[gtk+/wip/cssvalue: 74/164] cssvalue: Add a custom RGBA value



commit cd9cbb4a7236e5ff7167a1282c8f44900f671d71
Author: Benjamin Otte <otte redhat com>
Date:   Wed Mar 28 06:28:13 2012 +0200

    cssvalue: Add a custom RGBA value
    
    Note: custom CSS properties still use the default GtkCssValue and always
    will.
    So there is a difference in css values used between those, even though
    they both carry a GdkRGBA payload.

 gtk/Makefile.am               |    2 +
 gtk/gtkcssrgbavalue.c         |  121 +++++++++++++++++++++++++++++++++++++++++
 gtk/gtkcssrgbavalueprivate.h  |   42 ++++++++++++++
 gtk/gtkcssstylefuncs.c        |   16 +++---
 gtk/gtkcssstylepropertyimpl.c |   99 +++++++++++++++++-----------------
 gtk/gtkcssvalue.c             |   23 ++------
 gtk/gtkcssvalueprivate.h      |    2 -
 gtk/gtkstylecontext.c         |    3 +-
 gtk/gtksymboliccolor.c        |   27 +++++-----
 gtk/gtkthemingengine.c        |    3 +-
 10 files changed, 244 insertions(+), 94 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 8797fc3..c2d7685 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -438,6 +438,7 @@ gtk_private_h_sources =		\
 	gtkcssnumbervalueprivate.h	\
 	gtkcssparserprivate.h	\
 	gtkcssproviderprivate.h	\
+	gtkcssrgbavalueprivate.h	\
 	gtkcsssectionprivate.h 	\
 	gtkcssselectorprivate.h	\
 	gtkcssshadowvalueprivate.h      \
@@ -639,6 +640,7 @@ gtk_base_c_sources = 		\
 	gtkcssnumbervalue.c	\
 	gtkcssparser.c		\
 	gtkcssprovider.c	\
+	gtkcssrgbavalue.c	\
 	gtkcsssection.c 	\
 	gtkcssselector.c	\
 	gtkcssshadowvalue.c	\
diff --git a/gtk/gtkcssrgbavalue.c b/gtk/gtkcssrgbavalue.c
new file mode 100644
index 0000000..f11f8b7
--- /dev/null
+++ b/gtk/gtkcssrgbavalue.c
@@ -0,0 +1,121 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkcssrgbavalueprivate.h"
+
+#include "gtkstylecontextprivate.h"
+#include "gtksymboliccolorprivate.h"
+
+struct _GtkCssValue {
+  GTK_CSS_VALUE_BASE
+  GdkRGBA rgba;
+};
+
+static void
+gtk_css_value_rgba_free (GtkCssValue *value)
+{
+  g_slice_free (GtkCssValue, value);
+}
+
+static gboolean
+gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
+                          const GtkCssValue *rgba2)
+{
+  return gdk_rgba_equal (&rgba1->rgba, &rgba2->rgba);
+}
+
+static void
+gtk_css_value_rgba_print (const GtkCssValue *rgba,
+                          GString           *string)
+{
+  char *s = gdk_rgba_to_string (&rgba->rgba);
+  g_string_append (string, s);
+  g_free (s);
+}
+
+static const GtkCssValueClass GTK_CSS_VALUE_RGBA = {
+  gtk_css_value_rgba_free,
+  gtk_css_value_rgba_equal,
+  gtk_css_value_rgba_print
+};
+
+GtkCssValue *
+_gtk_css_rgba_value_new_from_rgba (const GdkRGBA *rgba)
+{
+  GtkCssValue *value;
+
+  g_return_val_if_fail (rgba != NULL, NULL);
+
+  value = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_RGBA);
+  value->rgba = *rgba;
+
+  return value;
+}
+
+const GdkRGBA *
+_gtk_css_rgba_value_get_rgba (const GtkCssValue *rgba)
+{
+  g_return_val_if_fail (rgba->class == &GTK_CSS_VALUE_RGBA, NULL);
+
+  return &rgba->rgba;
+}
+
+GtkCssValue *
+_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue     *rgba,
+                                           GtkCssValue     *fallback,
+                                           GtkStyleContext *context,
+                                           gboolean         for_color_property)
+{
+  GtkSymbolicColor *symbolic;
+  GtkCssValue *resolved;
+
+  g_return_val_if_fail (rgba != NULL, NULL);
+
+  symbolic = _gtk_css_value_get_symbolic_color (rgba);
+
+  if (symbolic == _gtk_symbolic_color_get_current_color ())
+    {
+      /* The computed value of the âcurrentColorâ keyword is the computed
+       * value of the âcolorâ property. If the âcurrentColorâ keyword is
+       * set on the âcolorâ property itself, it is treated as âcolor: inheritâ. 
+       */
+      if (for_color_property)
+        {
+          GtkStyleContext *parent = gtk_style_context_get_parent (context);
+
+          if (parent)
+            return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color"));
+          else
+            return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, TRUE);
+        }
+      else
+        {
+          return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
+        }
+    }
+  
+  resolved = _gtk_style_context_resolve_color_value (context, symbolic);
+
+  if (resolved == NULL)
+    return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, for_color_property);
+
+  g_assert (resolved->class == &GTK_CSS_VALUE_RGBA);
+  return resolved;
+}
+
diff --git a/gtk/gtkcssrgbavalueprivate.h b/gtk/gtkcssrgbavalueprivate.h
new file mode 100644
index 0000000..d35846d
--- /dev/null
+++ b/gtk/gtkcssrgbavalueprivate.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright  2012 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Alexander Larsson <alexl gnome org>
+ */
+
+#ifndef __GTK_CSS_RGBA_VALUE_PRIVATE_H__
+#define __GTK_CSS_RGBA_VALUE_PRIVATE_H__
+
+#include "gtkcssparserprivate.h"
+#include "gtkcsstypesprivate.h"
+#include "gtkcssvalueprivate.h"
+
+G_BEGIN_DECLS
+
+GtkCssValue *   _gtk_css_rgba_value_new_from_rgba (const GdkRGBA          *rgba);
+
+GtkCssValue *   _gtk_css_rgba_value_compute_from_symbolic
+                                                  (GtkCssValue            *rgba,
+                                                   GtkCssValue            *fallback,
+                                                   GtkStyleContext        *context,
+                                                   gboolean                for_color_property);
+
+const GdkRGBA * _gtk_css_rgba_value_get_rgba      (const GtkCssValue      *rgba);
+
+
+G_END_DECLS
+
+#endif /* __GTK_CSS_RGBA_VALUE_PRIVATE_H__ */
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c
index 727c788..eaade29 100644
--- a/gtk/gtkcssstylefuncs.c
+++ b/gtk/gtkcssstylefuncs.c
@@ -30,6 +30,7 @@
 #include "gtkanimationdescription.h"
 #include "gtkcssimagegradientprivate.h"
 #include "gtkcssprovider.h"
