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).
This commit is contained in:
Benjamin Otte 2011-06-13 01:26:11 +02:00
parent e0b1943c97
commit ba7d1c2104
3 changed files with 14 additions and 8 deletions

View File

@ -669,7 +669,7 @@ _gtk_style_properties_peek_property (GtkStyleProperties *props,
if (val == NULL) if (val == NULL)
return NULL; return NULL;
_gtk_style_property_resolve (node, props, val); _gtk_style_property_resolve (node, props, state, val);
return val; return val;
} }
@ -713,7 +713,7 @@ gtk_style_properties_get_property (GtkStyleProperties *props,
else if (_gtk_style_property_is_shorthand (node)) else if (_gtk_style_property_is_shorthand (node))
_gtk_style_property_pack (node, props, state, value); _gtk_style_property_pack (node, props, state, value);
else else
_gtk_style_property_default_value (node, props, value); _gtk_style_property_default_value (node, props, state, value);
return TRUE; return TRUE;
} }
@ -767,7 +767,7 @@ gtk_style_properties_get_valist (GtkStyleProperties *props,
GValue default_value = { 0 }; GValue default_value = { 0 };
g_value_init (&default_value, node->pspec->value_type); 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_LCOPY (&default_value, args, 0, &error);
g_value_unset (&default_value); g_value_unset (&default_value);
} }

View File

@ -1683,6 +1683,7 @@ pack_border_radius (GValue *value,
static void static void
border_image_width_default_value (GtkStyleProperties *props, border_image_width_default_value (GtkStyleProperties *props,
GtkStateFlags state,
GValue *value) GValue *value)
{ {
} }
@ -1858,10 +1859,11 @@ _gtk_style_property_print_value (const GtkStyleProperty *property,
void void
_gtk_style_property_default_value (const GtkStyleProperty *property, _gtk_style_property_default_value (const GtkStyleProperty *property,
GtkStyleProperties *properties, GtkStyleProperties *properties,
GtkStateFlags state,
GValue *value) GValue *value)
{ {
if (property->default_value_func) 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) else if (property->pspec->value_type == GTK_TYPE_THEMING_ENGINE)
g_value_set_object (value, gtk_theming_engine_load (NULL)); g_value_set_object (value, gtk_theming_engine_load (NULL));
else if (property->pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION) else if (property->pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
@ -1970,6 +1972,7 @@ resolve_shadow (GtkStyleProperties *props,
void void
_gtk_style_property_resolve (const GtkStyleProperty *property, _gtk_style_property_resolve (const GtkStyleProperty *property,
GtkStyleProperties *props, GtkStyleProperties *props,
GtkStateFlags state,
GValue *val) GValue *val)
{ {
if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) 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_unset (val);
g_value_init (val, property->pspec->value_type); 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) else if (G_VALUE_TYPE (val) == GDK_TYPE_RGBA)
{ {
if (g_value_get_boxed (val) == NULL) 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) 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_unset (val);
g_value_init (val, CAIRO_GOBJECT_TYPE_PATTERN); 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) else if (G_VALUE_TYPE (val) == GTK_TYPE_SHADOW)
{ {
if (!resolve_shadow (props, val)) if (!resolve_shadow (props, val))
_gtk_style_property_default_value (property, props, val); _gtk_style_property_default_value (property, props, state, val);
} }
} }

View File

@ -40,6 +40,7 @@ typedef gboolean (* GtkStyleParseFunc) (GtkCssParser
typedef void (* GtkStylePrintFunc) (const GValue *value, typedef void (* GtkStylePrintFunc) (const GValue *value,
GString *string); GString *string);
typedef void (* GtkStyleDefaultValueFunc) (GtkStyleProperties *props, typedef void (* GtkStyleDefaultValueFunc) (GtkStyleProperties *props,
GtkStateFlags state,
GValue *value); GValue *value);
@ -71,10 +72,12 @@ gboolean _gtk_style_property_is_inherit (const GtkStyleProper
void _gtk_style_property_default_value (const GtkStyleProperty *property, void _gtk_style_property_default_value (const GtkStyleProperty *property,
GtkStyleProperties *properties, GtkStyleProperties *properties,
GtkStateFlags state,
GValue *value); GValue *value);
void _gtk_style_property_resolve (const GtkStyleProperty *property, void _gtk_style_property_resolve (const GtkStyleProperty *property,
GtkStyleProperties *properties, GtkStyleProperties *properties,
GtkStateFlags state,
GValue *value); GValue *value);
gboolean _gtk_style_property_is_shorthand (const GtkStyleProperty *property); gboolean _gtk_style_property_is_shorthand (const GtkStyleProperty *property);