From ccfc4d3f128d0617b3d9c0bbe034b5ceae771780 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 8 Dec 2015 20:57:24 +0100 Subject: [PATCH] iconhelper: Remove the context argument Instead, use the widget's context. --- gtk/deprecated/gtkstatusicon.c | 4 +--- gtk/gtkcellrendererpixbuf.c | 3 +-- gtk/gtkentry.c | 12 +++++------- gtk/gtkiconhelper.c | 12 ++++++++---- gtk/gtkiconhelperprivate.h | 3 --- gtk/gtkimage.c | 6 ++---- gtk/gtkspinbutton.c | 4 ++-- 7 files changed, 19 insertions(+), 25 deletions(-) diff --git a/gtk/deprecated/gtkstatusicon.c b/gtk/deprecated/gtkstatusicon.c index fd65b0aa54..b46dfcc7a9 100644 --- a/gtk/deprecated/gtkstatusicon.c +++ b/gtk/deprecated/gtkstatusicon.c @@ -1376,7 +1376,6 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon) HICON prev_hicon; #endif GtkIconHelper *icon_helper; - GtkStyleContext *context; cairo_surface_t *surface; GtkWidget *widget; GdkPixbuf *pixbuf; @@ -1391,7 +1390,6 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon) if (widget == NULL) return; - context = gtk_widget_get_style_context (widget); round_size = round_pixel_size (widget, priv->size); icon_helper = _gtk_icon_helper_new (widget); @@ -1399,7 +1397,7 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon) _gtk_icon_helper_set_definition (icon_helper, priv->image_def); _gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR); _gtk_icon_helper_set_pixel_size (icon_helper, round_size); - surface = gtk_icon_helper_load_surface (icon_helper, context, 1); + surface = gtk_icon_helper_load_surface (icon_helper, 1); pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, round_size, round_size); cairo_surface_destroy (surface); diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index 2f781cbbf4..36dbb045b7 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -480,7 +480,6 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell, if (!_gtk_icon_helper_get_is_empty (icon_helper)) _gtk_icon_helper_get_size (icon_helper, - gtk_widget_get_style_context (widget), &pixbuf_width, &pixbuf_height); g_object_unref (icon_helper); @@ -594,7 +593,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell, icon_helper = create_icon_helper (cellpixbuf, widget); _gtk_icon_helper_draw (icon_helper, - context, cr, + cr, pix_rect.x, pix_rect.y); g_object_unref (icon_helper); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 83e738b71f..31f0effbc5 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -2785,7 +2785,7 @@ get_icon_width (GtkEntry *entry, state = gtk_style_context_get_state (context); gtk_style_context_get_padding (context, state, &padding); - _gtk_icon_helper_get_size (icon_info->icon_helper, context, + _gtk_icon_helper_get_size (icon_info->icon_helper, &width, NULL); gtk_style_context_restore (context); @@ -3795,7 +3795,7 @@ draw_icon (GtkWidget *widget, context = gtk_widget_get_style_context (widget); gtk_style_context_save_to_node (context, icon_info->css_node); - _gtk_icon_helper_get_size (icon_info->icon_helper, context, + _gtk_icon_helper_get_size (icon_info->icon_helper, &pix_width, &pix_height); state = gtk_style_context_get_state (context); gtk_style_context_get_padding (context, state, &padding); @@ -3804,7 +3804,7 @@ draw_icon (GtkWidget *widget, y = MAX (0, (height - pix_height) / 2); _gtk_icon_helper_draw (icon_info->icon_helper, - context, cr, + cr, x, y); gtk_style_context_restore (context); @@ -8868,10 +8868,8 @@ gtk_entry_get_icon_pixbuf (GtkEntry *entry, context = gtk_widget_get_style_context (GTK_WIDGET (entry)); gtk_style_context_save_to_node (context, icon_info->css_node); - _gtk_icon_helper_get_size (icon_info->icon_helper, context, &width, &height); - surface = gtk_icon_helper_load_surface (icon_info->icon_helper, - context, - 1); + _gtk_icon_helper_get_size (icon_info->icon_helper, &width, &height); + surface = gtk_icon_helper_load_surface (icon_info->icon_helper, 1); pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height); diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index ad79e2d85e..a8f6698118 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -428,13 +428,15 @@ ensure_surface_for_gicon (GtkIconHelper *self, cairo_surface_t * gtk_icon_helper_load_surface (GtkIconHelper *self, - GtkStyleContext *context, int scale) { cairo_surface_t *surface; + GtkStyleContext *context; GtkIconSet *icon_set; GIcon *gicon; + context = gtk_widget_get_style_context (self->priv->owner); + switch (gtk_image_definition_get_storage_type (self->priv->def)) { case GTK_IMAGE_SURFACE: @@ -519,17 +521,18 @@ gtk_icon_helper_ensure_surface (GtkIconHelper *self, scale = gtk_widget_get_scale_factor (self->priv->owner); - self->priv->rendered_surface = gtk_icon_helper_load_surface (self, context, scale); + self->priv->rendered_surface = gtk_icon_helper_load_surface (self, scale); } void _gtk_icon_helper_get_size (GtkIconHelper *self, - GtkStyleContext *context, gint *width_out, gint *height_out) { + GtkStyleContext *context; gint width, height, scale; + context = gtk_widget_get_style_context (self->priv->owner); width = height = 0; /* Certain kinds of images are easy to calculate the size for, these @@ -791,11 +794,12 @@ _gtk_icon_helper_new (GtkWidget *owner) void _gtk_icon_helper_draw (GtkIconHelper *self, - GtkStyleContext *context, cairo_t *cr, gdouble x, gdouble y) { + GtkStyleContext *context = gtk_widget_get_style_context (self->priv->owner); + gtk_icon_helper_ensure_surface (self, context); if (self->priv->rendered_surface != NULL) diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h index df4fb6ab77..4fcbd8d111 100644 --- a/gtk/gtkiconhelperprivate.h +++ b/gtk/gtkiconhelperprivate.h @@ -121,15 +121,12 @@ const gchar *_gtk_icon_helper_get_stock_id (GtkIconHelper *self); const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self); cairo_surface_t *gtk_icon_helper_load_surface (GtkIconHelper *self, - GtkStyleContext *context, int scale); void _gtk_icon_helper_get_size (GtkIconHelper *self, - GtkStyleContext *context, gint *width_out, gint *height_out); void _gtk_icon_helper_draw (GtkIconHelper *self, - GtkStyleContext *context, cairo_t *cr, gdouble x, gdouble y); diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 48c00dc3e5..7494f413d7 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -1623,10 +1623,8 @@ gtk_image_get_preferred_size (GtkImage *image, GtkImagePrivate *priv = image->priv; gint width, height; GtkBorder border; - GtkStyleContext *context; - context = gtk_widget_get_style_context (GTK_WIDGET (image)); - _gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height); + _gtk_icon_helper_get_size (priv->icon_helper, &width, &height); G_GNUC_BEGIN_IGNORE_DEPRECATIONS _gtk_misc_get_padding_and_border (GTK_MISC (image), &border); G_GNUC_END_IGNORE_DEPRECATIONS @@ -1716,7 +1714,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS else { _gtk_icon_helper_draw (priv->icon_helper, - context, cr, + cr, x, y); } diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 7b2f2984da..27f60d3b6a 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -1113,7 +1113,7 @@ gtk_spin_button_panel_draw (GtkSpinButton *spin_button, _gtk_icon_helper_set_icon_name (icon_helper, "list-add-symbolic", GTK_ICON_SIZE_MENU); } - _gtk_icon_helper_get_size (icon_helper, context, &icon_width, &icon_height); + _gtk_icon_helper_get_size (icon_helper, &icon_width, &icon_height); gtk_render_background (context, cr, 0, 0, width, height); gtk_render_frame (context, cr, 0, 0, width, height); @@ -1121,7 +1121,7 @@ gtk_spin_button_panel_draw (GtkSpinButton *spin_button, x = floor ((width - icon_width) / 2.0); y = floor ((height - icon_height) / 2.0); - _gtk_icon_helper_draw (icon_helper, context, cr, x, y); + _gtk_icon_helper_draw (icon_helper, cr, x, y); cairo_restore (cr); gtk_style_context_restore (context);