[gtk+/css-fixes: 5/15] css: Use enum parsing for background repeat style



commit 2a42fad1458cde90199940161c4d3c04db10aacb
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Nov 25 14:36:27 2011 +0100

    css: Use enum parsing for background repeat style

 gtk/gtkstyleproperty.c |   27 +++++----------------------
 1 files changed, 5 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 0aed216..a545ed6 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]