diff options
author | Benjamin Otte <otte@redhat.com> | 2015-09-04 19:38:50 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-10-22 16:35:14 +0200 |
commit | 26450a661e5498b29a455b52f4ce70c134c81cd5 (patch) | |
tree | e5b9f7646f752d2789ff06809cc65f6ddbf130d1 /gtk/gtkcssnodedeclaration.c | |
parent | b65f400d565a3d30a9cd8b686296176f00abefee (diff) | |
download | gtk+-26450a661e5498b29a455b52f4ce70c134c81cd5.tar.gz |
cssnodedeclaration: Add possibility to set the name
This is supposed to be a replacement for setting the type. So far, both
options are possible - either will unset the other.
Diffstat (limited to 'gtk/gtkcssnodedeclaration.c')
-rw-r--r-- | gtk/gtkcssnodedeclaration.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c index da1c944bd3..6d861fb448 100644 --- a/gtk/gtkcssnodedeclaration.c +++ b/gtk/gtkcssnodedeclaration.c @@ -33,6 +33,7 @@ struct _GtkCssNodeDeclaration { guint refcount; GtkJunctionSides junction_sides; GType type; + const /* interned */ char *name; const /* interned */ char *id; GtkStateFlags state; guint n_classes; @@ -118,6 +119,9 @@ gtk_css_node_declaration_new (void) 1, /* need to own a ref ourselves so the copy-on-write path kicks in when people change things */ 0, 0, + NULL, + NULL, + 0, 0, 0 }; @@ -166,10 +170,12 @@ gboolean gtk_css_node_declaration_set_type (GtkCssNodeDeclaration **decl, GType type) { - if ((*decl)->type == type) + if ((*decl)->type == type && + (*decl)->name == NULL) return FALSE; gtk_css_node_declaration_make_writable (decl); + (*decl)->name = NULL; (*decl)->type = type; return TRUE; @@ -182,6 +188,27 @@ gtk_css_node_declaration_get_type (const GtkCssNodeDeclaration *decl) } gboolean +gtk_css_node_declaration_set_name (GtkCssNodeDeclaration **decl, + /*interned*/ const char *name) +{ + if ((*decl)->type == 0 && + (*decl)->name == name) + return FALSE; + + gtk_css_node_declaration_make_writable (decl); + (*decl)->type = 0; + (*decl)->name = name; + + return TRUE; +} + +/*interned*/ const char * +gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl) +{ + return decl->name; +} + +gboolean gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl, const char *id) { @@ -510,6 +537,7 @@ gtk_css_node_declaration_hash (gconstpointer elem) guint hash, i; hash = (guint) decl->type; + hash ^= GPOINTER_TO_UINT (decl->name); hash <<= 5; hash ^= GPOINTER_TO_UINT (decl->id); @@ -550,6 +578,9 @@ gtk_css_node_declaration_equal (gconstpointer elem1, if (decl1->type != decl2->type) return FALSE; + if (decl1->name != decl2->name) + return FALSE; + if (decl1->state != decl2->state) return FALSE; |