iconhelper: Remove the context argument

Instead, use the widget's context.
This commit is contained in:
Benjamin Otte 2015-12-08 20:57:24 +01:00
parent e95e2d5048
commit ccfc4d3f12
7 changed files with 19 additions and 25 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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);
}

View File

@ -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);