From 3cf6db8b1a2a4c2b120a3d37310ddd9d63118e82 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 27 Aug 2012 17:52:02 +0200 Subject: cssvalue: Handle dependencies for typed values --- gtk/gtkcssstylefuncs.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'gtk/gtkcssstylefuncs.c') diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c index 1d5d6aea89..8478ba3ec2 100644 --- a/gtk/gtkcssstylefuncs.c +++ b/gtk/gtkcssstylefuncs.c @@ -53,7 +53,8 @@ typedef gboolean (* GtkStyleParseFunc) (GtkCssParser typedef void (* GtkStylePrintFunc) (const GValue *value, GString *string); typedef GtkCssValue * (* GtkStyleComputeFunc) (GtkStyleContext *context, - GtkCssValue *specified); + GtkCssValue *specified, + GtkCssDependencies *dependencies); static void register_conversion_function (GType type, @@ -202,8 +203,9 @@ rgba_value_print (const GValue *value, } static GtkCssValue * -rgba_value_compute (GtkStyleContext *context, - GtkCssValue *specified) +rgba_value_compute (GtkStyleContext *context, + GtkCssValue *specified, + GtkCssDependencies *dependencies) { GdkRGBA white = { 1, 1, 1, 1 }; const GValue *value; @@ -216,7 +218,7 @@ rgba_value_compute (GtkStyleContext *context, GValue new_value = G_VALUE_INIT; GdkRGBA rgba; - if (!_gtk_style_context_resolve_color (context, symbolic, &rgba, NULL)) + if (!_gtk_style_context_resolve_color (context, symbolic, &rgba, dependencies)) rgba = white; g_value_init (&new_value, GDK_TYPE_RGBA); @@ -275,8 +277,9 @@ color_value_print (const GValue *value, } static GtkCssValue * -color_value_compute (GtkStyleContext *context, - GtkCssValue *specified) +color_value_compute (GtkStyleContext *context, + GtkCssValue *specified, + GtkCssDependencies *dependencies) { GdkRGBA rgba; GdkColor color = { 0, 65535, 65535, 65535 }; @@ -291,7 +294,7 @@ color_value_compute (GtkStyleContext *context, if (_gtk_style_context_resolve_color (context, g_value_get_boxed (value), &rgba, - NULL)) + dependencies)) { color.red = rgba.red * 65535. + 0.5; color.green = rgba.green * 65535. + 0.5; @@ -816,8 +819,9 @@ pattern_value_print (const GValue *value, } static GtkCssValue * -pattern_value_compute (GtkStyleContext *context, - GtkCssValue *specified) +pattern_value_compute (GtkStyleContext *context, + GtkCssValue *specified, + GtkCssDependencies *dependencies) { const GValue *value = _gtk_css_typed_value_get (specified); @@ -826,6 +830,8 @@ pattern_value_compute (GtkStyleContext *context, GValue new_value = G_VALUE_INIT; cairo_pattern_t *gradient; + *dependencies = GTK_CSS_DEPENDS_ON_EVERYTHING; + gradient = gtk_gradient_resolve_for_context (g_value_get_boxed (value), context); g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN); @@ -1081,23 +1087,29 @@ _gtk_css_style_print_value (const GValue *value, /** * _gtk_css_style_compute_value: - * @computed: (out): a value to be filled with the result * @context: the context to use for computing the value + * @target_type: Type the resulting value should have * @specified: the value to use for the computation + * @dependencies: (out): Value initialized with 0 to take the dependencies + * of the returned value * * Converts the @specified value into the @computed value using the * information in @context. The values must have matching types, ie * @specified must be a result of a call to * _gtk_css_style_parse_value() with the same type as @computed. + * + * Returns: the resulting value **/ GtkCssValue * -_gtk_css_style_compute_value (GtkStyleContext *context, - GType target_type, - GtkCssValue *specified) +_gtk_css_style_compute_value (GtkStyleContext *context, + GType target_type, + GtkCssValue *specified, + GtkCssDependencies *dependencies) { GtkStyleComputeFunc func; g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + g_return_val_if_fail (*dependencies == 0, NULL); gtk_css_style_funcs_init (); @@ -1108,7 +1120,7 @@ _gtk_css_style_compute_value (GtkStyleContext *context, GSIZE_TO_POINTER (g_type_fundamental (target_type))); if (func) - return func (context, specified); + return func (context, specified, dependencies); else return _gtk_css_value_ref (specified); } -- cgit v1.2.1