diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-10-21 18:44:08 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-10-21 18:44:08 +0000 |
commit | a34d841d7964cdf3cef591700ba3e8baaea4723d (patch) | |
tree | b833f7f9a0b5823856765fdf565f778fa3a0e094 /gtk/gtkiconcache.c | |
parent | 81c28db09dd7b8c19cedd8d4dddb7389aaeb9f2d (diff) | |
download | gtk+-a34d841d7964cdf3cef591700ba3e8baaea4723d.tar.gz |
Implement for cached themes.
2004-10-21 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkicontheme.c (gtk_icon_theme_has_icon): Implement for
cached themes.
* gtk/gtkiconcache.h:
* gtk/gtkiconcache.c (_gtk_icon_cache_has_icon): New function.
* gtk/updateiconcache.c (scan_directory): Don't skip .icon
files which are listed before their images.
(foreach_remove_func): Instead filter lonely .icon files out
here.
* gtk/gtkicontheme.c (theme_dir_get_icon_suffix): Filter out
the HAS_ICON_FILE flag.
Diffstat (limited to 'gtk/gtkiconcache.c')
-rw-r--r-- | gtk/gtkiconcache.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/gtk/gtkiconcache.c b/gtk/gtkiconcache.c index 7aca03eac0..5175787c7c 100644 --- a/gtk/gtkiconcache.c +++ b/gtk/gtkiconcache.c @@ -50,7 +50,6 @@ GtkIconCache * _gtk_icon_cache_ref (GtkIconCache *cache) { cache->ref_count ++; - return cache; } @@ -141,7 +140,6 @@ _gtk_icon_cache_new_for_path (const gchar *path) cache->ref_count = 1; cache->buffer = buffer; cache->size = st.st_size; - done: g_free (cache_filename); close (fd); @@ -282,6 +280,36 @@ _gtk_icon_cache_add_icons (GtkIconCache *cache, chain_offset = GET_UINT32 (cache->buffer, chain_offset); } - } + } +} + +gboolean +_gtk_icon_cache_has_icon (GtkIconCache *cache, + const gchar *icon_name) +{ + guint32 hash_offset; + guint32 n_buckets; + guint32 chain_offset; + gint hash; + hash_offset = GET_UINT32 (cache->buffer, 4); + n_buckets = GET_UINT32 (cache->buffer, hash_offset); + + hash = icon_name_hash (icon_name) % n_buckets; + + chain_offset = GET_UINT32 (cache->buffer, hash_offset + 4 + 4 * hash); + while (chain_offset != 0xffffffff) + { + guint32 name_offset = GET_UINT32 (cache->buffer, chain_offset + 4); + gchar *name = cache->buffer + name_offset; + + if (strcmp (name, icon_name) == 0) + return TRUE; + + chain_offset = GET_UINT32 (cache->buffer, chain_offset); + } + + return FALSE; } + + |