[gtk+] iconhelper: Respect -gtk-icon-style



commit f8cccbad0ee7c4c29ff374ef30c0903f5b939a80
Author: Benjamin Otte <otte redhat com>
Date:   Sat May 10 21:50:37 2014 +0200

    iconhelper: Respect -gtk-icon-style
    
    This allows styling of entry icons, treeview pixbufs and images. They
    can now be forced to be symbolic or regular.

 gtk/gtkiconhelper.c          |   12 +++++++++---
 gtk/gtkstylecontext.c        |   24 ++++++++++++++++++++++++
 gtk/gtkstylecontextprivate.h |    4 ++++
 3 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index ba7e272..b88cf02 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -19,8 +19,12 @@
 
 #include "config.h"
 
+#include "gtkiconhelperprivate.h"
+
 #include <math.h>
+
 #include "gtkiconhelperprivate.h"
+#include "gtkstylecontextprivate.h"
 
 struct _GtkIconHelperPrivate {
   GtkImageType storage_type;
@@ -254,7 +258,7 @@ check_invalidate_pixbuf (GtkIconHelper *self,
 }
 
 static GtkIconLookupFlags
-get_icon_lookup_flags (GtkIconHelper *self)
+get_icon_lookup_flags (GtkIconHelper *self, GtkStyleContext *context)
 {
   GtkIconLookupFlags flags = GTK_ICON_LOOKUP_USE_BUILTIN;
 
@@ -263,6 +267,8 @@ get_icon_lookup_flags (GtkIconHelper *self)
   if (self->priv->pixel_size != -1)
     flags |= GTK_ICON_LOOKUP_FORCE_SIZE;
 
+  flags |= _gtk_style_context_get_icon_lookup_flags (context);
+
   return flags;
 }
 
@@ -279,7 +285,7 @@ ensure_pixbuf_for_gicon (GtkIconHelper *self,
     return;
 
   icon_theme = gtk_icon_theme_get_default ();
-  flags = get_icon_lookup_flags (self);
+  flags = get_icon_lookup_flags (self, context);
 
   ensure_icon_size (self, context, &width, &height);
 
@@ -685,7 +691,7 @@ ensure_surface_for_gicon (GtkIconHelper   *self,
     return;
 
   icon_theme = gtk_icon_theme_get_default ();
-  flags = get_icon_lookup_flags (self);
+  flags = get_icon_lookup_flags (self, context);
 
   ensure_icon_size (self, context, &width, &height);
   scale = get_scale_factor (self, context);
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 0dd86c4..c9b1812 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -27,6 +27,7 @@
 #include "gtkcsscolorvalueprivate.h"
 #include "gtkcsscornervalueprivate.h"
 #include "gtkcssenginevalueprivate.h"
+#include "gtkcssenumvalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcssrgbavalueprivate.h"
 #include "gtkdebug.h"
@@ -4677,6 +4678,29 @@ _gtk_style_context_get_changes (GtkStyleContext *context)
   return context->priv->invalidating_context;
 }
 
+GtkIconLookupFlags
+_gtk_style_context_get_icon_lookup_flags (GtkStyleContext *context)
+{
+  GtkCssIconStyle icon_style;
+
+  g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
+
+  icon_style = _gtk_css_icon_style_value_get (_gtk_style_context_peek_property (context, 
GTK_CSS_PROPERTY_ICON_STYLE));
+
+  switch (icon_style)
+    {
+    case GTK_CSS_ICON_STYLE_REGULAR:
+      return GTK_ICON_LOOKUP_FORCE_REGULAR;
+    case GTK_CSS_ICON_STYLE_SYMBOLIC:
+      return GTK_ICON_LOOKUP_FORCE_SYMBOLIC;
+    case GTK_CSS_ICON_STYLE_REQUESTED:
+      return 0;
+    default:
+      g_assert_not_reached ();
+      return 0;
+    }
+}
+
 static AtkAttributeSet *
 add_attribute (AtkAttributeSet  *attributes,
                AtkTextAttribute  attr,
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 0db71e9..56b658c 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -19,6 +19,8 @@
 #define __GTK_STYLE_CONTEXT_PRIVATE_H__
 
 #include "gtkstylecontext.h"
+
+#include "gtkicontheme.h"
 #include "gtkstyleproviderprivate.h"
 #include "gtkbitmaskprivate.h"
 #include "gtkcssvalueprivate.h"
@@ -54,6 +56,8 @@ void           _gtk_style_context_get_cursor_color           (GtkStyleContext
 
 void           _gtk_style_context_update_animating           (GtkStyleContext    *context);
 
+GtkIconLookupFlags _gtk_style_context_get_icon_lookup_flags  (GtkStyleContext    *context);
+
 G_END_DECLS
 
 #endif /* __GTK_STYLE_CONTEXT_PRIVATE_H__ */


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