Add and use gtk_icon_helper_invalidate_for_change

This commit is contained in:
Timm Bäder 2016-02-06 09:24:36 +01:00
parent 0c80210685
commit 0bd6c48315
3 changed files with 21 additions and 4 deletions

View File

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

View File

@ -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__ */

View File

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