]> Pileus Git - ~andy/gtk/commitdiff
styleproperty: Add custom parser for custom properties
authorBenjamin Otte <otte@redhat.com>
Mon, 2 Jan 2012 09:37:04 +0000 (10:37 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 17:37:55 +0000 (18:37 +0100)
In particular, move the property_parse_func handling to
GtkCssCustomProperty exclusively.

gtk/gtkcsscustomproperty.c
gtk/gtkcssstyleproperty.c

index 1175af3e63883e076d411ed3c03eb45df081dda8..bb9aa415acb77b43193b3ca25652aa016f2b8b29 100644 (file)
 
 #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;
 }
 
 
index 62323738563aedd18c7b2852e0547632ade21775..76021dc8effaf9f4d456857ff2258acf3b742044 100644 (file)
@@ -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)