Commit 61042d15 authored by Benjamin Otte's avatar Benjamin Otte

styleproperty: Add custom parser for custom properties

In particular, move the property_parse_func handling to
GtkCssCustomProperty exclusively.
parent 22e9588d
......@@ -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;
}
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment