[gtk+] cssimage: Implement symbolic coloring for -gtk-icontheme()



commit 271ef198bf0c7fd569136f9c72e2806d529cd9e8
Author: Benjamin Otte <otte redhat com>
Date:   Fri May 16 04:06:23 2014 +0200

    cssimage: Implement symbolic coloring for -gtk-icontheme()

 gtk/gtkcssimageicontheme.c        |   30 +++++++++++++++++++++++-------
 gtk/gtkcssimageiconthemeprivate.h |    1 +
 2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c
index a681fe2..91cfb6d 100644
--- a/gtk/gtkcssimageicontheme.c
+++ b/gtk/gtkcssimageicontheme.c
@@ -23,6 +23,7 @@
 
 #include <math.h>
 
+#include "gtkcssrgbavalueprivate.h"
 #include "gtksettingsprivate.h"
 #include "gtkstyleproviderprivate.h"
 
@@ -43,6 +44,7 @@ gtk_css_image_icon_theme_draw (GtkCssImage        *image,
 {
   GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
   GError *error = NULL;
+  GtkIconInfo *icon_info;
   GdkPixbuf *pixbuf;
   gint size;
 
@@ -50,12 +52,22 @@ gtk_css_image_icon_theme_draw (GtkCssImage        *image,
   if (size <= 0)
     return;
 
-  pixbuf = gtk_icon_theme_load_icon_for_scale (icon_theme->icon_theme,
-                                               icon_theme->name,
-                                               size,
-                                               icon_theme->scale,
-                                               GTK_ICON_LOOKUP_USE_BUILTIN,
-                                               &error);
+  icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme->icon_theme,
+                                                    icon_theme->name,
+                                                    size,
+                                                    icon_theme->scale,
+                                                    GTK_ICON_LOOKUP_USE_BUILTIN);
+  if (icon_info == NULL)
+    {
+      /* XXX: render missing icon image here? */
+      return;
+    }
+
+  pixbuf = gtk_icon_info_load_symbolic (icon_info,
+                                        &icon_theme->color,
+                                        NULL, NULL, NULL,
+                                        NULL,
+                                        &error);
   if (pixbuf == NULL)
     {
       /* XXX: render missing icon image here? */
@@ -70,12 +82,13 @@ gtk_css_image_icon_theme_draw (GtkCssImage        *image,
   cairo_paint (cr);
 
   g_object_unref (pixbuf);
+  g_object_unref (icon_info);
 }
 
 
 static gboolean
 gtk_css_image_icon_theme_parse (GtkCssImage  *image,
-                            GtkCssParser *parser)
+                                GtkCssParser *parser)
 {
   GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
 
@@ -133,6 +146,9 @@ gtk_css_image_icon_theme_compute (GtkCssImage             *image,
   copy->name = g_strdup (icon_theme->name);
   copy->icon_theme = gtk_icon_theme_get_for_screen (screen);
   copy->scale = scale;
+  copy->color = *_gtk_css_rgba_value_get_rgba (_gtk_css_computed_values_get_value (values, 
GTK_CSS_PROPERTY_COLOR));
+
+  *dependencies = GTK_CSS_DEPENDS_ON_COLOR;
 
   return GTK_CSS_IMAGE (copy);
 }
diff --git a/gtk/gtkcssimageiconthemeprivate.h b/gtk/gtkcssimageiconthemeprivate.h
index 8482060..5922146 100644
--- a/gtk/gtkcssimageiconthemeprivate.h
+++ b/gtk/gtkcssimageiconthemeprivate.h
@@ -40,6 +40,7 @@ struct _GtkCssImageIconTheme
   GtkCssImage parent;
 
   GtkIconTheme *icon_theme;
+  GdkRGBA color;
   gint scale;
   char *name;
 };


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