[gtk+/wip/css: 89/163] styleproperty: Add custom parser for custom properties



commit cecf09c746ace954da60512f6eb47fc0946e63e0
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jan 2 10:37:04 2012 +0100

    styleproperty: Add custom parser for custom properties
    
    In particular, move the property_parse_func handling to
    GtkCssCustomProperty exclusively.

 gtk/gtkcsscustomproperty.c |   37 +++++++++++++++++++++++++++++++++++++
 gtk/gtkcssstyleproperty.c  |   18 ------------------
 2 files changed, 37 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index 1175af3..bb9aa41 100644
--- a/gtk/gtkcsscustomproperty.c
+++ b/gtk/gtkcsscustomproperty.c
@@ -24,13 +24,50 @@
 
 #include <string.h>
 
+#include "gtkcssstylefuncsprivate.h"
 #include "gtkthemingengine.h"
 
 G_DEFINE_TYPE (GtkCssCustomProperty, _gtk_css_custom_property, GTK_TYPE_CSS_STYLE_PROPERTY)
 
+static gboolean
+gtk_css_custom_property_parse_value (GtkStyleProperty *property,
+                                     GValue           *value,
+                                     GtkCssParser     *parser,
+                                     GFile            *base)
+{
+  gboolean success;
+
+  g_value_init (value, _gtk_style_property_get_value_type (property));
+
+  if (property->property_parse_func)
+    {
+      GError *error = NULL;
+      char *value_str;
+      
+      value_str = _gtk_css_parser_read_value (parser);
+      if (value_str != NULL)
+        {
+          success = (*property->property_parse_func) (value_str, value, &error);
+          g_free (value_str);
+        }
+      else
+        success = FALSE;
+    }
+  else
+    success = _gtk_css_style_parse_value (value, parser, base);
+
+  if (!success)
+    g_value_unset (value);
+
+  return success;
+}
+
 static void
 _gtk_css_custom_property_class_init (GtkCssCustomPropertyClass *klass)
 {
+  GtkStylePropertyClass *property_class = GTK_STYLE_PROPERTY_CLASS (klass);
+
+  property_class->parse_value = gtk_css_custom_property_parse_value;
 }
 
 
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 6232373..76021dc 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -347,24 +347,6 @@ gtk_css_style_property_parse_value (GtkStyleProperty *property,
       g_value_set_enum (value, GTK_CSS_INHERIT);
       return TRUE;
     }
-  else if (property->property_parse_func)
-    {
-      GError *error = NULL;
-      char *value_str;
-      
-      value_str = _gtk_css_parser_read_value (parser);
-      if (value_str == NULL)
-        return FALSE;
-      
-      g_value_init (value, _gtk_style_property_get_value_type (property));
-      success = (*property->property_parse_func) (value_str, value, &error);
-
-      g_free (value_str);
-      if (!success)
-        g_value_unset (value);
-
-      return success;
-    }
 
   g_value_init (value, _gtk_style_property_get_value_type (property));
   if (property->parse_func)



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