+#include "gtkcssrgbavalueprivate.h"
 #include "gtkcsstypesprivate.h"
 #include "gtkgradient.h"
 #include "gtkprivatetypebuiltins.h"
@@ -213,24 +214,21 @@ rgba_value_print (const GValue *value,
 
 static GtkCssValue *
 rgba_value_compute (GtkStyleContext *context,
-                    GtkCssValue    *specified)
+                    GtkCssValue     *specified)
 {
   GdkRGBA white = { 1, 1, 1, 1 };
-  GtkCssValue *res;
   
   if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
     {
       GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified);
+      GdkRGBA rgba;
 
       if (symbolic == _gtk_symbolic_color_get_current_color ())
-        return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
-      else {
-	res = _gtk_style_context_resolve_color_value (context, symbolic);
-	if (res != NULL)
-	  return res;
+        rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, "color"));
+      else if (!gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
+        rgba = white;
 
-	return _gtk_css_value_new_from_rgba (&white);
-      }
+      return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba);
     }
   else
     return _gtk_css_value_ref (specified);
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 4be8573..2d277a7 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -44,7 +44,7 @@
 #include "gtkcssimageprivate.h"
 #include "gtkcssimageprivate.h"
 #include "gtkcssnumbervalueprivate.h"
-#include "gtkgradient.h"
+#include "gtkcssrgbavalueprivate.h"
 #include "gtkcssshadowvalueprivate.h"
 #include "gtksymboliccolorprivate.h"
 #include "gtkthemingengine.h"
@@ -190,42 +190,41 @@ color_compute (GtkCssStyleProperty    *property,
                GtkStyleContext        *context,
                GtkCssValue            *specified)
 {
-  GtkSymbolicColor *symbolic = _gtk_css_value_get_symbolic_color (specified);
-  GtkCssValue *resolved;
+  return _gtk_css_rgba_value_compute_from_symbolic (specified,
+                                                    _gtk_css_style_property_get_initial_value (property),
+                                                    context,
+                                                    FALSE);
+}
 
