diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 7d8d6ddac8..cc9c3020f1 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -456,6 +456,7 @@ gtk_private_h_sources = \ gtkcssstringvalueprivate.h \ gtkcssstylefuncsprivate.h \ gtkcssstylepropertyprivate.h \ + gtkcsstypedvalueprivate.h \ gtkcssvalueprivate.h \ gtkcustompaperunixdialog.h \ gtkentryprivate.h \ @@ -670,6 +671,7 @@ gtk_base_c_sources = \ gtkcssstylefuncs.c \ gtkcssstyleproperty.c \ gtkcssstylepropertyimpl.c \ + gtkcsstypedvalue.c \ gtkcssvalue.c \ gtkcsstypes.c \ gtkdialog.c \ diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c index 0f20c1fc7f..8f50d8a5e2 100644 --- a/gtk/gtkcsscustomproperty.c +++ b/gtk/gtkcsscustomproperty.c @@ -24,6 +24,7 @@ #include #include "gtkcssstylefuncsprivate.h" +#include "gtkcsstypedvalueprivate.h" #include "gtkstylepropertiesprivate.h" #include "gtkthemingengine.h" @@ -46,7 +47,6 @@ gtk_css_custom_property_parse_value (GtkStyleProperty *property, { GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property); GValue value = G_VALUE_INIT; - GtkCssValue *result; gboolean success; if (custom->property_parse_func) @@ -78,10 +78,7 @@ gtk_css_custom_property_parse_value (GtkStyleProperty *property, return NULL; } - result = _gtk_css_value_new_from_gvalue (&value); - g_value_unset (&value); - - return result; + return _gtk_css_typed_value_new_take (&value); } static void @@ -91,14 +88,15 @@ gtk_css_custom_property_query (GtkStyleProperty *property, gpointer query_data) { GtkCssStyleProperty *style = GTK_CSS_STYLE_PROPERTY (property); + GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property); GtkCssValue *css_value; css_value = (* query_func) (_gtk_css_style_property_get_id (style), query_data); if (css_value == NULL) - css_value =_gtk_css_style_property_get_initial_value (style); + css_value = _gtk_css_style_property_get_initial_value (style); - _gtk_css_value_init_gvalue (css_value, value); - g_assert (GTK_CSS_CUSTOM_PROPERTY (property)->pspec->value_type == G_VALUE_TYPE (value)); + g_value_init (value, custom->pspec->value_type); + g_value_copy (_gtk_css_typed_value_get (css_value), value); } static void @@ -107,7 +105,7 @@ gtk_css_custom_property_assign (GtkStyleProperty *property, GtkStateFlags state, const GValue *value) { - GtkCssValue *css_value = _gtk_css_value_new_from_gvalue (value); + GtkCssValue *css_value = _gtk_css_typed_value_new (value); _gtk_style_properties_set_property_by_property (props, GTK_CSS_STYLE_PROPERTY (property), state, @@ -174,7 +172,7 @@ gtk_css_custom_property_create_initial_value (GParamSpec *pspec) else g_param_value_set_default (pspec, &value); - result = _gtk_css_value_new_from_gvalue (&value); + result = _gtk_css_typed_value_new (&value); g_value_unset (&value); return result; diff --git a/gtk/gtkcssstylefuncs.c b/gtk/gtkcssstylefuncs.c index dcdd25d569..7456442934 100644 --- a/gtk/gtkcssstylefuncs.c +++ b/gtk/gtkcssstylefuncs.c @@ -29,11 +29,10 @@ #include "gtkcssimagegradientprivate.h" #include "gtkcssprovider.h" -#include "gtkcssrgbavalueprivate.h" +#include "gtkcsstypedvalueprivate.h" #include "gtkcsstypesprivate.h" #include "gtkgradient.h" #include "gtkprivatetypebuiltins.h" -#include "gtkcssshadowvalueprivate.h" #include "gtkstylecontextprivate.h" #include "gtksymboliccolorprivate.h" #include "gtkthemingengine.h" @@ -209,16 +208,22 @@ rgba_value_compute (GtkStyleContext *context, GtkCssValue *specified) { GdkRGBA white = { 1, 1, 1, 1 }; + const GValue *value; + + value = _gtk_css_typed_value_get (specified); - if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR)) + if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR)) { - GtkSymbolicColor *symbolic = _gtk_css_value_get_boxed (specified); + GtkSymbolicColor *symbolic = g_value_get_boxed (value); + GValue new_value = G_VALUE_INIT; GdkRGBA rgba; if (!_gtk_style_context_resolve_color (context, symbolic, &rgba)) rgba = white; - return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba); + g_value_init (&new_value, GDK_TYPE_RGBA); + g_value_set_boxed (&new_value, &rgba); + return _gtk_css_typed_value_new_take (&new_value); } else return _gtk_css_value_ref (specified); @@ -278,11 +283,16 @@ color_value_compute (GtkStyleContext *context, { GdkRGBA rgba; GdkColor color = { 0, 65535, 65535, 65535 }; + const GValue *value; - if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR)) + value = _gtk_css_typed_value_get (specified); + + if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR)) { + GValue new_value = G_VALUE_INIT; + if (_gtk_style_context_resolve_color (context, - _gtk_css_value_get_boxed (specified), + g_value_get_boxed (value), &rgba)) { color.red = rgba.red * 65535. + 0.5; @@ -290,7 +300,9 @@ color_value_compute (GtkStyleContext *context, color.blue = rgba.blue * 65535. + 0.5; } - return _gtk_css_value_new_from_color (&color); + g_value_init (&new_value, GDK_TYPE_COLOR); + g_value_set_boxed (&new_value, &color); + return _gtk_css_typed_value_new_take (&new_value); } else return _gtk_css_value_ref (specified); @@ -821,13 +833,18 @@ static GtkCssValue * pattern_value_compute (GtkStyleContext *context, GtkCssValue *specified) { - if (_gtk_css_value_holds (specified, GTK_TYPE_GRADIENT)) + const GValue *value = _gtk_css_typed_value_get (specified); + + if (G_VALUE_HOLDS (value, GTK_TYPE_GRADIENT)) { + GValue new_value = G_VALUE_INIT; cairo_pattern_t *gradient; - gradient = gtk_gradient_resolve_for_context (_gtk_css_value_get_gradient (specified), context); + gradient = gtk_gradient_resolve_for_context (g_value_get_boxed (value), context); - return _gtk_css_value_new_take_pattern (gradient); + g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN); + g_value_take_boxed (&new_value, gradient); + return _gtk_css_typed_value_new_take (&new_value); } else return _gtk_css_value_ref (specified); diff --git a/gtk/gtkcsstypedvalue.c b/gtk/gtkcsstypedvalue.c new file mode 100644 index 0000000000..a16742790e --- /dev/null +++ b/gtk/gtkcsstypedvalue.c @@ -0,0 +1,120 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2011 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include "config.h" + +#include "gtkcsstypedvalueprivate.h" + +#include "gtkcssstylefuncsprivate.h" + +struct _GtkCssValue { + GTK_CSS_VALUE_BASE + GValue value; +}; + +static void +gtk_css_value_typed_free (GtkCssValue *value) +{ + g_value_unset (&value->value); + g_slice_free (GtkCssValue, value); +} + +static gboolean +gtk_css_value_typed_equal (const GtkCssValue *value1, + const GtkCssValue *value2) +{ + return FALSE; +} + +static GtkCssValue * +gtk_css_value_typed_transition (GtkCssValue *start, + GtkCssValue *end, + double progress) +{ + return NULL; +} + +static void +gtk_css_value_typed_print (const GtkCssValue *value, + GString *string) +{ + _gtk_css_style_print_value (&value->value, string); +} + +static const GtkCssValueClass GTK_CSS_VALUE_TYPED = { + gtk_css_value_typed_free, + gtk_css_value_typed_equal, + gtk_css_value_typed_transition, + gtk_css_value_typed_print +}; + +static GtkCssValue * +gtk_css_typed_value_new_for_type (GType type) +{ + GtkCssValue *result; + + result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_TYPED); + + g_value_init (&result->value, type); + + return result; +} + +GtkCssValue * +_gtk_css_typed_value_new (const GValue *value) +{ + GtkCssValue *result; + + g_return_val_if_fail (G_IS_VALUE (value), NULL); + + result = gtk_css_typed_value_new_for_type (G_VALUE_TYPE (value)); + + g_value_copy (value, &result->value); + + return result; +} + +GtkCssValue * +_gtk_css_typed_value_new_take (GValue *value) +{ + GtkCssValue *result; + + g_return_val_if_fail (G_IS_VALUE (value), NULL); + + result = _gtk_css_typed_value_new (value); + g_value_unset (value); + + return result; +} + +gboolean +_gtk_is_css_typed_value_of_type (const GtkCssValue *value, + GType type) +{ + if (value->class != >K_CSS_VALUE_TYPED) + return FALSE; + + return G_VALUE_HOLDS (&value->value, type); +} + +const GValue * +_gtk_css_typed_value_get (const GtkCssValue *value) +{ + g_return_val_if_fail (value->class == >K_CSS_VALUE_TYPED, NULL); + + return &value->value; +} diff --git a/gtk/gtkcsstypedvalueprivate.h b/gtk/gtkcsstypedvalueprivate.h new file mode 100644 index 0000000000..3061b9be53 --- /dev/null +++ b/gtk/gtkcsstypedvalueprivate.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2012 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Authors: Alexander Larsson + */ + +#ifndef __GTK_CSS_TYPED_VALUE_PRIVATE_H__ +#define __GTK_CSS_TYPED_VALUE_PRIVATE_H__ + +#include "gtkcssparserprivate.h" +#include "gtkcssvalueprivate.h" + +G_BEGIN_DECLS + +GtkCssValue * _gtk_css_typed_value_new (const GValue *value); +GtkCssValue * _gtk_css_typed_value_new_take (GValue *value); + +gboolean _gtk_is_css_typed_value_of_type (const GtkCssValue *value, + GType type); + +const GValue * _gtk_css_typed_value_get (const GtkCssValue *value); + +G_END_DECLS + +#endif /* __GTK_CSS_TYPED_VALUE_PRIVATE_H__ */ diff --git a/gtk/gtkcssvalue.c b/gtk/gtkcssvalue.c index 477d7b1f0d..c24f703fe8 100644 --- a/gtk/gtkcssvalue.c +++ b/gtk/gtkcssvalue.c @@ -18,288 +18,13 @@ #include "config.h" #include "gtkcssvalueprivate.h" -#include "gtkcssstylefuncsprivate.h" -#include "gtktypebuiltins.h" -#include "gtkgradient.h" -#include -#include "gtkprivatetypebuiltins.h" -#include "fallback-c89.c" - -struct _GtkCssValue -{ +struct _GtkCssValue { GTK_CSS_VALUE_BASE - GType type; - union { - gpointer ptr; - gint gint; - guint guint; - double dbl; - float flt; - } u; -}; - -static void -gtk_css_value_default_free (GtkCssValue *value) -{ - GType type = value->type; - - if (g_type_is_a (type, G_TYPE_OBJECT)) - { - if (value->u.ptr != NULL) - g_object_unref (value->u.ptr); - } - else if (g_type_is_a (type, G_TYPE_BOXED)) - { - if (value->u.ptr != NULL) - g_boxed_free (type, value->u.ptr); - } - else if (g_type_is_a (type, G_TYPE_STRING)) - g_free (value->u.ptr); - else if (g_type_is_a (type, G_TYPE_INT)) - {} - else if (g_type_is_a (type, G_TYPE_UINT)) - {} - else if (g_type_is_a (type, G_TYPE_BOOLEAN)) - {} - else if (g_type_is_a (type, G_TYPE_ENUM)) - {} - else if (g_type_is_a (type, G_TYPE_FLAGS)) - {} - else if (g_type_is_a (type, G_TYPE_DOUBLE)) - {} - else if (g_type_is_a (type, G_TYPE_FLOAT)) - {} - else - { - g_value_unset (value->u.ptr); - g_slice_free (GValue, value->u.ptr); - } - - g_slice_free (GtkCssValue, value); -} - -static gboolean -gtk_css_value_default_equal (const GtkCssValue *value1, - const GtkCssValue *value2) -{ - return FALSE; -} - -static GtkCssValue * -gtk_css_value_default_transition (GtkCssValue *start, - GtkCssValue *end, - double progress) -{ - return NULL; -} - -static void -gtk_css_value_default_print (const GtkCssValue *value, - GString *string) -{ - GValue g_value = G_VALUE_INIT; - - _gtk_css_value_init_gvalue (value, &g_value); - _gtk_css_style_print_value (&g_value, string); - g_value_unset (&g_value); -} - -static const GtkCssValueClass GTK_CSS_VALUE_DEFAULT = { - gtk_css_value_default_free, - gtk_css_value_default_equal, - gtk_css_value_default_transition, - gtk_css_value_default_print }; G_DEFINE_BOXED_TYPE (GtkCssValue, _gtk_css_value, _gtk_css_value_ref, _gtk_css_value_unref) -static GtkCssValue * -gtk_css_value_new (GType type) -{ - GtkCssValue *value; - - value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_DEFAULT); - - value->type = type; - - return value; -} - -GtkCssValue * -_gtk_css_value_new_from_gvalue (const GValue *g_value) -{ - GtkCssValue *value; - GType type; - - g_return_val_if_fail (g_value != NULL, NULL); - - type = G_VALUE_TYPE (g_value); - - /* Make sure we reuse the int/number singletons */ - if (type == G_TYPE_INT) - value = _gtk_css_value_new_from_int (g_value_get_int (g_value)); - else - { - value = gtk_css_value_new (type); - - if (g_type_is_a (type, G_TYPE_OBJECT)) - value->u.ptr = g_value_dup_object (g_value); - else if (g_type_is_a (type, G_TYPE_BOXED)) - value->u.ptr = g_value_dup_boxed (g_value); - else if (g_type_is_a (type, G_TYPE_INT)) - value->u.gint = g_value_get_int (g_value); - else if (g_type_is_a (type, G_TYPE_UINT)) - value->u.guint = g_value_get_uint (g_value); - else if (g_type_is_a (type, G_TYPE_BOOLEAN)) - value->u.gint = g_value_get_boolean (g_value); - else if (g_type_is_a (type, G_TYPE_ENUM)) - value->u.gint = g_value_get_enum (g_value); - else if (g_type_is_a (type, G_TYPE_FLAGS)) - value->u.guint = g_value_get_flags (g_value); - else if (g_type_is_a (type, G_TYPE_STRING)) - value->u.ptr = g_value_dup_string (g_value); - else if (g_type_is_a (type, G_TYPE_DOUBLE)) - value->u.dbl = g_value_get_double (g_value); - else if (g_type_is_a (type, G_TYPE_FLOAT)) - value->u.flt = g_value_get_float (g_value); - else - { - value->u.ptr = g_slice_new0 (GValue); - g_value_init (value->u.ptr, G_VALUE_TYPE (g_value)); - g_value_copy (g_value, value->u.ptr); - } - } - - return value; -} - -GtkCssValue * -_gtk_css_value_new_from_int (gint val) -{ - GtkCssValue *value; - static GtkCssValue *singletons[4] = {NULL}; - - if (val >= 0 && val < G_N_ELEMENTS (singletons)) - { - if (singletons[val] == NULL) - { - value = gtk_css_value_new (G_TYPE_INT); - value->u.gint = val; - singletons[val] = value; - } - return _gtk_css_value_ref (singletons[val]); - } - - value = gtk_css_value_new (G_TYPE_INT); - value->u.gint = val; - - return value; -} - -GtkCssValue * -_gtk_css_value_new_from_enum (GType type, - gint val) -{ - GtkCssValue *value; - - g_return_val_if_fail (g_type_is_a (type, G_TYPE_ENUM), NULL); - - value = gtk_css_value_new (type); - value->u.gint = val; - - return value; -} - -GtkCssValue * -_gtk_css_value_new_take_strv (char **strv) -{ - GtkCssValue *value; - - value = gtk_css_value_new (G_TYPE_STRV); - value->u.ptr = strv; - - return value; -} - -static gpointer -g_boxed_copy0 (GType boxed_type, - gconstpointer src_boxed) -{ - if (src_boxed == NULL) - return NULL; - return g_boxed_copy (boxed_type, src_boxed); -} - -GtkCssValue * -_gtk_css_value_new_from_boxed (GType type, - gpointer boxed) -{ - GtkCssValue *value; - - g_return_val_if_fail (g_type_is_a (type, G_TYPE_BOXED), NULL); - - value = gtk_css_value_new (type); - value->u.ptr = g_boxed_copy0 (type, boxed); - - return value; -} - -GtkCssValue * -_gtk_css_value_new_take_pattern (cairo_pattern_t *v) -{ - GtkCssValue *value; - - value = gtk_css_value_new (CAIRO_GOBJECT_TYPE_PATTERN); - value->u.ptr = v; - - return value; -} - -GtkCssValue * -_gtk_css_value_new_take_binding_sets (GPtrArray *array) -{ - GtkCssValue *value; - - value = gtk_css_value_new (G_TYPE_PTR_ARRAY); - value->u.ptr = array; - - return value; -} - -GtkCssValue * -_gtk_css_value_new_from_color (const GdkColor *v) -{ - GtkCssValue *value; - - value = gtk_css_value_new (GDK_TYPE_COLOR); - value->u.ptr = g_boxed_copy0 (GDK_TYPE_COLOR, v); - - return value; -} - -GtkCssValue * -_gtk_css_value_new_from_border_style (GtkBorderStyle style) -{ - GtkCssValue *value; - - value = gtk_css_value_new (GTK_TYPE_BORDER_STYLE); - value->u.gint = style; - - return value; -} - -GtkCssValue * -_gtk_css_value_new_take_symbolic_color (GtkSymbolicColor *v) -{ - GtkCssValue *value; - - value = gtk_css_value_new (GTK_TYPE_SYMBOLIC_COLOR); - value->u.ptr = v; - - return value; -} - GtkCssValue * _gtk_css_value_alloc (const GtkCssValueClass *klass, gsize size) @@ -398,128 +123,3 @@ _gtk_css_value_print (const GtkCssValue *value, value->class->print (value, string); } -GType -_gtk_css_value_get_content_type (const GtkCssValue *value) -{ - g_return_val_if_fail (value->class == >K_CSS_VALUE_DEFAULT, G_TYPE_NONE); - - return value->type; -} - -gboolean -_gtk_css_value_holds (const GtkCssValue *value, GType type) -{ - g_return_val_if_fail (value->class == >K_CSS_VALUE_DEFAULT, FALSE); - - return g_type_is_a (value->type, type); -} - -static void -fill_gvalue (const GtkCssValue *value, - GValue *g_value) -{ - GType type; - - type = value->type; - - if (g_type_is_a (type, G_TYPE_OBJECT)) - g_value_set_object (g_value, value->u.ptr); - else if (g_type_is_a (type, G_TYPE_BOXED)) - g_value_set_boxed (g_value, value->u.ptr); - else if (g_type_is_a (type, G_TYPE_INT)) - g_value_set_int (g_value, value->u.gint); - else if (g_type_is_a (type, G_TYPE_UINT)) - g_value_set_uint (g_value, value->u.guint); - else if (g_type_is_a (type, G_TYPE_BOOLEAN)) - g_value_set_boolean (g_value, value->u.gint); - else if (g_type_is_a (type, G_TYPE_ENUM)) - g_value_set_enum (g_value, value->u.gint); - else if (g_type_is_a (type, G_TYPE_FLAGS)) - g_value_set_flags (g_value, value->u.guint); - else if (g_type_is_a (type, G_TYPE_STRING)) - g_value_set_string (g_value, value->u.ptr); - else if (g_type_is_a (type, G_TYPE_DOUBLE)) - g_value_set_double (g_value, value->u.dbl); - else if (g_type_is_a (type, G_TYPE_FLOAT)) - g_value_set_float (g_value, value->u.flt); - else - g_value_copy (value->u.ptr, g_value); -} - -void -_gtk_css_value_init_gvalue (const GtkCssValue *value, - GValue *g_value) -{ - if (value != NULL) - { - g_return_if_fail (value->class == >K_CSS_VALUE_DEFAULT); - g_value_init (g_value, value->type); - fill_gvalue (value, g_value); - } -} - -GtkSymbolicColor * -_gtk_css_value_get_symbolic_color (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_SYMBOLIC_COLOR), NULL); - return value->u.ptr; -} - -int -_gtk_css_value_get_int (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_INT), 0); - return value->u.gint; -} - -int -_gtk_css_value_get_enum (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_ENUM), 0); - return value->u.gint; -} - -gpointer -_gtk_css_value_dup_object (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_OBJECT), NULL); - if (value->u.ptr) - return g_object_ref (value->u.ptr); - return NULL; -} - -gpointer -_gtk_css_value_get_object (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_OBJECT), NULL); - return value->u.ptr; -} - -gpointer -_gtk_css_value_get_boxed (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_BOXED), NULL); - return value->u.ptr; -} - -const char ** -_gtk_css_value_get_strv (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_STRV), NULL); - return value->u.ptr; -} - -GtkBorderStyle -_gtk_css_value_get_border_style (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_BORDER_STYLE), 0); - return value->u.gint; -} - -GtkGradient * -_gtk_css_value_get_gradient (const GtkCssValue *value) -{ - g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_GRADIENT), NULL); - return value->u.ptr; -} - diff --git a/gtk/gtkcssvalueprivate.h b/gtk/gtkcssvalueprivate.h index 1bcfe73ade..9f30d0e8c8 100644 --- a/gtk/gtkcssvalueprivate.h +++ b/gtk/gtkcssvalueprivate.h @@ -76,30 +76,6 @@ char * _gtk_css_value_to_string (const GtkCssValue void _gtk_css_value_print (const GtkCssValue *value, GString *string); -GType _gtk_css_value_get_content_type (const GtkCssValue *value); -gboolean _gtk_css_value_holds (const GtkCssValue *value, - GType type); -GtkCssValue *_gtk_css_value_new_from_gvalue (const GValue *g_value); -GtkCssValue *_gtk_css_value_new_from_int (gint val); -GtkCssValue *_gtk_css_value_new_from_enum (GType type, - gint val); -GtkCssValue *_gtk_css_value_new_take_strv (char **strv); -GtkCssValue *_gtk_css_value_new_from_boxed (GType type, - gpointer boxed); -GtkCssValue *_gtk_css_value_new_from_color (const GdkColor *v); -GtkCssValue *_gtk_css_value_new_take_pattern (cairo_pattern_t *v); -GtkCssValue *_gtk_css_value_new_take_binding_sets (GPtrArray *array); -void _gtk_css_value_init_gvalue (const GtkCssValue *value, - GValue *g_value); - -int _gtk_css_value_get_int (const GtkCssValue *value); -int _gtk_css_value_get_enum (const GtkCssValue *value); -gpointer _gtk_css_value_dup_object (const GtkCssValue *value); -gpointer _gtk_css_value_get_object (const GtkCssValue *value); -gpointer _gtk_css_value_get_boxed (const GtkCssValue *value); -const char ** _gtk_css_value_get_strv (const GtkCssValue *value); -GtkGradient *_gtk_css_value_get_gradient (const GtkCssValue *value); - G_END_DECLS #endif /* __GTK_CSS_VALUE_PRIVATE_H__ */ diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 2b1986fb5a..ebb8d7c258 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -27,8 +27,8 @@ #include "gtksymboliccolor.h" #include "gtkthemingengine.h" #include "gtkgradient.h" -#include "gtkcssshadowvalueprivate.h" #include "gtkcssshorthandpropertyprivate.h" +#include "gtkcsstypedvalueprivate.h" #include "gtkcsstypesprivate.h" #include "gtkborderimageprivate.h" @@ -891,7 +891,7 @@ gtk_style_properties_merge (GtkStyleProperties *props, data = &g_array_index (prop_to_merge->values, ValueData, i); if (replace && data->state == GTK_STATE_FLAG_NORMAL && - _gtk_css_value_holds (data->value, PANGO_TYPE_FONT_DESCRIPTION)) + _gtk_is_css_typed_value_of_type (data->value, PANGO_TYPE_FONT_DESCRIPTION)) { /* Let normal state override all states * previously set in the original set @@ -901,19 +901,19 @@ gtk_style_properties_merge (GtkStyleProperties *props, value = property_data_get_value (prop, data->state); - if (_gtk_css_value_holds (data->value, PANGO_TYPE_FONT_DESCRIPTION) && + if (_gtk_is_css_typed_value_of_type (data->value, PANGO_TYPE_FONT_DESCRIPTION) && value->value != NULL) { PangoFontDescription *font_desc; PangoFontDescription *font_desc_to_merge; /* Handle merging of font descriptions */ - font_desc = _gtk_css_value_get_boxed (value->value); - font_desc_to_merge = _gtk_css_value_get_boxed (data->value); + font_desc = g_value_get_boxed (_gtk_css_typed_value_get (value->value)); + font_desc_to_merge = g_value_get_boxed (_gtk_css_typed_value_get (data->value)); pango_font_description_merge (font_desc, font_desc_to_merge, replace); } - else if (_gtk_css_value_holds (data->value, G_TYPE_PTR_ARRAY) && + else if (_gtk_is_css_typed_value_of_type (data->value, G_TYPE_PTR_ARRAY) && value->value != NULL) { GPtrArray *array, *array_to_merge; @@ -922,8 +922,8 @@ gtk_style_properties_merge (GtkStyleProperties *props, /* Append the array, mainly thought * for the gtk-key-bindings property */ - array = _gtk_css_value_get_boxed (value->value); - array_to_merge = _gtk_css_value_get_boxed (data->value); + array = g_value_get_boxed (_gtk_css_typed_value_get (value->value)); + array_to_merge = g_value_get_boxed (_gtk_css_typed_value_get (data->value)); for (i = 0; i < array_to_merge->len; i++) g_ptr_array_add (array, g_ptr_array_index (array_to_merge, i));