[gnome-shell] shell-app: Evict faded app icons on icon theme change



commit 581d1c5db1c040b86d9f5e0ae294952d60714ba2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Mar 17 00:20:31 2012 -0400

    shell-app: Evict faded app icons on icon theme change
    
    When a user changes icon themes, we don't want to waste precious memory
    with modified textures from the old icon theme.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672275

 src/shell-app.c           |    4 +++-
 src/st/st-texture-cache.c |    8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 81c761b..e164841 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -332,7 +332,9 @@ shell_app_get_faded_icon (ShellApp *app, int size)
   if (!app->entry)
     return window_backed_app_get_icon (app, size);
 
-  cache_key = g_strdup_printf ("faded-icon:%s,size=%d", shell_app_get_id (app), size);
+  /* Use icon: prefix so that we get evicted from the cache on
+   * icon theme changes. */
+  cache_key = g_strdup_printf ("icon:%s,size=%d,faded", shell_app_get_id (app), size);
   data.app = app;
   data.size = size;
   texture = st_texture_cache_load (st_texture_cache_get_default (),
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index ff1d857..3c7a1c8 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <glib.h>
 
-#define CACHE_PREFIX_GICON "gicon:"
+#define CACHE_PREFIX_ICON "icon:"
 #define CACHE_PREFIX_URI "uri:"
 #define CACHE_PREFIX_URI_FOR_CAIRO "uri-for-cairo:"
 #define CACHE_PREFIX_RAW_CHECKSUM "raw-checksum:"
@@ -112,7 +112,7 @@ st_texture_cache_evict_icons (StTextureCache *cache)
        * for GIcons even when they aren't named icons, but it's not
        * worth the complexity of parsing the key and calling
        * g_icon_new_for_string(); icon theme changes aren't normal */
-      if (g_str_has_prefix (cache_key, "gicon:"))
+      if (g_str_has_prefix (cache_key, CACHE_PREFIX_ICON))
         g_hash_table_iter_remove (&iter);
     }
 }
@@ -933,7 +933,7 @@ load_gicon_with_colors (StTextureCache    *cache,
   if (colors)
     {
       /* This raises some doubts about the practice of using string keys */
-      key = g_strdup_printf (CACHE_PREFIX_GICON "icon=%s,size=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
+      key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
                              gicon_string, size,
                              colors->foreground.red, colors->foreground.blue, colors->foreground.green, colors->foreground.alpha,
                              colors->warning.red, colors->warning.blue, colors->warning.green, colors->warning.alpha,
@@ -942,7 +942,7 @@ load_gicon_with_colors (StTextureCache    *cache,
     }
   else
     {
-      key = g_strdup_printf (CACHE_PREFIX_GICON "icon=%s,size=%d",
+      key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d",
                              gicon_string, size);
     }
   g_free (gicon_string);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]