summaryrefslogtreecommitdiff
path: root/gtk/gtkicontheme.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-10-21 18:44:08 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-10-21 18:44:08 +0000
commita34d841d7964cdf3cef591700ba3e8baaea4723d (patch)
treeb833f7f9a0b5823856765fdf565f778fa3a0e094 /gtk/gtkicontheme.c
parent81c28db09dd7b8c19cedd8d4dddb7389aaeb9f2d (diff)
downloadgdk-pixbuf-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/gtkicontheme.c')
-rw-r--r--gtk/gtkicontheme.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 7b428bcf9..1b9e9a699 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -1322,6 +1322,27 @@ gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
return pixbuf;
}
+typedef struct
+{
+ const gchar *icon_name;
+ gboolean found;
+} CacheSearch;
+
+static void
+cache_has_icon (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ GtkIconCache *cache = (GtkIconCache *)value;
+ CacheSearch *search = (CacheSearch *)user_data;
+
+ if (!cache || search->found)
+ return;
+
+ if (_gtk_icon_cache_has_icon (cache, search->icon_name))
+ search->found = TRUE;
+}
+
/**
* gtk_icon_theme_has_icon:
* @icon_theme: a #GtkIconTheme
@@ -1340,6 +1361,8 @@ gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
const char *icon_name)
{
GtkIconThemePrivate *priv;
+ GList *l;
+ CacheSearch search;
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), FALSE);
@@ -1347,6 +1370,27 @@ gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
ensure_valid_themes (icon_theme);
+ search.icon_name = icon_name;
+ search.found = FALSE;
+
+ for (l = priv->themes; l; l = l->next)
+ {
+ IconTheme *theme = (IconTheme *)l->data;
+
+ g_hash_table_foreach (theme->icon_caches, cache_has_icon, &search);
+
+ if (search.found)
+ return TRUE;
+ }
+
+ for (l = priv->unthemed_icons_caches; l; l = l->next)
+ {
+ GtkIconCache *cache = (GtkIconCache *)l->data;
+
+ if (_gtk_icon_cache_has_icon (cache, icon_name))
+ return TRUE;
+ }
+
if (g_hash_table_lookup_extended (priv->all_icons,
icon_name, NULL, NULL))
return TRUE;
@@ -1741,9 +1785,9 @@ theme_dir_get_icon_suffix (IconThemeDir *dir,
dir->subdir);
if (has_icon_file)
- {
- *has_icon_file = suffix & HAS_ICON_FILE;
- }
+ *has_icon_file = suffix & HAS_ICON_FILE;
+
+ suffix = suffix & ~HAS_ICON_FILE;
}
else
suffix = GPOINTER_TO_UINT (g_hash_table_lookup (dir->icons, icon_name));