iconhelper: Remove the context argument
Instead, use the widget's context.
This commit is contained in:
parent
e95e2d5048
commit
ccfc4d3f12
@ -1376,7 +1376,6 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
|
|||||||
HICON prev_hicon;
|
HICON prev_hicon;
|
||||||
#endif
|
#endif
|
||||||
GtkIconHelper *icon_helper;
|
GtkIconHelper *icon_helper;
|
||||||
GtkStyleContext *context;
|
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
@ -1391,7 +1390,6 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon)
|
|||||||
if (widget == NULL)
|
if (widget == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
round_size = round_pixel_size (widget, priv->size);
|
round_size = round_pixel_size (widget, priv->size);
|
||||||
|
|
||||||
icon_helper = _gtk_icon_helper_new (widget);
|
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_definition (icon_helper, priv->image_def);
|
||||||
_gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
_gtk_icon_helper_set_icon_size (icon_helper, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
_gtk_icon_helper_set_pixel_size (icon_helper, round_size);
|
_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);
|
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, round_size, round_size);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
|
@ -480,7 +480,6 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
|
|||||||
|
|
||||||
if (!_gtk_icon_helper_get_is_empty (icon_helper))
|
if (!_gtk_icon_helper_get_is_empty (icon_helper))
|
||||||
_gtk_icon_helper_get_size (icon_helper,
|
_gtk_icon_helper_get_size (icon_helper,
|
||||||
gtk_widget_get_style_context (widget),
|
|
||||||
&pixbuf_width, &pixbuf_height);
|
&pixbuf_width, &pixbuf_height);
|
||||||
|
|
||||||
g_object_unref (icon_helper);
|
g_object_unref (icon_helper);
|
||||||
@ -594,7 +593,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
|
|||||||
icon_helper = create_icon_helper (cellpixbuf, widget);
|
icon_helper = create_icon_helper (cellpixbuf, widget);
|
||||||
|
|
||||||
_gtk_icon_helper_draw (icon_helper,
|
_gtk_icon_helper_draw (icon_helper,
|
||||||
context, cr,
|
cr,
|
||||||
pix_rect.x, pix_rect.y);
|
pix_rect.x, pix_rect.y);
|
||||||
g_object_unref (icon_helper);
|
g_object_unref (icon_helper);
|
||||||
|
|
||||||
|
@ -2785,7 +2785,7 @@ get_icon_width (GtkEntry *entry,
|
|||||||
state = gtk_style_context_get_state (context);
|
state = gtk_style_context_get_state (context);
|
||||||
gtk_style_context_get_padding (context, state, &padding);
|
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);
|
&width, NULL);
|
||||||
gtk_style_context_restore (context);
|
gtk_style_context_restore (context);
|
||||||
|
|
||||||
@ -3795,7 +3795,7 @@ draw_icon (GtkWidget *widget,
|
|||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
gtk_style_context_save_to_node (context, icon_info->css_node);
|
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);
|
&pix_width, &pix_height);
|
||||||
state = gtk_style_context_get_state (context);
|
state = gtk_style_context_get_state (context);
|
||||||
gtk_style_context_get_padding (context, state, &padding);
|
gtk_style_context_get_padding (context, state, &padding);
|
||||||
@ -3804,7 +3804,7 @@ draw_icon (GtkWidget *widget,
|
|||||||
y = MAX (0, (height - pix_height) / 2);
|
y = MAX (0, (height - pix_height) / 2);
|
||||||
|
|
||||||
_gtk_icon_helper_draw (icon_info->icon_helper,
|
_gtk_icon_helper_draw (icon_info->icon_helper,
|
||||||
context, cr,
|
cr,
|
||||||
x, y);
|
x, y);
|
||||||
|
|
||||||
gtk_style_context_restore (context);
|
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));
|
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
|
||||||
gtk_style_context_save_to_node (context, icon_info->css_node);
|
gtk_style_context_save_to_node (context, icon_info->css_node);
|
||||||
|
|
||||||
_gtk_icon_helper_get_size (icon_info->icon_helper, context, &width, &height);
|
_gtk_icon_helper_get_size (icon_info->icon_helper, &width, &height);
|
||||||
surface = gtk_icon_helper_load_surface (icon_info->icon_helper,
|
surface = gtk_icon_helper_load_surface (icon_info->icon_helper, 1);
|
||||||
context,
|
|
||||||
1);
|
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||||
|
|
||||||
|
@ -428,13 +428,15 @@ ensure_surface_for_gicon (GtkIconHelper *self,
|
|||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
gtk_icon_helper_load_surface (GtkIconHelper *self,
|
gtk_icon_helper_load_surface (GtkIconHelper *self,
|
||||||
GtkStyleContext *context,
|
|
||||||
int scale)
|
int scale)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
GtkStyleContext *context;
|
||||||
GtkIconSet *icon_set;
|
GtkIconSet *icon_set;
|
||||||
GIcon *gicon;
|
GIcon *gicon;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (self->priv->owner);
|
||||||
|
|
||||||
switch (gtk_image_definition_get_storage_type (self->priv->def))
|
switch (gtk_image_definition_get_storage_type (self->priv->def))
|
||||||
{
|
{
|
||||||
case GTK_IMAGE_SURFACE:
|
case GTK_IMAGE_SURFACE:
|
||||||
@ -519,17 +521,18 @@ gtk_icon_helper_ensure_surface (GtkIconHelper *self,
|
|||||||
|
|
||||||
scale = gtk_widget_get_scale_factor (self->priv->owner);
|
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
|
void
|
||||||
_gtk_icon_helper_get_size (GtkIconHelper *self,
|
_gtk_icon_helper_get_size (GtkIconHelper *self,
|
||||||
GtkStyleContext *context,
|
|
||||||
gint *width_out,
|
gint *width_out,
|
||||||
gint *height_out)
|
gint *height_out)
|
||||||
{
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
gint width, height, scale;
|
gint width, height, scale;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (self->priv->owner);
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
|
|
||||||
/* Certain kinds of images are easy to calculate the size for, these
|
/* Certain kinds of images are easy to calculate the size for, these
|
||||||
@ -791,11 +794,12 @@ _gtk_icon_helper_new (GtkWidget *owner)
|
|||||||
|
|
||||||
void
|
void
|
||||||
_gtk_icon_helper_draw (GtkIconHelper *self,
|
_gtk_icon_helper_draw (GtkIconHelper *self,
|
||||||
GtkStyleContext *context,
|
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y)
|
gdouble y)
|
||||||
{
|
{
|
||||||
|
GtkStyleContext *context = gtk_widget_get_style_context (self->priv->owner);
|
||||||
|
|
||||||
gtk_icon_helper_ensure_surface (self, context);
|
gtk_icon_helper_ensure_surface (self, context);
|
||||||
|
|
||||||
if (self->priv->rendered_surface != NULL)
|
if (self->priv->rendered_surface != NULL)
|
||||||
|
@ -121,15 +121,12 @@ const gchar *_gtk_icon_helper_get_stock_id (GtkIconHelper *self);
|
|||||||
const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self);
|
const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self);
|
||||||
|
|
||||||
cairo_surface_t *gtk_icon_helper_load_surface (GtkIconHelper *self,
|
cairo_surface_t *gtk_icon_helper_load_surface (GtkIconHelper *self,
|
||||||
GtkStyleContext *context,
|
|
||||||
int scale);
|
int scale);
|
||||||
void _gtk_icon_helper_get_size (GtkIconHelper *self,
|
void _gtk_icon_helper_get_size (GtkIconHelper *self,
|
||||||
GtkStyleContext *context,
|
|
||||||
gint *width_out,
|
gint *width_out,
|
||||||
gint *height_out);
|
gint *height_out);
|
||||||
|
|
||||||
void _gtk_icon_helper_draw (GtkIconHelper *self,
|
void _gtk_icon_helper_draw (GtkIconHelper *self,
|
||||||
GtkStyleContext *context,
|
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y);
|
gdouble y);
|
||||||
|
@ -1623,10 +1623,8 @@ gtk_image_get_preferred_size (GtkImage *image,
|
|||||||
GtkImagePrivate *priv = image->priv;
|
GtkImagePrivate *priv = image->priv;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
GtkBorder border;
|
GtkBorder border;
|
||||||
GtkStyleContext *context;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (image));
|
_gtk_icon_helper_get_size (priv->icon_helper, &width, &height);
|
||||||
_gtk_icon_helper_get_size (priv->icon_helper, context, &width, &height);
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
_gtk_misc_get_padding_and_border (GTK_MISC (image), &border);
|
_gtk_misc_get_padding_and_border (GTK_MISC (image), &border);
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
@ -1716,7 +1714,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_gtk_icon_helper_draw (priv->icon_helper,
|
_gtk_icon_helper_draw (priv->icon_helper,
|
||||||
context, cr,
|
cr,
|
||||||
x, y);
|
x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_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_background (context, cr, 0, 0, width, height);
|
||||||
gtk_render_frame (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);
|
x = floor ((width - icon_width) / 2.0);
|
||||||
y = floor ((height - icon_height) / 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);
|
cairo_restore (cr);
|
||||||
|
|
||||||
gtk_style_context_restore (context);
|
gtk_style_context_restore (context);
|
||||||
|
Loading…
Reference in New Issue
Block a user