diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-07-20 04:14:59 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-07-20 04:14:59 +0000 |
commit | 81c0660f19d89c7bff8d13b1d86a1803ded6056b (patch) | |
tree | fc8dd21aa4b31727fba89e34822c97f2cd912834 /gtk | |
parent | ed1f9073fffd397f9bd46403d43dca46f3b3ddc9 (diff) | |
download | gtk+-81c0660f19d89c7bff8d13b1d86a1803ded6056b.tar.gz |
Add xdg_init-free versions of some functions and use them internally, so
2006-07-20 Matthias Clasen <mclasen@redhat.com>
* xdgmimemagic.c:
* xdgmime.c:
* xdgmime.h: Add xdg_init-free versions of some
functions and use them internally, so that we don't
reload caches and clobber data structures in the
middle of an operation. Patch by Joe Shaw,
bugs.freedesktop.org #6824
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/xdgmime/ChangeLog | 10 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmime.c | 54 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmime.h | 10 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmimemagic.c | 4 |
4 files changed, 58 insertions, 20 deletions
diff --git a/gtk/xdgmime/ChangeLog b/gtk/xdgmime/ChangeLog index f316e4b904..0105cfafb2 100644 --- a/gtk/xdgmime/ChangeLog +++ b/gtk/xdgmime/ChangeLog @@ -1,3 +1,13 @@ +2006-07-20 Matthias Clasen <mclasen@redhat.com> + + * xdgmimemagic.c: + * xdgmime.c: + * xdgmime.h: Add xdg_init-free versions of some + functions and use them internally, so that we don't + reload caches and clobber data structures in the + middle of an operation. Patch by Joe Shaw, + bugs.freedesktop.org #6824 + 2006-07-19 Matthias Clasen <mclasen@redhat.com> * xdgmimeglob.c (_xdg_glob_hash_node_lookup_file_name): diff --git a/gtk/xdgmime/xdgmime.c b/gtk/xdgmime/xdgmime.c index 2cc1e68d27..16026cf1fd 100644 --- a/gtk/xdgmime/xdgmime.c +++ b/gtk/xdgmime/xdgmime.c @@ -602,12 +602,10 @@ xdg_mime_get_max_buffer_extents (void) } const char * -xdg_mime_unalias_mime_type (const char *mime_type) +_xdg_mime_unalias_mime_type (const char *mime_type) { const char *lookup; - xdg_mime_init (); - if (_caches) return _xdg_mime_cache_unalias_mime_type (mime_type); @@ -617,16 +615,22 @@ xdg_mime_unalias_mime_type (const char *mime_type) return mime_type; } +const char * +xdg_mime_unalias_mime_type (const char *mime_type) +{ + xdg_mime_init (); + + return _xdg_mime_unalias_mime_type (mime_type); +} + int -xdg_mime_mime_type_equal (const char *mime_a, - const char *mime_b) +_xdg_mime_mime_type_equal (const char *mime_a, + const char *mime_b) { const char *unalias_a, *unalias_b; - xdg_mime_init (); - - unalias_a = xdg_mime_unalias_mime_type (mime_a); - unalias_b = xdg_mime_unalias_mime_type (mime_b); + unalias_a = _xdg_mime_unalias_mime_type (mime_a); + unalias_b = _xdg_mime_unalias_mime_type (mime_b); if (strcmp (unalias_a, unalias_b) == 0) return 1; @@ -635,6 +639,15 @@ xdg_mime_mime_type_equal (const char *mime_a, } int +xdg_mime_mime_type_equal (const char *mime_a, + const char *mime_b) +{ + xdg_mime_init (); + + return _xdg_mime_mime_type_equal (mime_a, mime_b); +} + +int xdg_mime_media_type_equal (const char *mime_a, const char *mime_b) { @@ -668,19 +681,17 @@ xdg_mime_is_super_type (const char *mime) #endif int -xdg_mime_mime_type_subclass (const char *mime, - const char *base) +_xdg_mime_mime_type_subclass (const char *mime, + const char *base) { const char *umime, *ubase; const char **parents; - xdg_mime_init (); - if (_caches) return _xdg_mime_cache_mime_type_subclass (mime, base); - umime = xdg_mime_unalias_mime_type (mime); - ubase = xdg_mime_unalias_mime_type (base); + umime = _xdg_mime_unalias_mime_type (mime); + ubase = _xdg_mime_unalias_mime_type (base); if (strcmp (umime, ubase) == 0) return 1; @@ -703,13 +714,22 @@ xdg_mime_mime_type_subclass (const char *mime, parents = _xdg_mime_parent_list_lookup (parent_list, umime); for (; parents && *parents; parents++) { - if (xdg_mime_mime_type_subclass (*parents, ubase)) + if (_xdg_mime_mime_type_subclass (*parents, ubase)) return 1; } return 0; } +int +xdg_mime_mime_type_subclass (const char *mime, + const char *base) +{ + xdg_mime_init (); + + return _xdg_mime_mime_type_subclass (mime, base); +} + char ** xdg_mime_list_mime_parents (const char *mime) { @@ -741,7 +761,7 @@ xdg_mime_get_mime_parents (const char *mime) xdg_mime_init (); - umime = xdg_mime_unalias_mime_type (mime); + umime = _xdg_mime_unalias_mime_type (mime); return _xdg_mime_parent_list_lookup (parent_list, umime); } diff --git a/gtk/xdgmime/xdgmime.h b/gtk/xdgmime/xdgmime.h index 2fa4a7cf39..d8172be25b 100644 --- a/gtk/xdgmime/xdgmime.h +++ b/gtk/xdgmime/xdgmime.h @@ -96,8 +96,16 @@ int xdg_mime_register_reload_callback (XdgMimeCallback callback, XdgMimeDestroy destroy); void xdg_mime_remove_callback (int callback_id); + /* Private versions of functions that don't call xdg_mime_init () */ +int _xdg_mime_mime_type_equal (const char *mime_a, + const char *mime_b); +int _xdg_mime_media_type_equal (const char *mime_a, + const char *mime_b); +int _xdg_mime_mime_type_subclass (const char *mime, + const char *base); + + #ifdef __cplusplus } #endif /* __cplusplus */ - #endif /* __XDG_MIME_H__ */ diff --git a/gtk/xdgmime/xdgmimemagic.c b/gtk/xdgmime/xdgmimemagic.c index 1718be7810..8258b2bb1b 100644 --- a/gtk/xdgmime/xdgmimemagic.c +++ b/gtk/xdgmime/xdgmimemagic.c @@ -664,7 +664,7 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic, { if (_xdg_mime_magic_match_compare_to_data (match, data, len)) { - if ((mime_type == NULL) || (xdg_mime_mime_type_subclass (match->mime_type, mime_type))) { + if ((mime_type == NULL) || (_xdg_mime_mime_type_subclass (match->mime_type, mime_type))) { mime_type = match->mime_type; } } @@ -673,7 +673,7 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic, for (n = 0; n < n_mime_types; n++) { if (mime_types[n] && - xdg_mime_mime_type_equal (mime_types[n], match->mime_type)) + _xdg_mime_mime_type_equal (mime_types[n], match->mime_type)) mime_types[n] = NULL; } } |