[gtk+/wip/cssvalue: 58/141] stylepropertyimpl: Add remaining parse functions



commit 208f65583a9806b4330295d78e2096994f1b2dff
Author: Benjamin Otte <otte redhat com>
Date:   Tue Mar 27 09:05:47 2012 +0200

    stylepropertyimpl: Add remaining parse functions

 gtk/gtkcssstylepropertyimpl.c |  162 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 155 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 22388b3..a4cb42e 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -604,6 +604,154 @@ css_image_value_compute (GtkCssStyleProperty    *property,
 }
 
 static GtkCssValue *
+font_size_parse (GtkCssStyleProperty *property,
+                 GtkCssParser        *parser,
+                 GFile               *base)
+{
+  gdouble d;
+
+  if (!_gtk_css_parser_try_double (parser, &d))
+    {
+      _gtk_css_parser_error (parser, "Expected a number");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_double (d);
+}
+
+static GtkCssValue *
+outline_parse (GtkCssStyleProperty *property,
+               GtkCssParser        *parser,
+               GFile               *base)
+{
+  int i;
+
+  if (!_gtk_css_parser_try_int (parser, &i))
+    {
+      _gtk_css_parser_error (parser, "Expected an integer");
+      return NULL;
+    }
+
+  return _gtk_css_value_new_from_int (i);
+}
+
+static GtkCssValue *
+border_image_repeat_parse (GtkCssStyleProperty *property,
+                           GtkCssParser        *parser,
+                           GFile               *base)
+{
+  GValue value = G_VALUE_INIT;
+  GtkCssValue *result;
+
+  g_value_init (&value, GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
+  if (!_gtk_css_style_parse_value (&value, parser, base))
+    {
+      g_value_unset (&value);
+      return NULL;
+    }
+
+  result = _gtk_css_value_new_from_gvalue (&value);
+  g_value_unset (&value);
+
+  return result;
+}
+
+static GtkCssValue *
+border_image_slice_parse (GtkCssStyleProperty *property,
+                          GtkCssParser        *parser,
+                          GFile               *base)
+{
+  GValue value = G_VALUE_INIT;
+  GtkCssValue *result;
+
+  g_value_init (&value, GTK_TYPE_BORDER);
+  if (!_gtk_css_style_parse_value (&value, parser, base))
+    {
+      g_value_unset (&value);
+      return NULL;
+    }
+
+  result = _gtk_css_value_new_from_gvalue (&value);
+  g_value_unset (&value);
+
+  return result;
+}
+
+static GtkCssValue *
+border_image_width_parse (GtkCssStyleProperty *property,
+                          GtkCssParser        *parser,
+                          GFile               *base)
+{
+  GValue value = G_VALUE_INIT;
+  GtkCssValue *result;
+
+  g_value_init (&value, GTK_TYPE_BORDER);
+  if (!_gtk_css_style_parse_value (&value, parser, base))
+    {
+      g_value_unset (&value);
+      return NULL;
+    }
+
+  result = _gtk_css_value_new_from_gvalue (&value);
+  g_value_unset (&value);
+
+  return result;
+}
+
+static GtkCssValue *
+engine_parse (GtkCssStyleProperty *property,
+              GtkCssParser        *parser,
+              GFile               *base)
+{
+  GtkThemingEngine *engine;
+  char *str;
+
+  if (_gtk_css_parser_try (parser, "none", TRUE))
+    return _gtk_css_value_new_from_theming_engine (gtk_theming_engine_load (NULL));
+
+  str = _gtk_css_parser_try_ident (parser, TRUE);
+  if (str == NULL)
+    {
+      _gtk_css_parser_error (parser, "Expected a valid theme name");
+      return NULL;
+    }
+
+  engine = gtk_theming_engine_load (str);
+
+  if (engine == NULL)
+    {
+      _gtk_css_parser_error (parser, "Theming engine '%s' not found", str);
+      g_free (str);
+      return NULL;
+    }
+
+  g_free (str);
+
+  return _gtk_css_value_new_from_theming_engine (engine);
+}
+
+static GtkCssValue *
+transition_parse (GtkCssStyleProperty *property,
+                  GtkCssParser        *parser,
+                  GFile               *base)
+{
+  GValue value = G_VALUE_INIT;
+  GtkCssValue *result;
+
+  g_value_init (&value, GTK_TYPE_ANIMATION_DESCRIPTION);
+  if (!_gtk_css_style_parse_value (&value, parser, base))
+    {
+      g_value_unset (&value);
+      return NULL;
+    }
+
+  result = _gtk_css_value_new_from_gvalue (&value);
+  g_value_unset (&value);
+
+  return result;
+}
+
+static GtkCssValue *
 parse_margin (GtkCssStyleProperty *property,
               GtkCssParser        *parser,
               GFile               *base)
@@ -1084,7 +1232,7 @@ _gtk_css_style_property_init_properties (void)
                                           G_TYPE_DOUBLE,
                                           G_TYPE_DOUBLE,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          NULL,
+                                          font_size_parse,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1413,7 +1561,7 @@ _gtk_css_style_property_init_properties (void)
                                           G_TYPE_INT,
                                           G_TYPE_INT,
                                           0,
-                                          NULL,
+                                          outline_parse,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1559,7 +1707,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
                                           GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
                                           0,
-                                          NULL,
+                                          border_image_repeat_parse,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1571,7 +1719,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER,
                                           GTK_TYPE_BORDER,
                                           0,
-                                          NULL,
+                                          border_image_slice_parse,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1581,7 +1729,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_BORDER,
                                           GTK_TYPE_BORDER,
                                           0,
-                                          NULL,
+                                          border_image_width_parse,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1591,7 +1739,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_THEMING_ENGINE,
                                           GTK_TYPE_THEMING_ENGINE,
                                           0,
-                                          NULL,
+                                          engine_parse,
                                           NULL,
                                           NULL,
                                           NULL,
@@ -1601,7 +1749,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_TYPE_ANIMATION_DESCRIPTION,
                                           GTK_TYPE_ANIMATION_DESCRIPTION,
                                           0,
-                                          NULL,
+                                          transition_parse,
                                           NULL,
                                           NULL,
                                           NULL,



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