[gtk+] icontheme: support emblems in symbolic icons



commit faba7df4fea6cd09470b3b2cc277c35e6cf7c380
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Tue Nov 5 18:32:28 2013 -0800

    icontheme: support emblems in symbolic icons
    
    We were failing to apply emblems in the symbolic icons code path.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725683

 gtk/gtkicontheme.c |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index c857f5b..9131006 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3569,25 +3569,19 @@ gtk_icon_info_is_symbolic (GtkIconInfo *icon_info)
 
 static gboolean icon_info_ensure_scale_and_pixbuf (GtkIconInfo*, gboolean);
 
-/* Combine the icon with all emblems, the first emblem is placed 
- * in the southeast corner. Scale emblems to be at most 3/4 of the
- * size of the icon itself.
- */
-static void 
-apply_emblems (GtkIconInfo *info)
+static GdkPixbuf *
+apply_emblems_to_pixbuf (GdkPixbuf *pixbuf,
+                         GtkIconInfo *info)
 {
   GdkPixbuf *icon = NULL;
   gint w, h, pos;
   GSList *l;
 
   if (info->emblem_infos == NULL)
-    return;
-
-  if (info->emblems_applied)
-    return;
+    return g_object_ref (pixbuf);
 
-  w = gdk_pixbuf_get_width (info->pixbuf);
-  h = gdk_pixbuf_get_height (info->pixbuf);
+  w = gdk_pixbuf_get_width (pixbuf);
+  h = gdk_pixbuf_get_height (pixbuf);
 
   for (l = info->emblem_infos, pos = 0; l; l = l->next, pos++)
     {
@@ -3633,7 +3627,7 @@ apply_emblems (GtkIconInfo *info)
 
           if (icon == NULL)
             {
-              icon = gdk_pixbuf_copy (info->pixbuf);
+              icon = gdk_pixbuf_copy (pixbuf);
               if (icon == NULL)
                 break;
             }
@@ -3643,6 +3637,23 @@ apply_emblems (GtkIconInfo *info)
        }
    }
 
+  return icon;
+}
+
+/* Combine the icon with all emblems, the first emblem is placed 
+ * in the southeast corner. Scale emblems to be at most 3/4 of the
+ * size of the icon itself.
+ */
+static void 
+apply_emblems (GtkIconInfo *info)
+{
+  GdkPixbuf *icon;
+
+  if (info->emblems_applied)
+    return;
+
+  icon = apply_emblems_to_pixbuf (info->pixbuf, info);
+
   if (icon)
     {
       g_object_unref (info->pixbuf);
@@ -4291,6 +4302,12 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo  *icon_info,
 
   if (pixbuf != NULL)
     {
+      GdkPixbuf *icon;
+
+      icon = apply_emblems_to_pixbuf (pixbuf, icon_info);
+      g_object_unref (pixbuf);
+      pixbuf = icon;
+
       if (use_cache)
        {
          icon_info->symbolic_pixbuf_cache =


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