[gtk+/wip/cssvalue: 54/164] stylepropertyimpl: Add color parsing function



commit 1f3b0a3a9f13c4e95549c28bd79ab9e507b21317
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 b78eb24..7315b9d 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)
@@ -866,7 +887,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,
@@ -890,7 +911,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1258,7 +1279,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1270,7 +1291,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1282,7 +1303,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1294,7 +1315,7 @@ _gtk_css_style_property_init_properties (void)
                                           GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
-                                          NULL,
+                                          color_parse,
                                           NULL,
                                           color_compute,
                                           NULL,
@@ -1306,7 +1327,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]