]> Pileus Git - ~andy/gtk/commitdiff
stylepropertyimpl: Add color parsing function
authorBenjamin Otte <otte@redhat.com>
Tue, 27 Mar 2012 03:11:58 +0000 (05:11 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Apr 2012 06:59:12 +0000 (08:59 +0200)
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

index b78eb244892942aabfa403596d1c36b4c09faea5..7315b9d90ed2473e1a2adc09d329b0bd67444c35 100644 (file)
@@ -127,6 +127,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,
@@ -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,