[gtk+/wip/css: 125/167] styleproperty: Use a custom resolve function for colors
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css: 125/167] styleproperty: Use a custom resolve function for colors
- Date: Sun, 8 Jan 2012 04:53:14 +0000 (UTC)
commit c6f541baf214c50c4296380f30ccc4be1eaba122
Author: Benjamin Otte <otte redhat com>
Date: Tue Jan 3 17:59:31 2012 +0100
styleproperty: Use a custom resolve function for colors
We want to make sure to fall back to the initial value of the property
if resolving fails.
This is kinda tricky, because the initial value itself might need
resolving, too.
gtk/gtkcssstylepropertyimpl.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 053cafb..62dffe3 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -53,6 +53,9 @@ color_compute (GtkCssStyleProperty *property,
{
g_value_init (computed, GDK_TYPE_RGBA);
+ /* for when resolvage fails */
+restart:
+
if (G_VALUE_HOLDS (specified, GTK_TYPE_CSS_SPECIAL_VALUE))
{
GtkStyleContext *parent = gtk_style_context_get_parent (context);
@@ -65,8 +68,22 @@ color_compute (GtkCssStyleProperty *property,
context,
_gtk_css_style_property_get_initial_value (property));
}
+ else if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))
+ {
+ GdkRGBA rgba;
+
+ if (!_gtk_style_context_resolve_color (context,
+ g_value_get_boxed (specified),
+ &rgba))
+ {
+ specified = _gtk_css_style_property_get_initial_value (property);
+ goto restart;
+ }
+
+ g_value_set_boxed (computed, &rgba);
+ }
else
- _gtk_css_style_compute_value (computed, context, specified);
+ g_value_copy (specified, computed);
}
static void
@@ -462,7 +479,7 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
- NULL,
+ color_compute,
&rgba);
gtk_style_property_register ("font-family",
@@ -663,28 +680,28 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
- NULL,
+ color_compute,
&value);
_gtk_style_property_register ("border-right-color",
GDK_TYPE_RGBA,
0,
NULL,
NULL,
- NULL,
+ color_compute,
&value);
_gtk_style_property_register ("border-bottom-color",
GDK_TYPE_RGBA,
0,
NULL,
NULL,
- NULL,
+ color_compute,
&value);
_gtk_style_property_register ("border-left-color",
GDK_TYPE_RGBA,
0,
NULL,
NULL,
- NULL,
+ color_compute,
&value);
g_value_unset (&value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]