diff options
author | Benjamin Otte <otte@redhat.com> | 2015-02-01 16:43:58 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-03-18 15:23:30 +0100 |
commit | c4b88e05fd6f7018a2ed241610ed97323650ec41 (patch) | |
tree | 8029c08a06df0200001aef81e594c0789e899256 /gtk | |
parent | 637a4bda5ced8c3777673ef171ba9e6c62eab46f (diff) | |
download | gtk+-c4b88e05fd6f7018a2ed241610ed97323650ec41.tar.gz |
stylecontext: Redo handling of differing state
Instead of passing an "override_state" flag, create a new CssNode just
for this simple lookup.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcssnode.c | 6 | ||||
-rw-r--r-- | gtk/gtkcssnodeprivate.h | 1 | ||||
-rw-r--r-- | gtk/gtkstylecontext.c | 43 |
3 files changed, 26 insertions, 24 deletions
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c index 1f846d9341..fdaca1d997 100644 --- a/gtk/gtkcssnode.c +++ b/gtk/gtkcssnode.c @@ -365,12 +365,6 @@ gtk_css_node_get_declaration (GtkCssNode *cssnode) return cssnode->decl; } -GtkCssNodeDeclaration * -gtk_css_node_dup_declaration (GtkCssNode *cssnode) -{ - return gtk_css_node_declaration_ref (cssnode->decl); -} - void gtk_css_node_invalidate (GtkCssNode *cssnode, GtkCssChange change) diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h index 9687830caa..06e915523e 100644 --- a/gtk/gtkcssnodeprivate.h +++ b/gtk/gtkcssnodeprivate.h @@ -108,7 +108,6 @@ GList * gtk_css_node_list_regions (GtkCssNode * const GtkCssNodeDeclaration * gtk_css_node_get_declaration (GtkCssNode *cssnode); -GtkCssNodeDeclaration * gtk_css_node_dup_declaration (GtkCssNode *cssnode); GtkCssStyle * gtk_css_node_get_style (GtkCssNode *cssnode); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index c6051abd02..54365227ee 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -754,9 +754,7 @@ update_properties (GtkCssNode *cssnode, } static GtkCssStyle * -build_properties (GtkCssNode *cssnode, - gboolean override_state, - GtkStateFlags state) +build_properties (GtkCssNode *cssnode) { const GtkCssNodeDeclaration *decl; GtkCssMatcher matcher; @@ -772,8 +770,6 @@ build_properties (GtkCssNode *cssnode, return g_object_ref (style); path = gtk_css_node_create_widget_path (cssnode); - if (override_state) - gtk_widget_path_iter_set_state (path, -1, state); if (_gtk_css_matcher_init (&matcher, path)) style = gtk_css_static_style_new_compute (gtk_css_node_get_style_provider (cssnode), @@ -806,7 +802,7 @@ gtk_style_context_lookup_style (GtkStyleContext *context) if (values) return values; - values = build_properties (cssnode, FALSE, 0); + values = build_properties (cssnode); gtk_css_node_set_style (cssnode, values); g_object_unref (values); @@ -818,20 +814,35 @@ static GtkCssStyle * gtk_style_context_lookup_style_for_state (GtkStyleContext *context, GtkStateFlags state) { - GtkCssNodeDeclaration *decl; + GtkCssNode *node; GtkCssStyle *values; if (gtk_css_node_get_state (context->priv->cssnode) == state) return g_object_ref (gtk_style_context_lookup_style (context)); if (g_getenv ("GTK_STYLE_CONTEXT_WARNING")) - g_warning ("State does not match current state"); + { + GtkCssNode *root = gtk_style_context_get_root (context); + + if (GTK_IS_CSS_WIDGET_NODE (root)) + { + GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root)); + g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()", + state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (context->priv->cssnode)); + } + else + { + g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()", + state, context, gtk_css_node_get_state (context->priv->cssnode)); + } + } - decl = gtk_css_node_dup_declaration (context->priv->cssnode); - gtk_css_node_declaration_set_state (&decl, state); - values = build_properties (context->priv->cssnode, - TRUE, state); - gtk_css_node_declaration_unref (decl); + node = gtk_css_transient_node_new (context->priv->cssnode); + gtk_css_node_set_parent (node, gtk_css_node_get_parent (context->priv->cssnode)); + gtk_css_node_set_state (node, state); + values = build_properties (node); + gtk_css_node_set_parent (node, NULL); + g_object_unref (node); return values; } @@ -2823,7 +2834,7 @@ _gtk_style_context_validate (GtkStyleContext *context, { GtkCssStyle *style, *static_style; - static_style = build_properties (cssnode, FALSE, 0); + static_style = build_properties (cssnode); style = gtk_css_animated_style_new (static_style, priv->parent ? gtk_style_context_lookup_style (priv->parent) : NULL, timestamp, @@ -2916,9 +2927,7 @@ gtk_style_context_invalidate (GtkStyleContext *context) gtk_css_node_set_style (context->priv->cssnode, NULL); root = gtk_style_context_get_root (context); - style = build_properties (root, - FALSE, - 0); + style = build_properties (root); gtk_css_node_set_style (root, style); g_object_unref (style); |