[gtk+/wip/cssstyle: 24/27] cssnodedeclaration: Store the GType of the node
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssstyle: 24/27] cssnodedeclaration: Store the GType of the node
- Date: Wed, 24 Dec 2014 02:21:24 +0000 (UTC)
commit d3aa4ea715a6f1b432f72ace5044be2248054f65
Author: Benjamin Otte <otte redhat com>
Date: Sun Dec 21 20:26:26 2014 +0100
cssnodedeclaration: Store the GType of the node
gtk/gtkcssnodedeclaration.c | 25 ++++++++++++++++++++++++-
gtk/gtkcssnodedeclarationprivate.h | 3 +++
gtk/gtkstylecontext.c | 14 +++++++++++++-
3 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c
index 1c09930..e5c7187 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 767b6ec..56323ac 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 bed3522..7e18c5a 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -869,6 +869,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);
@@ -1361,10 +1366,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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]