diff options
author | Benjamin Otte <otte@redhat.com> | 2012-01-02 09:53:03 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-01-09 18:37:54 +0100 |
commit | 70af2cb2e3c6a7186632639aa86d4eb1f7fd8e3a (patch) | |
tree | 46c3716dda48bd86db34ec6644349575b396a466 /gtk/gtkcssstyleproperty.c | |
parent | 47a27a00f57c99a824d793a75c910f06148f8dca (diff) | |
download | gtk+-70af2cb2e3c6a7186632639aa86d4eb1f7fd8e3a.tar.gz |
styleproperty: Move parse func
It's specific to GtKCssStyleProperty after all.
Diffstat (limited to 'gtk/gtkcssstyleproperty.c')
-rw-r--r-- | gtk/gtkcssstyleproperty.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c index d262a59847..b7c7afedf7 100644 --- a/gtk/gtkcssstyleproperty.c +++ b/gtk/gtkcssstyleproperty.c @@ -318,6 +318,57 @@ _gtk_css_style_property_query (GtkStyleProperty *property, _gtk_style_property_default_value (property, props, state, value); } +static gboolean +gtk_css_style_property_parse_value (GtkStyleProperty *property, + GValue *value, + GtkCssParser *parser, + GFile *base) +{ + if (_gtk_css_parser_try (parser, "initial", TRUE)) + { + /* the initial value can be explicitly specified with the + * ‘initial’ keyword which all properties accept. + */ + g_value_unset (value); + g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE); + g_value_set_enum (value, GTK_CSS_INITIAL); + return TRUE; + } + else if (_gtk_css_parser_try (parser, "inherit", TRUE)) + { + /* All properties accept the ‘inherit’ value which + * explicitly specifies that the value will be determined + * by inheritance. The ‘inherit’ value can be used to + * strengthen inherited values in the cascade, and it can + * also be used on properties that are not normally inherited. + */ + g_value_unset (value); + g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE); + g_value_set_enum (value, GTK_CSS_INHERIT); + return TRUE; + } + else if (property->property_parse_func) + { + GError *error = NULL; + char *value_str; + gboolean success; + + value_str = _gtk_css_parser_read_value (parser); + if (value_str == NULL) + return FALSE; + + success = (*property->property_parse_func) (value_str, value, &error); + + g_free (value_str); + + return success; + } + else if (property->parse_func) + return (* property->parse_func) (parser, base, value); + else + return _gtk_css_style_parse_value (value, parser, base); +} + static void _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass) { @@ -352,6 +403,7 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass) property_class->assign = _gtk_css_style_property_assign; property_class->query = _gtk_css_style_property_query; + property_class->parse_value = gtk_css_style_property_parse_value; klass->style_properties = g_ptr_array_new (); } |