[gtk+/wip/cssvalue: 55/164] stylepropertyimpl: Add parse funcs for enums



commit 3967665b5a7d483d17db1902fa772c3c65b68d73
Author: Benjamin Otte <otte redhat com>
Date:   Tue Mar 27 06:29:37 2012 +0200

    stylepropertyimpl: Add parse funcs for enums

 gtk/gtkcssstylepropertyimpl.c |  100 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 90 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 7315b9d..3b1bd42 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -260,6 +260,86 @@ font_family_value_print (GtkCssStyleProperty *property,
 }
 
 static GtkCssValue *
+parse_pango_style (GtkCssStyleProperty *property,
+                   GtkCssParser        *parser,
+                   GFile               *base)
+{
+  int value;
+
+  if (!_gtk_css_parser_try_enum (parser, PANGO_TYPE_STYLE, &value))
+    {
+      _gtk_css_parser_error (parser, "unknown value for property");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_enum (PANGO_TYPE_STYLE, value);
+}
+
+static GtkCssValue *
+parse_pango_weight (GtkCssStyleProperty *property,
+                    GtkCssParser        *parser,
+                    GFile               *base)
+{
+  int value;
+
+  if (!_gtk_css_parser_try_enum (parser, PANGO_TYPE_WEIGHT, &value))
+    {
+      _gtk_css_parser_error (parser, "unknown value for property");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_enum (PANGO_TYPE_WEIGHT, value);
+}
+
+static GtkCssValue *
+parse_pango_variant (GtkCssStyleProperty *property,
+                     GtkCssParser        *parser,
+                     GFile               *base)
+{
+  int value;
+
+  if (!_gtk_css_parser_try_enum (parser, PANGO_TYPE_VARIANT, &value))
+    {
+      _gtk_css_parser_error (parser, "unknown value for property");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_enum (PANGO_TYPE_VARIANT, value);
+}
+
+static GtkCssValue *
+parse_border_style (GtkCssStyleProperty *property,
+                    GtkCssParser        *parser,
+                    GFile               *base)
+{
+  int value;
+
+  if (!_gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &value))
+    {
+      _gtk_css_parser_error (parser, "unknown value for property");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_enum (GTK_TYPE_BORDER_STYLE, value);
+}
+
+static GtkCssValue *
+parse_css_area (GtkCssStyleProperty *property,
+                GtkCssParser        *parser,
+                GFile               *base)
+{
+  int value;
+
+  if (!_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_AREA, &value))
+    {
+      _gtk_css_parser_error (parser, "unknown value for property");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, value);
+}
+
+static GtkCssValue *
 bindings_value_parse (GtkCssStyleProperty *property,
                       GtkCssParser        *parser,
                       GFile               *base)
@@ -933,7 +1013,7 @@ _gtk_css_style_property_init_properties (void)
                                           PANGO_TYPE_STYLE,
                                           PANGO_TYPE_STYLE,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          NULL,
+                                          parse_pango_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -944,7 +1024,7 @@ _gtk_css_style_property_init_properties (void)
                                           PANGO_TYPE_VARIANT,
                                           PANGO_TYPE_VARIANT,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          NULL,
+                                          parse_pango_variant,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -956,7 +1036,7 @@ _gtk_css_style_property_init_properties (void)
                                           PANGO_TYPE_WEIGHT,
                                           PANGO_TYPE_WEIGHT,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          NULL,
+                                          parse_pango_weight,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1085,7 +1165,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1105,7 +1185,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1125,7 +1205,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1145,7 +1225,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1207,7 +1287,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1238,7 +1318,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_CSS_AREA,
                                           GTK_TYPE_CSS_AREA,
                                           0,
-                                          NULL,
+                                          parse_css_area,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1248,7 +1328,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_CSS_AREA,
                                           GTK_TYPE_CSS_AREA,
                                           0,
-                                          NULL,
+                                          parse_css_area,
                                           NULL,
                                           NULL,
                                           NULL,



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