-  if (symbolic == _gtk_symbolic_color_get_current_color ())
-    {
-      /* The computed value of the âcurrentColorâ keyword is the computed
-       * value of the âcolorâ property. If the âcurrentColorâ keyword is
-       * set on the âcolorâ property itself, it is treated as âcolor: inheritâ. 
-       */
-      if (g_str_equal (_gtk_style_property_get_name (GTK_STYLE_PROPERTY (property)), "color"))
-        {
-          GtkStyleContext *parent = gtk_style_context_get_parent (context);
+static GtkCssValue *
+color_property_compute (GtkCssStyleProperty    *property,
+                        GtkStyleContext        *context,
+                        GtkCssValue            *specified)
+{
+  GtkCssValue *value;
+
+  value = _gtk_css_rgba_value_compute_from_symbolic (specified,
+                                                    _gtk_css_style_property_get_initial_value (property),
+                                                    context,
+                                                    TRUE);
+  _gtk_css_rgba_value_get_rgba (value);
+  return value;
+}
 
-          if (parent)
-            return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color"));
-          else
-            return _gtk_css_style_compute_value (context,
-						 GDK_TYPE_RGBA,
-						 _gtk_css_style_property_get_initial_value (property));
-        }
-      else
-        {
-          return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
-        }
-    }
-  else if ((resolved = _gtk_style_context_resolve_color_value (context,
-							       symbolic)) != NULL)
-    {
-      return resolved;
-    }
-  else
-    {
-      return color_compute (property,
-			    context,
-			    _gtk_css_style_property_get_initial_value (property));
-    }
+static void
+color_query (GtkCssStyleProperty *property,
+             const GtkCssValue   *css_value,
+             GValue              *value)
+{
+  g_value_init (value, GDK_TYPE_RGBA);
+  g_value_set_boxed (value, _gtk_css_rgba_value_get_rgba (css_value));
+}
+
+static GtkCssValue *
+color_assign (GtkCssStyleProperty *property,
+              const GValue        *value)
+{
+  return _gtk_css_rgba_value_new_from_rgba (g_value_get_boxed (value));
 }
 
 static GtkCssValue *
@@ -1162,9 +1161,9 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           color_parse,
                                           NULL,
-                                          color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_property_compute,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_new_rgba (1, 1, 1, 1)));
@@ -1187,8 +1186,8 @@ _gtk_css_style_property_init_properties (void)
                                           color_parse,
                                           NULL,
                                           color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_new_rgba (0, 0, 0, 0)));
