[gtk+] css: Add GTK_CSS_AFFECTS_ICON_SIZE
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Add GTK_CSS_AFFECTS_ICON_SIZE
- Date: Sat, 14 Oct 2017 17:19:27 +0000 (UTC)
commit 4e24cb858866abafc7208b33df9099d8b5e85d66
Author: Timm Bäder <mail baedert org>
Date: Sat Oct 14 14:58:53 2017 +0200
css: Add GTK_CSS_AFFECTS_ICON_SIZE
And use it in GtkIconHelper. This way, we can avoid resizes when e.g.
the fg color of a symbolic icon changes.
gtk/gtkcssstylepropertyimpl.c | 4 ++--
gtk/gtkcsstypesprivate.h | 1 +
gtk/gtkiconhelper.c | 15 ++++++++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index c68268e..8f714d8 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -1033,7 +1033,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_ICON_THEME,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
- GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+ GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON |
GTK_CSS_AFFECTS_ICON_SIZE,
icon_theme_value_parse,
NULL,
gtk_css_icon_theme_value_new (NULL));
@@ -1592,7 +1592,7 @@ _gtk_css_style_property_init_properties (void)
GTK_CSS_PROPERTY_ICON_STYLE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
- GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+ GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON |
GTK_CSS_AFFECTS_ICON_SIZE,
icon_style_parse,
NULL,
_gtk_css_icon_style_value_new (GTK_CSS_ICON_STYLE_REQUESTED));
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 1e43172..a173f55 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -127,6 +127,7 @@ typedef enum {
GTK_CSS_AFFECTS_CONTENT = (1 << 0),
GTK_CSS_AFFECTS_BACKGROUND = (1 << 1),
GTK_CSS_AFFECTS_BORDER = (1 << 2),
+ GTK_CSS_AFFECTS_ICON_SIZE = (1 << 3),
GTK_CSS_AFFECTS_TEXT_ATTRS = (1 << 4),
GTK_CSS_AFFECTS_TEXT_SIZE = (1 << 5),
GTK_CSS_AFFECTS_TEXT_CLIP = (1 << 6),
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 5fe7689..484c022 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -60,7 +60,20 @@ gtk_icon_helper_invalidate_for_change (GtkIconHelper *self,
(gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON) &&
!self->rendered_surface_is_symbolic)))
{
- gtk_icon_helper_invalidate (self);
+ /* Avoid the queue_resize in gtk_icon_helper_invalidate */
+ g_clear_object (&self->texture);
+
+ if (self->rendered_surface != NULL)
+ {
+ cairo_surface_destroy (self->rendered_surface);
+ self->rendered_surface = NULL;
+ self->rendered_surface_is_symbolic = FALSE;
+ }
+
+ if (change == NULL ||
+ (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE) &&
+ !GTK_IS_CSS_TRANSIENT_NODE (self->node)))
+ gtk_widget_queue_resize (self->owner);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]