Commit ad22612a authored by Benjamin Otte's avatar Benjamin Otte Committed by Matthias Clasen

iconhelper: Require passing a cssnode to the constructor

Note that we don't use it yet.
parent 7075d009
......@@ -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);
......
......@@ -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);
}
}
......
......@@ -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))
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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,
......
......@@ -1087,16 +1087,17 @@ gtk_spin_button_panel_draw (GtkSpinButton *spin_button,
height = gdk_window_get_height (panel);
width = gdk_window_get_width (panel);
icon_helper = _gtk_icon_helper_new (widget);
_gtk_icon_helper_set_use_fallback (icon_helper, TRUE);
if (panel == priv->down_panel)
{
icon_helper = gtk_icon_helper_new (priv->down_node, widget);
_gtk_icon_helper_set_use_fallback (icon_helper, TRUE);
gtk_style_context_save_to_node (context, priv->down_node);
_gtk_icon_helper_set_icon_name (icon_helper, "list-remove-symbolic", GTK_ICON_SIZE_MENU);
}
else
{
icon_helper = gtk_icon_helper_new (priv->up_node, widget);
_gtk_icon_helper_set_use_fallback (icon_helper, TRUE);
gtk_style_context_save_to_node (context, priv->up_node);
_gtk_icon_helper_set_icon_name (icon_helper, "list-add-symbolic", GTK_ICON_SIZE_MENU);
}
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment