[glib] themedicon: correctly fallback to symbolic icons



commit a5fd296cc8583de6ac10c5a6adc84751495ad7e1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Aug 13 15:16:48 2013 +0200

    themedicon: correctly fallback to symbolic icons
    
    When an icon is requested as symbolic, our generic fallback algorithm
    uses fullcolor icons when the specified icon name is not found, treating
    the "-symbolic" suffix as another component of the icon name.
    
    Change the algorithm to check beforehand if the icon is symbolic, remove
    the suffix if so, and re-add it at the end for all the generated icon
    names.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680926

 gio/gthemedicon.c |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/gio/gthemedicon.c b/gio/gthemedicon.c
index fac9aa2..9016860 100644
--- a/gio/gthemedicon.c
+++ b/gio/gthemedicon.c
@@ -155,8 +155,17 @@ g_themed_icon_constructed (GObject *object)
       const char *p;
       char *dashp;
       char *last;
+      gboolean is_symbolic;
+      char *name;
+      char **names;
+
+      is_symbolic = g_str_has_suffix (themed->names[0], "-symbolic");
+      if (is_symbolic)
+        name = g_strndup (themed->names[0], strlen (themed->names[0]) - 9);
+      else
+        name = g_strdup (themed->names[0]);
 
-      p = themed->names[0];
+      p = name;
       while (*p)
         {
           if (*p == '-')
@@ -164,17 +173,31 @@ g_themed_icon_constructed (GObject *object)
           p++;
         }
 
-      last = g_strdup (themed->names[0]);
+      last = name;
 
       g_strfreev (themed->names);
 
-      themed->names = g_new (char *, dashes + 1 + 1);
-      themed->names[i++] = last;
+      names = g_new (char *, dashes + 1 + 1);
+      names[i++] = last;
 
       while ((dashp = strrchr (last, '-')) != NULL)
-        themed->names[i++] = last = g_strndup (last, dashp - last);
+        names[i++] = last = g_strndup (last, dashp - last);
+
+      names[i++] = NULL;
+
+      if (is_symbolic)
+        {
+          themed->names = g_new (char *, dashes + 1 + 1);
+          for (i = 0; names[i] != NULL; i++)
+            themed->names[i] = g_strconcat (names[i], "-symbolic", NULL);
 
-      themed->names[i++] = NULL;
+          themed->names[i] = NULL;
+          g_strfreev (names);
+        }
+      else
+        {
+          themed->names = names;
+        }
     }
 }
 


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