[gtk+/wip/css: 81/154] styleproperty: Move parse func
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css: 81/154] styleproperty: Move parse func
- Date: Sat, 7 Jan 2012 14:54:44 +0000 (UTC)
commit dffd846477dbd5092498096760e8ff7efc3e24cd
Author: Benjamin Otte <otte redhat com>
Date: Mon Jan 2 09:53:03 2012 +0100
styleproperty: Move parse func
It's specific to GtKCssStyleProperty after all.
gtk/gtkcssstyleproperty.c | 52 +++++++++++++++++++++++++++++++++++++++
gtk/gtkstyleproperty.c | 59 ---------------------------------------------
2 files changed, 52 insertions(+), 59 deletions(-)
---
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index d262a59..b7c7afe 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 ();
}
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 0bc2275..4bc9c38 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -119,12 +119,6 @@ gtk_style_property_get_property (GObject *object,
}
}
-static gboolean
-gtk_style_property_real_parse_value (GtkStyleProperty *property,
- GValue *value,
- GtkCssParser *parser,
- GFile *base);
-
static void
_gtk_style_property_class_init (GtkStylePropertyClass *klass)
{
@@ -149,8 +143,6 @@ _gtk_style_property_class_init (GtkStylePropertyClass *klass)
G_TYPE_NONE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- klass->parse_value = gtk_style_property_real_parse_value;
-
klass->properties = g_hash_table_new (g_str_hash, g_str_equal);
}
@@ -404,57 +396,6 @@ _gtk_style_property_parse_value (GtkStyleProperty *property,
return klass->parse_value (property, value, parser, base);
}
-static gboolean
-gtk_style_property_real_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);
-}
-
/**
* _gtk_style_property_assign:
* @property: the property
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]