From ba7d1c21049e9f055ce5b2689efa7f8910b19413 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 13 Jun 2011 01:26:11 +0200 Subject: [PATCH] styleproperty: Make default_value() take a state Because of this, resolve() needs to take a state, too. This is so that we can have default values depend on other values (like border color). --- gtk/gtkstyleproperties.c | 6 +++--- gtk/gtkstyleproperty.c | 13 ++++++++----- gtk/gtkstylepropertyprivate.h | 3 +++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 6af179b9ec..458fcaa2fb 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -669,7 +669,7 @@ _gtk_style_properties_peek_property (GtkStyleProperties *props, if (val == NULL) return NULL; - _gtk_style_property_resolve (node, props, val); + _gtk_style_property_resolve (node, props, state, val); return val; } @@ -713,7 +713,7 @@ gtk_style_properties_get_property (GtkStyleProperties *props, else if (_gtk_style_property_is_shorthand (node)) _gtk_style_property_pack (node, props, state, value); else - _gtk_style_property_default_value (node, props, value); + _gtk_style_property_default_value (node, props, state, value); return TRUE; } @@ -767,7 +767,7 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, GValue default_value = { 0 }; g_value_init (&default_value, node->pspec->value_type); - _gtk_style_property_default_value (node, props, &default_value); + _gtk_style_property_default_value (node, props, state, &default_value); G_VALUE_LCOPY (&default_value, args, 0, &error); g_value_unset (&default_value); } diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c index e8a2114e89..2de24a997d 100644 --- a/gtk/gtkstyleproperty.c +++ b/gtk/gtkstyleproperty.c @@ -1683,6 +1683,7 @@ pack_border_radius (GValue *value, static void border_image_width_default_value (GtkStyleProperties *props, + GtkStateFlags state, GValue *value) { } @@ -1858,10 +1859,11 @@ _gtk_style_property_print_value (const GtkStyleProperty *property, void _gtk_style_property_default_value (const GtkStyleProperty *property, GtkStyleProperties *properties, + GtkStateFlags state, GValue *value) { if (property->default_value_func) - property->default_value_func (properties, value); + property->default_value_func (properties, state, value); else if (property->pspec->value_type == GTK_TYPE_THEMING_ENGINE) g_value_set_object (value, gtk_theming_engine_load (NULL)); else if (property->pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION) @@ -1970,6 +1972,7 @@ resolve_shadow (GtkStyleProperties *props, void _gtk_style_property_resolve (const GtkStyleProperty *property, GtkStyleProperties *props, + GtkStateFlags state, GValue *val) { if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) @@ -1987,12 +1990,12 @@ _gtk_style_property_resolve (const GtkStyleProperty *property, g_value_unset (val); g_value_init (val, property->pspec->value_type); - _gtk_style_property_default_value (property, props, val); + _gtk_style_property_default_value (property, props, state, val); } else if (G_VALUE_TYPE (val) == GDK_TYPE_RGBA) { if (g_value_get_boxed (val) == NULL) - _gtk_style_property_default_value (property, props, val); + _gtk_style_property_default_value (property, props, state, val); } else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT) { @@ -2002,13 +2005,13 @@ _gtk_style_property_resolve (const GtkStyleProperty *property, { g_value_unset (val); g_value_init (val, CAIRO_GOBJECT_TYPE_PATTERN); - _gtk_style_property_default_value (property, props, val); + _gtk_style_property_default_value (property, props, state, val); } } else if (G_VALUE_TYPE (val) == GTK_TYPE_SHADOW) { if (!resolve_shadow (props, val)) - _gtk_style_property_default_value (property, props, val); + _gtk_style_property_default_value (property, props, state, val); } } diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h index afa76be616..db8706843f 100644 --- a/gtk/gtkstylepropertyprivate.h +++ b/gtk/gtkstylepropertyprivate.h @@ -40,6 +40,7 @@ typedef gboolean (* GtkStyleParseFunc) (GtkCssParser typedef void (* GtkStylePrintFunc) (const GValue *value, GString *string); typedef void (* GtkStyleDefaultValueFunc) (GtkStyleProperties *props, + GtkStateFlags state, GValue *value); @@ -71,10 +72,12 @@ gboolean _gtk_style_property_is_inherit (const GtkStyleProper void _gtk_style_property_default_value (const GtkStyleProperty *property, GtkStyleProperties *properties, + GtkStateFlags state, GValue *value); void _gtk_style_property_resolve (const GtkStyleProperty *property, GtkStyleProperties *properties, + GtkStateFlags state, GValue *value); gboolean _gtk_style_property_is_shorthand (const GtkStyleProperty *property);