[gtk+/css-fixes: 3/15] css: Parse enums with new case-insensitive helper
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/css-fixes: 3/15] css: Parse enums with new case-insensitive helper
- Date: Fri, 25 Nov 2011 14:53:19 +0000 (UTC)
commit 3e2402941505a179c6e505d6ee880472c6b5c801
Author: Alexander Larsson <alexl redhat com>
Date: Fri Nov 25 14:30:47 2011 +0100
css: Parse enums with new case-insensitive helper
gtk/gtkstyleproperty.c | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index f511c71..b904dc7 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -1360,9 +1360,14 @@ enum_value_parse (GtkCssParser *parser,
GFile *base,
GValue *value)
{
- GEnumClass *enum_class;
- GEnumValue *enum_value;
char *str;
+ int v;
+
+ if (_gtk_css_parser_try_enum (parser, G_VALUE_TYPE (value), &v))
+ {
+ g_value_set_enum (value, v);
+ return TRUE;
+ }
str = _gtk_css_parser_try_ident (parser, TRUE);
if (str == NULL)
@@ -1370,21 +1375,13 @@ enum_value_parse (GtkCssParser *parser,
_gtk_css_parser_error (parser, "Expected an identifier");
return FALSE;
}
-
- enum_class = g_type_class_ref (G_VALUE_TYPE (value));
- enum_value = g_enum_get_value_by_nick (enum_class, str);
-
- if (enum_value)
- g_value_set_enum (value, enum_value->value);
- else
- _gtk_css_parser_error (parser,
- "Unknown value '%s' for enum type '%s'",
- str, g_type_name (G_VALUE_TYPE (value)));
- g_type_class_unref (enum_class);
+ _gtk_css_parser_error (parser,
+ "Unknown value '%s' for enum type '%s'",
+ str, g_type_name (G_VALUE_TYPE (value)));
g_free (str);
- return enum_value != NULL;
+ return FALSE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]