Code

Fix icon cache code to properly render multiple sizes as needed.
authorjoncruz <joncruz@users.sourceforge.net>
Mon, 30 Mar 2009 09:36:22 +0000 (09:36 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Mon, 30 Mar 2009 09:36:22 +0000 (09:36 +0000)
src/widgets/icon.cpp

index 0bed152f8e338714cc75d5c689d33d522d766e5f..220ffc722ab2dff99e18030a72a2e8b3aece5944 100644 (file)
@@ -908,6 +908,9 @@ static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, un
 
     for ( std::vector<IconCacheItem>::iterator it = iconSetCache[name].begin(); it != iconSetCache[name].end(); ++it ) {
         if ( it->_lsize == lsize ) {
+            if (dump) {
+                g_message("         erasing %s:%d   %p", name, it->_lsize, it->_pb);
+            }
             iconSetCache[name].erase(it);
             break;
         }
@@ -937,9 +940,23 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize)
     if (pb) {
         return false;
     } else {
-        pb = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), name, psize,
-            (GtkIconLookupFlags) 0, NULL);
+        GtkIconTheme* theme = gtk_icon_theme_get_default();
+        if ( gtk_icon_theme_has_icon(theme, name) ) {
+            gint *sizeArray = gtk_icon_theme_get_icon_sizes( theme, name );
+            for (gint* cur = sizeArray; *cur; cur++) {
+                if (static_cast<gint>(psize) == *cur) {
+                    pb = gtk_icon_theme_load_icon( theme, name, psize,
+                                                   (GtkIconLookupFlags) 0, NULL );
+                    break;
+                }
+            }
+            g_free(sizeArray);
+            sizeArray = 0;
+        }
         if (!pb) {
+            if (dump) {
+                g_message("prerender_icon  [%s] %d", name, psize);
+            }
             guchar* px = load_svg_pixels(name, lsize, psize);
             if ( !px ) {
                 // check for a fallback name
@@ -958,6 +975,9 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize)
                 g_message("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX  error!!! pixels not found for '%s'", name);
             }
         }
+        else if (dump) {
+            g_message("prerender_icon  [%s] %d NOT!!!!!!", name, psize);
+        }
 
         if (pb) {
             pb_cache[key] = pb;