[gtk+/wip/cssvalue: 182/218] stylepropertyimpl: Add color parsing function



commit 4f2697d9cf87b2fb887231f8d8027cf3326fdf0e
Author: Benjamin Otte <otte redhat com>
Date:   Tue Mar 27 05:11:58 2012 +0200

    stylepropertyimpl: Add color parsing function
    
    This is in preparation for removing the specified type and computed type
    properties from GtkCssStyleProperty, which is in preparation for really
    using GtkCssValue classes and not GTypes.

 gtk/gtkcssstylepropertyimpl.c |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index f28f42f..a0547ff 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -128,6 +128,27 @@ string_append_string (GString    *str,
 /*** IMPLEMENTATIONS ***/
 
 static GtkCssValue *
+color_parse (GtkCssStyleProperty *property,
+             GtkCssParser        *parser,
+             GFile               *base)
+{
+  GtkSymbolicColor *symbolic;
+
+  if (_gtk_css_parser_try (parser, "currentcolor", TRUE))
+    {
+      symbolic = gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
+    }
+  else
+    {
+      symbolic = _gtk_css_parser_read_symbolic_color (parser);
+      if (symbolic == NULL)
+        return NULL;
+    }
+
+  return _gtk_css_value_new_take_symbolic_color (symbolic);
+}
+
+static GtkCssValue *
 color_compute (GtkCssStyleProperty    *property,
                GtkStyleContext        *context,
                GtkCssValue            *specified)
@@ -856,7 +877,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -880,7 +901,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1248,7 +1269,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1260,7 +1281,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1272,7 +1293,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1284,7 +1305,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1296,7 +1317,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,



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