[gtk+/wip/otte/gadget: 11/18] iconhelper: Require passing a cssnode to the constructor



commit 7c2f5ec494defa4e98d162ea82ae7de6d5d21b93
Author: Benjamin Otte <otte redhat com>
Date:   Wed Dec 9 18:25:36 2015 +0100

    iconhelper: Require passing a cssnode to the constructor
    
    Note that we don't use it yet.

 gtk/deprecated/gtkstatusicon.c |    3 ++-
 gtk/gtkcellrendererpixbuf.c    |    7 ++++---
 gtk/gtkentry.c                 |    6 +++---
 gtk/gtkiconhelper.c            |    5 ++++-
 gtk/gtkiconhelperprivate.h     |    3 ++-
 gtk/gtkimage.c                 |    5 +++--
 gtk/gtkstylecontext.c          |    6 ++++++
 gtk/gtkstylecontextprivate.h   |    1 +
 8 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/gtk/deprecated/gtkstatusicon.c b/gtk/deprecated/gtkstatusicon.c
index e384974..627a291 100644
--- a/gtk/deprecated/gtkstatusicon.c
+++ b/gtk/deprecated/gtkstatusicon.c
@@ -43,6 +43,7 @@
 #include "gtktooltip.h"
 #include "gtkicontheme.h"
 #include "gtklabel.h"
+#include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
 
 #ifdef GDK_WINDOWING_X11
@@ -1392,7 +1393,7 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
 
   round_size = round_pixel_size (widget, priv->size);
 
-  icon_helper = _gtk_icon_helper_new (widget);
+  icon_helper = gtk_icon_helper_new (gtk_style_context_get_node (gtk_widget_get_style_context (widget)), 
widget);
   _gtk_icon_helper_set_force_scale_pixbuf (icon_helper, TRUE);
   _gtk_icon_helper_set_definition (icon_helper, priv->image_def);
   _gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR);
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index 2201c72..30dcc1b 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -24,6 +24,7 @@
 #include "gtkicontheme.h"
 #include "gtkintl.h"
 #include "gtkprivate.h"
+#include "gtkstylecontextprivate.h"
 #include "a11y/gtkimagecellaccessible.h"
 
 
