diff options
author | Benjamin Otte <otte@redhat.com> | 2012-04-07 07:40:36 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-17 08:59:20 +0200 |
commit | 40283e7c2793c7b46e51df520ae17d312a389618 (patch) | |
tree | 4c52decc658ec488dfc46a0ed7de70106b8b1c65 /gtk/gtkcssstylefuncs.c | |
parent | 883c871be649cb51e1ff5f907a07fd7dfa1cbaf9 (diff) | |
download | gtk+-40283e7c2793c7b46e51df520ae17d312a389618.tar.gz |
cssvalue: Split out old value handling to new typed value
... and Make this new value be a real GValue, as we don't need to save
performance for these anymore (it's just used for custom properties).
And I'd rather have code work for all values then be optimized for no
reason.
Diffstat (limited to 'gtk/gtkcssstylefuncs.c')
-rw-r--r-- | gtk/gtkcssstylefuncs.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c index dcdd25d569..7456442934 100644 --- a/gtk/gtkcssstylefuncs.c +++ b/gtk/gtkcssstylefuncs.c @@ -29,11 +29,10 @@ #include "gtkcssimagegradientprivate.h" #include "gtkcssprovider.h" -#include "gtkcssrgbavalueprivate.h" +#include "gtkcsstypedvalueprivate.h" #include "gtkcsstypesprivate.h" #include "gtkgradient.h" #include "gtkprivatetypebuiltins.h" -#include "gtkcssshadowvalueprivate.h" #include "gtkstylecontextprivate.h" #include "gtksymboliccolorprivate.h" #include "gtkthemingengine.h" @@ -209,16 +208,22 @@ rgba_value_compute (GtkStyleContext *context, GtkCssValue *specified) { GdkRGBA white = { 1, 1, 1, 1 }; + const GValue *value; + + value = _gtk_css_typed_value_get (specified); - if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR)) + if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR)) { - GtkSymbolicColor *symbolic = _gtk_css_value_get_boxed (specified); + GtkSymbolicColor *symbolic = g_value_get_boxed (value); + GValue new_value = G_VALUE_INIT; GdkRGBA rgba; if (!_gtk_style_context_resolve_color (context, symbolic, &rgba)) rgba = white; - return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba); + g_value_init (&new_value, GDK_TYPE_RGBA); + g_value_set_boxed (&new_value, &rgba); + return _gtk_css_typed_value_new_take (&new_value); } else return _gtk_css_value_ref (specified); @@ -278,11 +283,16 @@ color_value_compute (GtkStyleContext *context, { GdkRGBA rgba; GdkColor color = { 0, 65535, 65535, 65535 }; + const GValue *value; - if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR)) + value = _gtk_css_typed_value_get (specified); + + if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR)) { + GValue new_value = G_VALUE_INIT; + if (_gtk_style_context_resolve_color (context, - _gtk_css_value_get_boxed (specified), + g_value_get_boxed (value), &rgba)) { color.red = rgba.red * 65535. + 0.5; @@ -290,7 +300,9 @@ color_value_compute (GtkStyleContext *context, color.blue = rgba.blue * 65535. + 0.5; } - return _gtk_css_value_new_from_color (&color); + g_value_init (&new_value, GDK_TYPE_COLOR); + g_value_set_boxed (&new_value, &color); + return _gtk_css_typed_value_new_take (&new_value); } else return _gtk_css_value_ref (specified); @@ -821,13 +833,18 @@ static GtkCssValue * pattern_value_compute (GtkStyleContext *context, GtkCssValue *specified) { - if (_gtk_css_value_holds (specified, GTK_TYPE_GRADIENT)) + const GValue *value = _gtk_css_typed_value_get (specified); + + if (G_VALUE_HOLDS (value, GTK_TYPE_GRADIENT)) { + GValue new_value = G_VALUE_INIT; cairo_pattern_t *gradient; - gradient = gtk_gradient_resolve_for_context (_gtk_css_value_get_gradient (specified), context); + gradient = gtk_gradient_resolve_for_context (g_value_get_boxed (value), context); - return _gtk_css_value_new_take_pattern (gradient); + g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN); + g_value_take_boxed (&new_value, gradient); + return _gtk_css_typed_value_new_take (&new_value); } else return _gtk_css_value_ref (specified); |