diff --git a/gtk/gtkborderimage.c b/gtk/gtkborderimage.c index dd8259131b..48d690d2e6 100644 --- a/gtk/gtkborderimage.c +++ b/gtk/gtkborderimage.c @@ -27,6 +27,7 @@ #include #include "gtkborderimageprivate.h" +#include "gtkstylepropertiesprivate.h" /* this is in case round() is not provided by the compiler, * such as in the case of C89 compilers, like MSVC @@ -194,19 +195,20 @@ _gtk_border_image_unpack (const GValue *value, void _gtk_border_image_pack (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { GtkBorderImage *image; cairo_pattern_t *source; GtkBorder *slice, *width; GtkCssBorderImageRepeat *repeat; - gtk_style_properties_get (props, state, - "border-image-source", &source, - "border-image-slice", &slice, - "border-image-repeat", &repeat, - "border-image-width", &width, - NULL); + _gtk_style_properties_get (props, state, context, + "border-image-source", &source, + "border-image-slice", &slice, + "border-image-repeat", &repeat, + "border-image-width", &width, + NULL); if (source == NULL) { diff --git a/gtk/gtkborderimageprivate.h b/gtk/gtkborderimageprivate.h index 563ce299de..ee4975f263 100644 --- a/gtk/gtkborderimageprivate.h +++ b/gtk/gtkborderimageprivate.h @@ -29,6 +29,7 @@ #include "gtkstyleproperties.h" #include "gtkthemingengine.h" #include "gtkcsstypesprivate.h" +#include "gtkstylecontextprivate.h" G_BEGIN_DECLS @@ -63,7 +64,8 @@ GParameter * _gtk_border_image_unpack (const GValue *valu guint *n_params); void _gtk_border_image_pack (GValue *value, GtkStyleProperties *props, - GtkStateFlags state); + GtkStateFlags state, + GtkStylePropertyContext *context); G_END_DECLS diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index e67c4cca38..b2993ecfee 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1367,6 +1367,24 @@ gtk_style_context_get_property (GtkStyleContext *context, gtk_style_properties_get_property (data->store, property, state, value); } +void +_gtk_style_context_get_valist (GtkStyleContext *context, + GtkStateFlags state, + GtkStylePropertyContext *property_context, + va_list args) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + priv = context->priv; + g_return_if_fail (priv->widget_path != NULL); + + data = style_data_lookup (context); + _gtk_style_properties_get_valist (data->store, state, property_context, args); +} + /** * gtk_style_context_get_valist: * @context: a #GtkStyleContext diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h index 57db77e5cb..9796bafc66 100644 --- a/gtk/gtkstylecontextprivate.h +++ b/gtk/gtkstylecontextprivate.h @@ -24,7 +24,17 @@ G_BEGIN_DECLS +typedef struct _GtkStylePropertyContext GtkStylePropertyContext; +struct _GtkStylePropertyContext +{ + int width; + int height; +}; +void _gtk_style_context_get_valist (GtkStyleContext *context, + GtkStateFlags state, + GtkStylePropertyContext *property_context, + va_list args); const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, GtkStateFlags state, diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index f3946f8659..3a6b4b475a 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -640,6 +640,7 @@ const GValue * _gtk_style_properties_peek_property (GtkStyleProperties *props, const gchar *prop_name, GtkStateFlags state, + GtkStylePropertyContext *context, const GtkStyleProperty **property) { GtkStylePropertiesPrivate *priv; @@ -670,11 +671,42 @@ _gtk_style_properties_peek_property (GtkStyleProperties *props, if (val == NULL) return NULL; - _gtk_style_property_resolve (node, props, state, val); + _gtk_style_property_resolve (node, props, state, context, val); return val; } +gboolean +_gtk_style_properties_get_property (GtkStyleProperties *props, + const gchar *property, + GtkStateFlags state, + GtkStylePropertyContext *context, + GValue *value) +{ + const GtkStyleProperty *node; + const GValue *val; + + g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); + g_return_val_if_fail (property != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + val = _gtk_style_properties_peek_property (props, property, state, context, &node); + + if (!node) + return FALSE; + + g_value_init (value, node->pspec->value_type); + + if (val) + g_value_copy (val, value); + else if (_gtk_style_property_is_shorthand (node)) + _gtk_style_property_pack (node, props, state, context, value); + else + _gtk_style_property_default_value (node, props, state, value); + + return TRUE; +} + /** * gtk_style_properties_get_property: * @props: a #GtkStyleProperties @@ -695,44 +727,22 @@ gtk_style_properties_get_property (GtkStyleProperties *props, GtkStateFlags state, GValue *value) { - const GtkStyleProperty *node; - const GValue *val; + GtkStylePropertyContext context = { 100, 100}; g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); g_return_val_if_fail (property != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); - val = _gtk_style_properties_peek_property (props, property, state, &node); - - if (!node) - return FALSE; - - g_value_init (value, node->pspec->value_type); - - if (val) - g_value_copy (val, value); - else if (_gtk_style_property_is_shorthand (node)) - _gtk_style_property_pack (node, props, state, value); - else - _gtk_style_property_default_value (node, props, state, value); - - return TRUE; + return _gtk_style_properties_get_property (props, + property, + state, &context, value); } -/** - * gtk_style_properties_get_valist: - * @props: a #GtkStyleProperties - * @state: state to retrieve the property values for - * @args: va_list of property name/return location pairs, followed by %NULL - * - * Retrieves several style property values from @props for a given state. - * - * Since: 3.0 - **/ void -gtk_style_properties_get_valist (GtkStyleProperties *props, - GtkStateFlags state, - va_list args) +_gtk_style_properties_get_valist (GtkStyleProperties *props, + GtkStateFlags state, + GtkStylePropertyContext *context, + va_list args) { const gchar *property_name; @@ -746,7 +756,7 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, gchar *error = NULL; const GValue *val; - val = _gtk_style_properties_peek_property (props, property_name, state, &node); + val = _gtk_style_properties_peek_property (props, property_name, state, context, &node); if (!node) break; @@ -759,7 +769,7 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, GValue packed = G_VALUE_INIT; g_value_init (&packed, node->pspec->value_type); - _gtk_style_property_pack (node, props, state, &packed); + _gtk_style_property_pack (node, props, state, context, &packed); G_VALUE_LCOPY (&packed, args, 0, &error); g_value_unset (&packed); } @@ -784,6 +794,41 @@ gtk_style_properties_get_valist (GtkStyleProperties *props, } } +/** + * gtk_style_properties_get_valist: + * @props: a #GtkStyleProperties + * @state: state to retrieve the property values for + * @args: va_list of property name/return location pairs, followed by %NULL + * + * Retrieves several style property values from @props for a given state. + * + * Since: 3.0 + **/ +void +gtk_style_properties_get_valist (GtkStyleProperties *props, + GtkStateFlags state, + va_list args) +{ + GtkStylePropertyContext context = { 100, 100}; + + return _gtk_style_properties_get_valist (props, state, &context, args); +} + +void +_gtk_style_properties_get (GtkStyleProperties *props, + GtkStateFlags state, + GtkStylePropertyContext *context, + ...) +{ + va_list args; + + g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); + + va_start (args, context); + _gtk_style_properties_get_valist (props, state, context, args); + va_end (args); +} + /** * gtk_style_properties_get: * @props: a #GtkStyleProperties diff --git a/gtk/gtkstylepropertiesprivate.h b/gtk/gtkstylepropertiesprivate.h index bbb5d81fbf..628fd50339 100644 --- a/gtk/gtkstylepropertiesprivate.h +++ b/gtk/gtkstylepropertiesprivate.h @@ -22,13 +22,30 @@ #include "gtkstyleproperties.h" #include "gtkstylepropertyprivate.h" +#include "gtkstylecontextprivate.h" G_BEGIN_DECLS const GValue * _gtk_style_properties_peek_property (GtkStyleProperties *props, const gchar *prop_name, GtkStateFlags state, + GtkStylePropertyContext *context, const GtkStyleProperty **property); +void _gtk_style_properties_get (GtkStyleProperties *props, + GtkStateFlags state, + GtkStylePropertyContext *context, + ...); +void _gtk_style_properties_get_valist (GtkStyleProperties *props, + GtkStateFlags state, + GtkStylePropertyContext *context, + va_list args); + +const GValue * _gtk_style_properties_resolve_property (GtkStyleProperties *props, + const gchar *prop_name, + GtkStateFlags state, + const GtkStyleProperty **property, + GtkStylePropertyContext *context, + GValue *value); void _gtk_style_properties_set_property_by_property (GtkStyleProperties *props, const GtkStyleProperty *property, diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c index 99b804f595..2ece9b65de 100644 --- a/gtk/gtkstyleproperty.c +++ b/gtk/gtkstyleproperty.c @@ -1855,7 +1855,8 @@ unpack_border_width (const GValue *value, static void pack_border_width (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { pack_border (value, props, state, "border-top-width", "border-left-width", @@ -1874,7 +1875,8 @@ unpack_padding (const GValue *value, static void pack_padding (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { pack_border (value, props, state, "padding-top", "padding-left", @@ -1893,7 +1895,8 @@ unpack_margin (const GValue *value, static void pack_margin (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { pack_border (value, props, state, "margin-top", "margin-left", @@ -1935,7 +1938,8 @@ unpack_border_radius (const GValue *value, static void pack_border_radius (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { GtkCssBorderCornerRadius *top_left; @@ -2035,7 +2039,8 @@ unpack_font_description (const GValue *value, static void pack_font_description (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { PangoFontDescription *description; char **families; @@ -2113,7 +2118,8 @@ unpack_border_color (const GValue *value, static void pack_border_color (GValue *value, GtkStyleProperties *props, - GtkStateFlags state) + GtkStateFlags state, + GtkStylePropertyContext *context) { /* NB: We are a color property, so we have to resolve to a color here. * So we just resolve to a color. We pick one and stick to it. @@ -2512,6 +2518,7 @@ void _gtk_style_property_resolve (const GtkStyleProperty *property, GtkStyleProperties *props, GtkStateFlags state, + GtkStylePropertyContext *context, GValue *val) { if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) @@ -2579,6 +2586,7 @@ void _gtk_style_property_pack (const GtkStyleProperty *property, GtkStyleProperties *props, GtkStateFlags state, + GtkStylePropertyContext *context, GValue *value) { g_return_if_fail (property != NULL); @@ -2586,7 +2594,7 @@ _gtk_style_property_pack (const GtkStyleProperty *property, g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props)); g_return_if_fail (G_IS_VALUE (value)); - property->pack_func (value, props, state); + property->pack_func (value, props, state, context); } static void diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h index aef18b8893..07994d5f26 100644 --- a/gtk/gtkstylepropertyprivate.h +++ b/gtk/gtkstylepropertyprivate.h @@ -21,6 +21,7 @@ #define __GTK_STYLEPROPERTY_PRIVATE_H__ #include "gtkcssparserprivate.h" +#include "gtkstylecontextprivate.h" G_BEGIN_DECLS @@ -33,7 +34,8 @@ typedef GParameter * (* GtkStyleUnpackFunc) (const GValue guint *n_params); typedef void (* GtkStylePackFunc) (GValue *value, GtkStyleProperties *props, - GtkStateFlags state); + GtkStateFlags state, + GtkStylePropertyContext *context); typedef gboolean (* GtkStyleParseFunc) (GtkCssParser *parser, GFile *base, GValue *value); @@ -82,7 +84,8 @@ void _gtk_style_property_default_value (const GtkStyleProper void _gtk_style_property_resolve (const GtkStyleProperty *property, GtkStyleProperties *properties, GtkStateFlags state, - GValue *value); + GtkStylePropertyContext *context, + GValue *orig_value); gboolean _gtk_style_property_is_shorthand (const GtkStyleProperty *property); GParameter * _gtk_style_property_unpack (const GtkStyleProperty *property, @@ -91,6 +94,7 @@ GParameter * _gtk_style_property_unpack (const GtkStyleProper void _gtk_style_property_pack (const GtkStyleProperty *property, GtkStyleProperties *props, GtkStateFlags state, + GtkStylePropertyContext *context, GValue *value); gboolean _gtk_style_property_parse_value (const GtkStyleProperty *property, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index f068c3d38d..81430d56e2 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -450,6 +450,25 @@ gtk_theming_engine_get_valist (GtkThemingEngine *engine, gtk_style_context_get_valist (priv->context, state, args); } +void +_gtk_theming_engine_get (GtkThemingEngine *engine, + GtkStateFlags state, + GtkStylePropertyContext *property_context, + ...) +{ + GtkThemingEnginePrivate *priv; + va_list args; + + g_return_if_fail (GTK_IS_THEMING_ENGINE (engine)); + + priv = engine->priv; + + va_start (args, property_context); + _gtk_style_context_get_valist (priv->context, state, property_context, args); + va_end (args); +} + + /** * gtk_theming_engine_get: * @engine: a #GtkThemingEngine diff --git a/gtk/gtkthemingengineprivate.h b/gtk/gtkthemingengineprivate.h index caf189ec6b..5191fa05b8 100644 --- a/gtk/gtkthemingengineprivate.h +++ b/gtk/gtkthemingengineprivate.h @@ -21,6 +21,13 @@ #define __GTK_THEMING_ENGINE_PRIVATE_H__ #include +#include "gtkstylecontextprivate.h" + +void _gtk_theming_engine_get (GtkThemingEngine *engine, + GtkStateFlags state, + GtkStylePropertyContext *property_context, + ...) G_GNUC_NULL_TERMINATED; + void _gtk_theming_engine_paint_spinner (cairo_t *cr, gdouble radius,