GtkCssProvider: Make additions to parse_value() less error prone.

This commit is contained in:
Carlos Garnacho 2010-06-18 16:42:48 +02:00
parent 814957021f
commit aa5ec97cac

View File

@ -874,6 +874,8 @@ parse_value (GType type,
const gchar *value_str, const gchar *value_str,
GValue *value) GValue *value)
{ {
gboolean parsed = TRUE;
g_value_init (value, type); g_value_init (value, type);
if (type == GDK_TYPE_COLOR) if (type == GDK_TYPE_COLOR)
@ -884,7 +886,6 @@ parse_value (GType type,
return FALSE; return FALSE;
g_value_set_boxed (value, &color); g_value_set_boxed (value, &color);
return TRUE;
} }
else if (type == PANGO_TYPE_FONT_DESCRIPTION) else if (type == PANGO_TYPE_FONT_DESCRIPTION)
{ {
@ -892,31 +893,25 @@ parse_value (GType type,
font_desc = pango_font_description_from_string (value_str); font_desc = pango_font_description_from_string (value_str);
g_value_take_boxed (value, font_desc); g_value_take_boxed (value, font_desc);
return TRUE;
} }
else if (type == G_TYPE_INT) else if (type == G_TYPE_INT)
{ g_value_set_int (value, atoi (value_str));
g_value_set_int (value, atoi (value_str));
return TRUE;
}
else if (type == G_TYPE_DOUBLE) else if (type == G_TYPE_DOUBLE)
{ g_value_set_double (value, g_ascii_strtod (value_str, NULL));
g_value_set_double (value, g_ascii_strtod (value_str, NULL));
return TRUE;
}
else if (type == GTK_TYPE_THEMING_ENGINE) else if (type == GTK_TYPE_THEMING_ENGINE)
{ {
GtkThemingEngine *engine; GtkThemingEngine *engine;
engine = gtk_theming_engine_load (value_str); engine = gtk_theming_engine_load (value_str);
g_value_set_object (value, engine); g_value_set_object (value, engine);
return TRUE;
} }
else else
g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type)); {
g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type));
parsed = FALSE;
}
return FALSE; return parsed;
} }
static GTokenType static GTokenType