[gtk+/wip/cssvalue: 140/141] customrpoperty: Ensure style properties are registered



commit cfceda9de350b4e0b9de130676e96c7c262d0813
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 7 17:24:50 2012 +0200

    customrpoperty: Ensure style properties are registered
    
    ... before reigstering our own. Also, use that capability to emit a
    warning.

 gtk/gtkcsscustomproperty.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index 7bbce57..3b19cc0 100644
--- a/gtk/gtkcsscustomproperty.c
+++ b/gtk/gtkcsscustomproperty.c
@@ -229,6 +229,15 @@ gtk_theming_engine_register_property (const gchar            *name_space,
   g_return_if_fail (G_IS_PARAM_SPEC (pspec));
 
   name = g_strdup_printf ("-%s-%s", name_space, pspec->name);
+
+  /* This also initializes the default properties */
+  if (_gtk_style_property_lookup (pspec->name))
+    {
+      g_warning ("a property with name '%s' already exists", name);
+      g_free (name);
+      return;
+    }
+  
   initial = gtk_css_custom_property_create_initial_value (pspec);
 
   node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
@@ -264,6 +273,13 @@ gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
 
   g_return_if_fail (G_IS_PARAM_SPEC (pspec));
 
+  /* This also initializes the default properties */
+  if (_gtk_style_property_lookup (pspec->name))
+    {
+      g_warning ("a property with name '%s' already exists", pspec->name);
+      return;
+    }
+  
   initial = gtk_css_custom_property_create_initial_value (pspec);
 
   node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]