From 0bd6c48315079978f36d00e2681d94ae8e504c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 6 Feb 2016 09:24:36 +0100 Subject: [PATCH] Add and use gtk_icon_helper_invalidate_for_change --- gtk/gtkiconhelper.c | 19 +++++++++++++++++-- gtk/gtkiconhelperprivate.h | 3 +++ gtk/gtkimage.c | 3 +-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index 0b4b9b797e..ef05f83c2e 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -63,6 +63,22 @@ gtk_icon_helper_invalidate (GtkIconHelper *self) gtk_widget_queue_resize (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self))); } +void +gtk_icon_helper_invalidate_for_change (GtkIconHelper *self, + GtkCssStyleChange *change) +{ + GtkIconHelperPrivate *priv = self->priv; + + if (change && + ((gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SYMBOLIC_ICON) && + priv->rendered_surface_is_symbolic) || + (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON) && + !priv->rendered_surface_is_symbolic))) + { + gtk_icon_helper_invalidate (self); + } +} + static void gtk_icon_helper_take_definition (GtkIconHelper *self, GtkImageDefinition *def) @@ -147,8 +163,7 @@ static void gtk_icon_helper_style_changed (GtkCssGadget *gadget, GtkCssStyleChange *change) { - if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON)) - gtk_icon_helper_invalidate (GTK_ICON_HELPER (gadget)); + gtk_icon_helper_invalidate_for_change (GTK_ICON_HELPER (gadget), change); if (!GTK_IS_CSS_TRANSIENT_NODE (gtk_css_gadget_get_node (gadget))) GTK_CSS_GADGET_CLASS (gtk_icon_helper_parent_class)->style_changed (gadget, change); diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h index f4bdcd4817..185c2715de 100644 --- a/gtk/gtkiconhelperprivate.h +++ b/gtk/gtkiconhelperprivate.h @@ -140,6 +140,9 @@ void _gtk_icon_helper_set_force_scale_pixbuf (GtkIconHelper *self, void gtk_icon_helper_invalidate (GtkIconHelper *self); +void gtk_icon_helper_invalidate_for_change (GtkIconHelper *self, + GtkCssStyleChange *change); + G_END_DECLS #endif /* __GTK_ICON_HELPER_H__ */ diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 32d43bdb5c..4b1d158703 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -1930,8 +1930,7 @@ gtk_image_style_updated (GtkWidget *widget) { GtkCssStyleChange *change = gtk_style_context_get_change (context); - if (change && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON)) - gtk_icon_helper_invalidate (priv->icon_helper); + gtk_icon_helper_invalidate_for_change (priv->icon_helper, change); } GTK_WIDGET_CLASS (gtk_image_parent_class)->style_updated (widget);