[gtk+/nth-child: 9/33] css: Move property parsing into styleproperty file
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/nth-child: 9/33] css: Move property parsing into styleproperty file
- Date: Fri, 27 May 2011 23:04:25 +0000 (UTC)
commit 93c12def8f3e85c109c7d26d81a8ae826ae7bf29
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 | 72 ++++++++++++++----------------------------------
gtk/gtkstyleproperty.c | 28 ++++++++++++++++++
2 files changed, 49 insertions(+), 51 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 303bb2d..3bd7c5f 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2082,67 +2082,37 @@ 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)
+ if (_gtk_css_parser_begins_with (scanner->parser, ';') ||
+ _gtk_css_parser_begins_with (scanner->parser, '}') ||
+ _gtk_css_parser_is_eof (scanner->parser))
{
- _gtk_css_parser_resync (scanner->parser, TRUE, '}');
- return;
- }
-
- if ((*property->property_parse_func) (value_str, val, &error))
- gtk_css_ruleset_add (ruleset, property, val);
- else
- gtk_css_provider_take_error (scanner->provider, scanner, error);
-
- 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;
- }
+ 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);
- _gtk_css_parser_resync (scanner->parser, TRUE, '}');
return;
}
}
+ else
+ {
+ 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 097f85e..9223b4b 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -1386,6 +1386,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]