diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index a74a992ccb..61443323be 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -21,7 +21,9 @@ #include "gtkcssshadowvalueprivate.h" +#include "gtkcssrgbavalueprivate.h" #include "gtkstylecontextprivate.h" +#include "gtksymboliccolorprivate.h" #include "gtkthemingengineprivate.h" #include "gtkpango.h" @@ -34,15 +36,13 @@ struct _GtkCssValue { gint16 radius; gint16 spread; - GdkRGBA color; - GtkSymbolicColor *symbolic_color; + GtkCssValue *color; }; static void gtk_css_value_shadow_free (GtkCssValue *shadow) { - if (shadow->symbolic_color != NULL) - gtk_symbolic_color_unref (shadow->symbolic_color); + _gtk_css_value_unref (shadow->color); g_slice_free (GtkCssValue, shadow); } @@ -67,8 +67,6 @@ static void gtk_css_value_shadow_print (const GtkCssValue *shadow, GString *string) { - gchar *color_str; - if (shadow->inset) g_string_append (string, "inset "); @@ -82,13 +80,7 @@ gtk_css_value_shadow_print (const GtkCssValue *shadow, if (shadow->spread != 0) g_string_append_printf (string, "%d ", (gint) shadow->spread); - if (shadow->symbolic_color != NULL) - color_str = gtk_symbolic_color_to_string (shadow->symbolic_color); - else - color_str = gdk_rgba_to_string (&shadow->color); - - g_string_append (string, color_str); - g_free (color_str); + _gtk_css_value_print (shadow->color, string); } static const GtkCssValueClass GTK_CSS_VALUE_SHADOW = { @@ -104,8 +96,7 @@ gtk_css_shadow_value_new (gdouble hoffset, gdouble radius, gdouble spread, gboolean inset, - GdkRGBA *color, - GtkSymbolicColor *symbolic_color) + GtkCssValue *color) { GtkCssValue *retval; @@ -116,11 +107,7 @@ gtk_css_shadow_value_new (gdouble hoffset, retval->radius = radius; retval->spread = spread; retval->inset = inset; - - retval->symbolic_color = symbolic_color; - - if (color != NULL) - retval->color = *color; + retval->color = color; return retval; } @@ -183,28 +170,32 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser) if (!have_color || !have_lengths) { _gtk_css_parser_error (parser, "Must specify at least color and offsets"); + if (have_color) + gtk_symbolic_color_unref (color); return NULL; } return gtk_css_shadow_value_new (hoffset, voffset, blur, spread, have_inset, - NULL, color); + _gtk_css_value_new_take_symbolic_color (color)); } GtkCssValue * _gtk_css_shadow_value_compute (GtkCssValue *shadow, GtkStyleContext *context) { - GdkRGBA color; + GtkCssValue *color; - if (!_gtk_style_context_resolve_color (context, - shadow->symbolic_color, - &color)) - color.red = color.blue = color.green = color.alpha = 0; + color = _gtk_css_rgba_value_compute_from_symbolic (shadow->color, + _gtk_css_value_new_take_symbolic_color ( + gtk_symbolic_color_ref ( + _gtk_symbolic_color_get_current_color ())), + context, + FALSE); return gtk_css_shadow_value_new (shadow->hoffset, shadow->voffset, shadow->radius, shadow->spread, shadow->inset, - &color, NULL); + color); } void @@ -220,7 +211,7 @@ _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow, cairo_save (cr); cairo_rel_move_to (cr, shadow->hoffset, shadow->voffset); - gdk_cairo_set_source_rgba (cr, &shadow->color); + gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color)); _gtk_pango_fill_layout (cr, layout); cairo_rel_move_to (cr, -shadow->hoffset, -shadow->voffset); @@ -237,7 +228,7 @@ _gtk_css_shadow_value_paint_icon (const GtkCssValue *shadow, cairo_save (cr); pattern = cairo_pattern_reference (cairo_get_source (cr)); - gdk_cairo_set_source_rgba (cr, &shadow->color); + gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color)); cairo_translate (cr, shadow->hoffset, shadow->voffset); cairo_mask (cr, pattern); @@ -259,7 +250,7 @@ _gtk_css_shadow_value_paint_spinner (const GtkCssValue *shadow, cairo_translate (cr, shadow->hoffset, shadow->voffset); _gtk_theming_engine_paint_spinner (cr, radius, progress, - &shadow->color); + _gtk_css_rgba_value_get_rgba (shadow->color)); cairo_restore (cr); } @@ -288,7 +279,7 @@ _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow, _gtk_rounded_box_path (&box, cr); _gtk_rounded_box_clip_path (padding_box, cr); - gdk_cairo_set_source_rgba (cr, &shadow->color); + gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color)); cairo_fill (cr); cairo_restore (cr);