@@ -1554,8 +1553,8 @@ _gtk_css_style_property_init_properties (void)
                                           color_parse,
                                           NULL,
                                           color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_ref (
@@ -1566,8 +1565,8 @@ _gtk_css_style_property_init_properties (void)
                                           color_parse,
                                           NULL,
                                           color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_ref (
@@ -1578,8 +1577,8 @@ _gtk_css_style_property_init_properties (void)
                                           color_parse,
                                           NULL,
                                           color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_ref (
@@ -1590,8 +1589,8 @@ _gtk_css_style_property_init_properties (void)
                                           color_parse,
                                           NULL,
                                           color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_ref (
@@ -1602,8 +1601,8 @@ _gtk_css_style_property_init_properties (void)
                                           color_parse,
                                           NULL,
                                           color_compute,
-                                          query_simple,
-                                          assign_simple,
+                                          color_query,
+                                          color_assign,
                                           NULL,
                                           _gtk_css_value_new_take_symbolic_color (
                                             gtk_symbolic_color_ref (
diff --git a/gtk/gtkcssvalue.c b/gtk/gtkcssvalue.c
index 50a249e..99879a8 100644
--- a/gtk/gtkcssvalue.c
+++ b/gtk/gtkcssvalue.c
@@ -303,17 +303,6 @@ _gtk_css_value_new_take_binding_sets (GPtrArray *array)
 }
 
 GtkCssValue *
-_gtk_css_value_new_from_rgba (const GdkRGBA *v)
-{
-  GtkCssValue *value;
-
-  value = gtk_css_value_new (GDK_TYPE_RGBA);
-  value->u.ptr = g_boxed_copy0 (GDK_TYPE_RGBA, v);
-
-  return value;
-}
-
-GtkCssValue *
 _gtk_css_value_new_from_color (const GdkColor *v)
 {
   GtkCssValue *value;
@@ -452,12 +441,16 @@ _gtk_css_value_print (const GtkCssValue *value,
 GType
 _gtk_css_value_get_content_type (const GtkCssValue *value)
 {
+  g_return_val_if_fail (value->class == &GTK_CSS_VALUE_DEFAULT, G_TYPE_NONE);
+
   return value->type;
 }
 
 gboolean
 _gtk_css_value_holds (const GtkCssValue *value, GType type)
 {
+  g_return_val_if_fail (value->class == &GTK_CSS_VALUE_DEFAULT, FALSE);
+
   return g_type_is_a (value->type, type);
 }
 
@@ -499,6 +492,7 @@ _gtk_css_value_init_gvalue (const GtkCssValue *value,
 {
   if (value != NULL)
     {
+      g_return_if_fail (value->class == &GTK_CSS_VALUE_DEFAULT);
       g_value_init (g_value, value->type);
       fill_gvalue (value, g_value);
     }
@@ -632,13 +626,6 @@ _gtk_css_value_get_pango_weight (const GtkCssValue *value)
   return value->u.gint;
 }
 
-const GdkRGBA *
-_gtk_css_value_get_rgba (const GtkCssValue *value)
-{
-  g_return_val_if_fail (_gtk_css_value_holds (value, GDK_TYPE_RGBA), NULL);
-  return value->u.ptr;
-}
-
 GtkGradient *
 _gtk_css_value_get_gradient (const GtkCssValue *value)
 {
diff --git a/gtk/gtkcssvalueprivate.h b/gtk/gtkcssvalueprivate.h
index d99dfd1..3bedaf4 100644
--- a/gtk/gtkcssvalueprivate.h
+++ b/gtk/gtkcssvalueprivate.h
@@ -81,7 +81,6 @@ GtkCssValue *_gtk_css_value_new_take_string           (char
 GtkCssValue *_gtk_css_value_new_take_strv             (char                      **strv);
 GtkCssValue *_gtk_css_value_new_from_boxed            (GType                       type,
                                                        gpointer                    boxed);
-GtkCssValue *_gtk_css_value_new_from_rgba             (const GdkRGBA              *v);
 GtkCssValue *_gtk_css_value_new_from_color            (const GdkColor             *v);
 GtkCssValue *_gtk_css_value_new_take_symbolic_color   (GtkSymbolicColor           *v);
 GtkCssValue *_gtk_css_value_new_take_pattern          (cairo_pattern_t            *v);
@@ -114,7 +113,6 @@ const GtkCssBorderImageRepeat  *_gtk_css_value_get_border_image_repeat    (const
 PangoStyle                      _gtk_css_value_get_pango_style            (const GtkCssValue *value);
 PangoVariant                    _gtk_css_value_get_pango_variant          (const GtkCssValue *value);
 PangoWeight                     _gtk_css_value_get_pango_weight           (const GtkCssValue *value);
-const GdkRGBA                  *_gtk_css_value_get_rgba                   (const GtkCssValue *value);
 GtkGradient                    *_gtk_css_value_get_gradient               (const GtkCssValue *value);
 
 G_END_DECLS
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index cab170d..513d41f 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -23,6 +23,7 @@
 #include <gobject/gvaluecollector.h>
 
 #include "gtkstylecontextprivate.h"
+#include "gtkcssrgbavalueprivate.h"
 #include "gtkstylepropertiesprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkthemingengineprivate.h"
@@ -2786,7 +2787,7 @@ _gtk_style_context_resolve_color (GtkStyleContext  *context,
   if (val == NULL)
     return FALSE;
 
-  *result = *_gtk_css_value_get_rgba (val);
+  *result = *_gtk_css_rgba_value_get_rgba (val);
   _gtk_css_value_unref (val);
   return TRUE;
 }
diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c
index b96a234..26ec26a 100644
--- a/gtk/gtksymboliccolor.c
+++ b/gtk/gtksymboliccolor.c
@@ -16,6 +16,7 @@
  */
 
 #include "config.h"
+#include "gtkcssrgbavalueprivate.h"
 #include "gtksymboliccolorprivate.h"
 #include "gtkstyleproperties.h"
 #include "gtkintl.h"
@@ -104,7 +105,7 @@ gtk_symbolic_color_new_literal (const GdkRGBA *color)
 
   symbolic_color = g_slice_new0 (GtkSymbolicColor);
   symbolic_color->type = COLOR_TYPE_LITERAL;
-  symbolic_color->last_value = _gtk_css_value_new_from_rgba (color);
+  symbolic_color->last_value = _gtk_css_rgba_value_new_from_rgba (color);
   symbolic_color->ref_count = 1;
 
   return symbolic_color;
@@ -576,7 +577,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor   *color,
   if (v == NULL)
     return FALSE;
 
-  *resolved_color = *_gtk_css_value_get_rgba (v);
+  *resolved_color = *_gtk_css_rgba_value_get_rgba (v);
   _gtk_css_value_unref (v);
   return TRUE;
 }
@@ -618,12 +619,12 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
 	if (val == NULL)
 	  return NULL;
 
-	shade = *_gtk_css_value_get_rgba (val);
+	shade = *_gtk_css_rgba_value_get_rgba (val);
 	_shade_color (&shade, color->shade.factor);
 
 	_gtk_css_value_unref (val);
 
-	value = _gtk_css_value_new_from_rgba (&shade);
+	value = _gtk_css_rgba_value_new_from_rgba (&shade);
       }
 
       break;
@@ -636,12 +637,12 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
 	if (val == NULL)
 	  return NULL;
 
-	alpha = *_gtk_css_value_get_rgba (val);
+	alpha = *_gtk_css_rgba_value_get_rgba (val);
 	alpha.alpha = CLAMP (alpha.alpha * color->alpha.factor, 0, 1);
 
 	_gtk_css_value_unref (val);
 
-	value = _gtk_css_value_new_from_rgba (&alpha);
+	value = _gtk_css_rgba_value_new_from_rgba (&alpha);
       }
       break;
 
@@ -653,13 +654,13 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
 	val = _gtk_symbolic_color_resolve_full (color->mix.color1, func, data);
 	if (val == NULL)
 	  return NULL;
-	color1 = *_gtk_css_value_get_rgba (val);
+	color1 = *_gtk_css_rgba_value_get_rgba (val);
 	_gtk_css_value_unref (val);
 
 	val = _gtk_symbolic_color_resolve_full (color->mix.color2, func, data);
 	if (val == NULL)
 	  return NULL;
-	color2 = *_gtk_css_value_get_rgba (val);
+	color2 = *_gtk_css_rgba_value_get_rgba (val);
 	_gtk_css_value_unref (val);
 
 
@@ -668,7 +669,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
 	res.blue = CLAMP (color1.blue + ((color2.blue - color1.blue) * color->mix.factor), 0, 1);
 	res.alpha = CLAMP (color1.alpha + ((color2.alpha - color1.alpha) * color->mix.factor), 0, 1);
 
-	value =_gtk_css_value_new_from_rgba (&res);
+	value =_gtk_css_rgba_value_new_from_rgba (&res);
       }
 
       break;
@@ -681,7 +682,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
 					     &res))
 	  return NULL;
 
-	value = _gtk_css_value_new_from_rgba (&res);
+	value = _gtk_css_rgba_value_new_from_rgba (&res);
       }
 
       break;
@@ -695,8 +696,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
   if (value != NULL)
     {
       if (color->last_value != NULL &&
-	  gdk_rgba_equal (_gtk_css_value_get_rgba (color->last_value),
-			  _gtk_css_value_get_rgba (value)))
+          _gtk_css_value_equal (color->last_value, value))
 	{
 	  _gtk_css_value_unref (value);
 	  value = _gtk_css_value_ref (color->last_value);
@@ -709,6 +709,7 @@ _gtk_symbolic_color_resolve_full (GtkSymbolicColor           *color,
 	}
     }
 
+  _gtk_css_rgba_value_get_rgba (value);
   return value;
 }
 
@@ -734,7 +735,7 @@ gtk_symbolic_color_to_string (GtkSymbolicColor *color)
   switch (color->type)
     {
     case COLOR_TYPE_LITERAL:
-      s = gdk_rgba_to_string (_gtk_css_value_get_rgba (color->last_value));
+      s = gdk_rgba_to_string (_gtk_css_rgba_value_get_rgba (color->last_value));
       break;
     case COLOR_TYPE_NAME:
       s = g_strconcat ("@", color->name, NULL);
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 8872dd1..4747f9d 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -28,6 +28,7 @@
 #include "gtkmodulesprivate.h"
 #include "gtkborderimageprivate.h"
 #include "gtkpango.h"
+#include "gtkcssrgbavalueprivate.h"
 #include "gtkcssshadowvalueprivate.h"
 #include "gtkcsstypesprivate.h"
 #include "gtkthemingengineprivate.h"
@@ -1828,7 +1829,7 @@ render_frame_internal (GtkThemingEngine *engine,
       border_style[1] = border_style[2] = border_style[3] = border_style[0];
       border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-width"));
       border.left = border.right = border.bottom = border.top;
-      colors[0] = *_gtk_css_value_get_rgba (_gtk_theming_engine_peek_property (engine, "outline-color"));
+      colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, "outline-color"));
       colors[3] = colors[2] = colors[1] = colors[0];
       offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-offset"));
       



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