diff options
author | Alexander Larsson <alexl@redhat.com> | 2011-11-25 14:36:27 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2011-11-25 15:36:08 +0100 |
commit | 2a42fad1458cde90199940161c4d3c04db10aacb (patch) | |
tree | 9a2c3c8446d9acb5a93e99e51d3173f2f843d357 /gtk/gtkstyleproperty.c | |
parent | 8fb4b1373079503686d7cfd8f23290b0c47c2126 (diff) | |
download | gtk+-2a42fad1458cde90199940161c4d3c04db10aacb.tar.gz |
css: Use enum parsing for background repeat style
Diffstat (limited to 'gtk/gtkstyleproperty.c')
-rw-r--r-- | gtk/gtkstyleproperty.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c index 0aed216340..a545ed6118 100644 --- a/gtk/gtkstyleproperty.c +++ b/gtk/gtkstyleproperty.c @@ -32,6 +32,7 @@ #include "gtkcssprovider.h" #include "gtkcssparserprivate.h" #include "gtkcsstypesprivate.h" +#include "gtkprivatetypebuiltins.h" /* the actual parsers we have */ #include "gtkanimationdescription.h" @@ -1205,14 +1206,10 @@ background_repeat_value_parse (GtkCssParser *parser, GValue *value) { GtkCssBackgroundRepeat repeat; - GtkCssBackgroundRepeatStyle style; + int style; - if (_gtk_css_parser_try (parser, "repeat", TRUE)) - style = GTK_CSS_BACKGROUND_REPEAT_STYLE_REPEAT; - else if (_gtk_css_parser_try (parser, "no-repeat", TRUE)) - style = GTK_CSS_BACKGROUND_REPEAT_STYLE_NO_REPEAT; - else - style = GTK_CSS_BACKGROUND_REPEAT_STYLE_NONE; + if (!enum_parse (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT_STYLE, &style)) + return FALSE; repeat.repeat = style; @@ -1221,20 +1218,6 @@ background_repeat_value_parse (GtkCssParser *parser, return TRUE; } -static const gchar * -background_repeat_style_to_string (GtkCssBackgroundRepeatStyle repeat) -{ - switch (repeat) - { - case GTK_CSS_BACKGROUND_REPEAT_STYLE_REPEAT: - return "repeat"; - case GTK_CSS_BACKGROUND_REPEAT_STYLE_NO_REPEAT: - return "no-repeat"; - default: - return NULL; - } -} - static void background_repeat_value_print (const GValue *value, GString *string) @@ -1243,7 +1226,7 @@ background_repeat_value_print (const GValue *value, repeat = g_value_get_boxed (value); - g_string_append (string, background_repeat_style_to_string (repeat->repeat)); + enum_print (repeat->repeat, GTK_TYPE_CSS_BACKGROUND_REPEAT_STYLE, string); } static gboolean |