[gtk+] css: Move property parsing into styleproperty file
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Move property parsing into styleproperty file
- Date: Thu, 2 Jun 2011 00:10:32 +0000 (UTC)
commit d0e1e2b1031e56a7baba01fe41bcd1491ec4253e
Author: Benjamin Otte <otte redhat com>
Date: Thu May 26 01:25:00 2011 +0200
css: Move property parsing into styleproperty file
Just shuffles code around for parsing properties.
gtk/gtkcssprovider.c | 73 ++++++++++++------------------------------------
gtk/gtkstyleproperty.c | 28 ++++++++++++++++++
2 files changed, 46 insertions(+), 55 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 5d35797..89a3ce6 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2087,73 +2087,36 @@ parse_declaration (GtkCssScanner *scanner,
val = g_slice_new0 (GValue);
g_value_init (val, property->pspec->value_type);
- if (_gtk_css_parser_try (scanner->parser, "none", TRUE))
+ if (_gtk_style_property_parse_value (property,
+ val,
+ scanner->parser,
+ gtk_css_scanner_get_base_url (scanner)))
{
- /* Insert the default value, so it has an opportunity
- * to override other style providers when merged
- */
- g_param_value_set_default (property->pspec, val);
- gtk_css_ruleset_add (ruleset, property, val);
- }
- else if (property->property_parse_func)
- {
- GError *error = NULL;
- char *value_str;
-
- value_str = _gtk_css_parser_read_value (scanner->parser);
- if (value_str == NULL)
- {
- _gtk_css_parser_resync (scanner->parser, TRUE, '}');
- g_slice_free (GValue, val);
- return;
- }
-
- if ((*property->property_parse_func) (value_str, val, &error))
+ if (_gtk_css_parser_begins_with (scanner->parser, ';') ||
+ _gtk_css_parser_begins_with (scanner->parser, '}') ||
+ _gtk_css_parser_is_eof (scanner->parser))
{
gtk_css_ruleset_add (ruleset, property, val);
}
else
{
- gtk_css_provider_take_error (scanner->provider, scanner, error);
+ gtk_css_provider_error_literal (scanner->provider,
+ scanner,
+ GTK_CSS_PROVIDER_ERROR,
+ GTK_CSS_PROVIDER_ERROR_SYNTAX,
+ "Junk at end of value");
+ _gtk_css_parser_resync (scanner->parser, TRUE, '}');
g_value_unset (val);
g_slice_free (GValue, val);
+ return;
}
-
- g_free (value_str);
}
else
{
- if (_gtk_style_property_parse_value (property,
- val,
- scanner->parser,
- gtk_css_scanner_get_base_url (scanner)))
- {
- if (_gtk_css_parser_begins_with (scanner->parser, ';') ||
- _gtk_css_parser_begins_with (scanner->parser, '}') ||
- _gtk_css_parser_is_eof (scanner->parser))
- {
- gtk_css_ruleset_add (ruleset, property, val);
- }
- else
- {
- gtk_css_provider_error_literal (scanner->provider,
- scanner,
- GTK_CSS_PROVIDER_ERROR,
- GTK_CSS_PROVIDER_ERROR_SYNTAX,
- "Junk at end of value");
- _gtk_css_parser_resync (scanner->parser, TRUE, '}');
- g_value_unset (val);
- g_slice_free (GValue, val);
- return;
- }
- }
- else
- {
- g_value_unset (val);
- g_slice_free (GValue, val);
- _gtk_css_parser_resync (scanner->parser, TRUE, '}');
- return;
- }
+ g_value_unset (val);
+ g_slice_free (GValue, val);
+ _gtk_css_parser_resync (scanner->parser, TRUE, '}');
+ return;
}
}
else if (name[0] == '-')
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 7a0003d..ce3cf05 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -1387,6 +1387,34 @@ _gtk_style_property_parse_value (const GtkStyleProperty *property,
css_string_funcs_init ();
+ if (property)
+ {
+ if (_gtk_css_parser_try (parser, "none", TRUE))
+ {
+ /* Insert the default value, so it has an opportunity
+ * to override other style providers when merged
+ */
+ g_param_value_set_default (property->pspec, value);
+ 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;
+ }
+ }
+
func = g_hash_table_lookup (parse_funcs,
GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
if (func == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]