[gtk+/wip/otte/gadget: 2/30] cssnodedeclaration: Add possibility to set the name
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/gadget: 2/30] cssnodedeclaration: Add possibility to set the name
- Date: Sun, 11 Oct 2015 18:18:36 +0000 (UTC)
commit 20e1dbc09659008aed5cdc7519e1e3dc83db3270
Author: Benjamin Otte <otte redhat com>
Date: Fri Sep 4 19:38:50 2015 +0200
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.
gtk/gtkcssnodedeclaration.c | 33 ++++++++++++++++++++++++++++++++-
gtk/gtkcssnodedeclarationprivate.h | 3 +++
2 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c
index da1c944..6d861fb 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;
diff --git a/gtk/gtkcssnodedeclarationprivate.h b/gtk/gtkcssnodedeclarationprivate.h
index 066b8e2..a72111a 100644
--- a/gtk/gtkcssnodedeclarationprivate.h
+++ b/gtk/gtkcssnodedeclarationprivate.h
@@ -34,6 +34,9 @@ GtkJunctionSides gtk_css_node_declaration_get_junction_sides (const G
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_name (GtkCssNodeDeclaration **decl,
+ /*interned*/ const char
*name);
+/*interned*/ const char*gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration
*decl);
gboolean gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl,
const char *id);
const char * gtk_css_node_declaration_get_id (const GtkCssNodeDeclaration
*decl);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]