diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcssnodedeclaration.c | 25 | ||||
-rw-r--r-- | gtk/gtkcssnodedeclarationprivate.h | 3 | ||||
-rw-r--r-- | gtk/gtkstylecontext.c | 14 |
3 files changed, 40 insertions, 2 deletions
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c index 1c099304c0..e5c718708a 100644 --- a/gtk/gtkcssnodedeclaration.c +++ b/gtk/gtkcssnodedeclaration.c @@ -32,6 +32,7 @@ struct _GtkRegion struct _GtkCssNodeDeclaration { guint refcount; GtkJunctionSides junction_sides; + GType type; GtkStateFlags state; guint n_classes; guint n_regions; @@ -161,6 +162,25 @@ gtk_css_node_declaration_get_junction_sides (const GtkCssNodeDeclaration *decl) } gboolean +gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl, + GType type) +{ + if ((*decl)->type == type) + return FALSE; + + gtk_css_node_declaration_make_writable (decl); + (*decl)->type = type; + + return TRUE; +} + +GType +gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl) +{ + return decl->type; +} + +gboolean gtk_css_node_declaration_set_state (GtkCssNodeDeclaration **decl, GtkStateFlags state) { @@ -426,7 +446,7 @@ gtk_css_node_declaration_hash (gconstpointer elem) GtkRegion *regions; guint hash, i; - hash = 0; + hash = (guint) decl->type; classes = get_classes (decl); for (i = 0; i < decl->n_classes; i++) @@ -462,6 +482,9 @@ gtk_css_node_declaration_equal (gconstpointer elem1, if (decl1 == decl2) return TRUE; + if (decl1->type != decl2->type) + return FALSE; + if (decl1->state != decl2->state) return FALSE; diff --git a/gtk/gtkcssnodedeclarationprivate.h b/gtk/gtkcssnodedeclarationprivate.h index 767b6ecfb5..56323ac506 100644 --- a/gtk/gtkcssnodedeclarationprivate.h +++ b/gtk/gtkcssnodedeclarationprivate.h @@ -33,6 +33,9 @@ void gtk_css_node_declaration_unref (GtkCssN gboolean gtk_css_node_declaration_set_junction_sides (GtkCssNodeDeclaration **decl, GtkJunctionSides junction_sides); GtkJunctionSides gtk_css_node_declaration_get_junction_sides (const GtkCssNodeDeclaration *decl); +gboolean gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl, + GType type); +GType gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl); gboolean gtk_css_node_declaration_set_state (GtkCssNodeDeclaration **decl, GtkStateFlags flags); GtkStateFlags gtk_css_node_declaration_get_state (const GtkCssNodeDeclaration *decl); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 747ad745c6..2b34d0d2e7 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -881,6 +881,11 @@ _gtk_style_context_set_widget (GtkStyleContext *context, context->priv->widget = widget; + if (widget) + gtk_css_node_declaration_set_type (&context->priv->info->decl, G_OBJECT_TYPE (widget)); + else + gtk_css_node_declaration_set_type (&context->priv->info->decl, G_TYPE_NONE); + _gtk_style_context_update_animating (context); _gtk_style_context_queue_invalidate (context, GTK_CSS_CHANGE_ANY_SELF); @@ -1373,10 +1378,17 @@ gtk_style_context_set_path (GtkStyleContext *context, { gtk_widget_path_free (priv->widget_path); priv->widget_path = NULL; + gtk_css_node_declaration_set_type (&context->priv->info->decl, G_TYPE_NONE); } if (path) - priv->widget_path = gtk_widget_path_copy (path); + { + priv->widget_path = gtk_widget_path_copy (path); + if (gtk_widget_path_length (path)) + gtk_css_node_declaration_set_type (&context->priv->info->decl, + gtk_widget_path_iter_get_object_type (path, -1)); + } + _gtk_style_context_queue_invalidate (context, GTK_CSS_CHANGE_ANY); } |