css: Move property parsing into styleproperty file

Just shuffles code around for parsing properties.
This commit is contained in:
Benjamin Otte 2011-05-26 01:25:00 +02:00
parent 5a42464547
commit d0e1e2b103
2 changed files with 46 additions and 55 deletions

View File

@ -2087,42 +2087,6 @@ 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))
{
/* 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))
{
gtk_css_ruleset_add (ruleset, property, val);
}
else
{
gtk_css_provider_take_error (scanner->provider, scanner, error);
g_value_unset (val);
g_slice_free (GValue, val);
}
g_free (value_str);
}
else
{
if (_gtk_style_property_parse_value (property,
val,
scanner->parser,
@ -2155,7 +2119,6 @@ parse_declaration (GtkCssScanner *scanner,
return;
}
}
}
else if (name[0] == '-')
{
char *value_str;

View File

@ -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)