summaryrefslogtreecommitdiff
path: root/gtk/gtkcsscustomproperty.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-01-02 10:37:04 +0100
committerBenjamin Otte <otte@redhat.com>2012-01-09 18:37:55 +0100
commit61042d155cca8adb56d527e9f1a1f48d1b7a8834 (patch)
treeb6ad46fc611b81fa4271be8cace8a2f2bf4bca42 /gtk/gtkcsscustomproperty.c
parent22e9588dad30f580e31efc1b1495fb04af5990d0 (diff)
downloadgtk+-61042d155cca8adb56d527e9f1a1f48d1b7a8834.tar.gz
styleproperty: Add custom parser for custom properties
In particular, move the property_parse_func handling to GtkCssCustomProperty exclusively.
Diffstat (limited to 'gtk/gtkcsscustomproperty.c')
-rw-r--r--gtk/gtkcsscustomproperty.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index 1175af3e63..bb9aa415ac 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;
}