@@ -446,7 +447,7 @@ create_icon_helper (GtkCellRendererPixbuf *cellpixbuf,
   GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv;
   GtkIconHelper *helper;
 
-  helper = _gtk_icon_helper_new (widget);
+  helper = gtk_icon_helper_new (gtk_style_context_get_node (gtk_widget_get_style_context (widget)), widget);
   _gtk_icon_helper_set_force_scale_pixbuf (helper, TRUE);
   _gtk_icon_helper_set_definition (helper, priv->image_def);
   if (gtk_image_definition_get_storage_type (priv->image_def) != GTK_IMAGE_PIXBUF)
@@ -580,12 +581,12 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer      *cell,
 
       if (is_expanded && priv->pixbuf_expander_open != NULL)
         {
-          icon_helper = _gtk_icon_helper_new (widget);
+          icon_helper = gtk_icon_helper_new (gtk_style_context_get_node (context), widget);
           _gtk_icon_helper_set_pixbuf (icon_helper, priv->pixbuf_expander_open);
         }
       else if (!is_expanded && priv->pixbuf_expander_closed != NULL)
         {
-          icon_helper = _gtk_icon_helper_new (widget);
+          icon_helper = gtk_icon_helper_new (gtk_style_context_get_node (context), widget);
           _gtk_icon_helper_set_pixbuf (icon_helper, priv->pixbuf_expander_closed);
         }
     }
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 31f0eff..411abca 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -3256,9 +3256,6 @@ construct_icon_info (GtkWidget            *widget,
   icon_info = g_slice_new0 (EntryIconInfo);
   priv->icons[icon_pos] = icon_info;
 
-  icon_info->icon_helper = _gtk_icon_helper_new (widget);
-  _gtk_icon_helper_set_force_scale_pixbuf (icon_info->icon_helper, TRUE);
-
   widget_node = get_entry_node (widget);
   icon_info->css_node = gtk_css_node_new ();
   gtk_css_node_set_name (icon_info->css_node, I_("image"));
@@ -3267,6 +3264,9 @@ construct_icon_info (GtkWidget            *widget,
   update_icon_style (widget, icon_pos);
   g_object_unref (icon_info->css_node);
 
+  icon_info->icon_helper = gtk_icon_helper_new (icon_info->css_node, widget);
+  _gtk_icon_helper_set_force_scale_pixbuf (icon_info->icon_helper, TRUE);
+
   update_node_ordering (entry);
 
   if (gtk_widget_get_realized (widget))
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index b096955..241a400 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -770,11 +770,14 @@ _gtk_icon_helper_get_icon_name (GtkIconHelper *self)
 }
 
 GtkIconHelper *
-_gtk_icon_helper_new (GtkWidget *owner)
+gtk_icon_helper_new (GtkCssNode *node,
+                     GtkWidget  *owner)
 {
+  g_return_val_if_fail (GTK_IS_CSS_NODE (node), NULL);
   g_return_val_if_fail (GTK_IS_WIDGET (owner), NULL);
 
   return g_object_new (GTK_TYPE_ICON_HELPER,
+                       "node", node,
                        "owner", owner,
                        NULL);
 }
diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h
index b87e26a..1f869d4 100644
--- a/gtk/gtkiconhelperprivate.h
+++ b/gtk/gtkiconhelperprivate.h
@@ -68,7 +68,8 @@ struct _GtkIconHelperClass
 
 GType gtk_icon_helper_get_type (void) G_GNUC_CONST;
 
-GtkIconHelper *_gtk_icon_helper_new (GtkWidget *owner);
+GtkIconHelper *gtk_icon_helper_new (GtkCssNode *node,
+                                    GtkWidget  *owner);
 
 void _gtk_icon_helper_clear (GtkIconHelper *self);
 void _gtk_icon_helper_invalidate (GtkIconHelper *self);
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 4224902..b8530b2 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -419,11 +419,12 @@ gtk_image_init (GtkImage *image)
   image->priv = gtk_image_get_instance_private (image);
   priv = image->priv;
 
+  widget_node = gtk_widget_get_css_node (GTK_WIDGET (image));
   gtk_widget_set_has_window (GTK_WIDGET (image), FALSE);
-  priv->icon_helper = _gtk_icon_helper_new (GTK_WIDGET (image));
+
+  priv->icon_helper = gtk_icon_helper_new (widget_node, GTK_WIDGET (image));
   _gtk_icon_helper_set_icon_size (priv->icon_helper, DEFAULT_ICON_SIZE);
 
-  widget_node = gtk_widget_get_css_node (GTK_WIDGET (image));
   priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
                                                      GTK_WIDGET (image),
                                                      gtk_image_get_content_size,
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index b4a967e..7e8c2a0 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -484,6 +484,12 @@ gtk_style_context_lookup_style (GtkStyleContext *context)
   return gtk_css_node_get_style (context->priv->cssnode);
 }
 
+GtkCssNode*
+gtk_style_context_get_node (GtkStyleContext *context)
+{
+  return context->priv->cssnode;
+}
+
 static GtkStateFlags
 gtk_style_context_push_state (GtkStyleContext *context,
                               GtkStateFlags    state)
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 31f7127..91ce297 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
 
 GtkStyleContext *gtk_style_context_new_for_node              (GtkCssNode      *node);
 
+GtkCssNode     *gtk_style_context_get_node                   (GtkStyleContext *context);
 void            gtk_style_context_set_id                     (GtkStyleContext *context,
                                                               const char      *id);
 const char *    gtk_style_context_get_id                     (GtkStyleContext *context);


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