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



commit b4196131e0abe73dc5fdf98962cd840085d47f79
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 a0547ff..314eef9 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)
@@ -923,7 +1003,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,
@@ -934,7 +1014,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,
@@ -946,7 +1026,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,
@@ -1075,7 +1155,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1095,7 +1175,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1115,7 +1195,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1135,7 +1215,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1197,7 +1277,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER_STYLE,
                                           GTK_TYPE_BORDER_STYLE,
                                           0,
-                                          NULL,
+                                          parse_border_style,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1228,7 +1308,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_CSS_AREA,
                                           GTK_TYPE_CSS_AREA,
                                           0,
-                                          NULL,
+                                          parse_css_area,
                                           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,



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