summaryrefslogtreecommitdiff
path: root/gtk/gtkstyleproperties.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-12-31 17:58:30 +0100
committerBenjamin Otte <otte@redhat.com>2012-01-09 18:37:52 +0100
commitc9dc9d5a88e21c31a4608144fe22be25e31ba078 (patch)
tree99885c8a9e22315b0c7f6ddf76118bccd8b9e282 /gtk/gtkstyleproperties.c
parent7a4bbc8f35b65ed5f3447ca880dde140fd62e7de (diff)
downloadgtk+-c9dc9d5a88e21c31a4608144fe22be25e31ba078.tar.gz
styleproperties: Use _gtk_style_property_get_value_type()
... and check the case where the property is not get/settable.
Diffstat (limited to 'gtk/gtkstyleproperties.c')
-rw-r--r--gtk/gtkstyleproperties.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index cd325ae76c..1c39f0ac68 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -528,13 +528,14 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
{
GtkStylePropertiesPrivate *priv;
PropertyData *prop;
- GType value_type;
+ GType value_type, style_prop_type;
GValue *val;
value_type = G_VALUE_TYPE (value);
+ style_prop_type = _gtk_style_property_get_value_type (style_prop);
- if (style_prop->pspec->value_type == GDK_TYPE_RGBA ||
- style_prop->pspec->value_type == GDK_TYPE_COLOR)
+ if (style_prop_type == GDK_TYPE_RGBA ||
+ style_prop_type == GDK_TYPE_COLOR)
{
/* Allow GtkSymbolicColor and special values as well */
g_return_if_fail (value_type == GDK_TYPE_RGBA ||
@@ -542,20 +543,20 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
value_type == GTK_TYPE_CSS_SPECIAL_VALUE ||
value_type == GTK_TYPE_SYMBOLIC_COLOR);
}
- else if (style_prop->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN)
+ else if (style_prop_type == CAIRO_GOBJECT_TYPE_PATTERN)
{
/* Allow GtkGradient and theme part as a substitute */
g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN ||
value_type == GTK_TYPE_GRADIENT ||
value_type == GTK_TYPE_WIN32_THEME_PART);
}
- else if (style_prop->pspec->value_type == G_TYPE_INT)
+ else if (style_prop_type == G_TYPE_INT)
{
g_return_if_fail (value_type == G_TYPE_INT ||
value_type == GTK_TYPE_CSS_BORDER_RADIUS);
}
else
- g_return_if_fail (style_prop->pspec->value_type == value_type);
+ g_return_if_fail (style_prop_type == value_type);
if (GTK_IS_CSS_SHORTHAND_PROPERTY (style_prop))
{
@@ -598,7 +599,7 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
}
g_value_copy (value, val);
- if (style_prop->pspec->value_type == value_type)
+ if (style_prop_type == value_type)
g_param_value_validate (style_prop->pspec, val);
}
@@ -664,6 +665,7 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
{
GtkStyleProperty *node;
gchar *error = NULL;
+ GType val_type;
GValue val = G_VALUE_INIT;
node = _gtk_style_property_lookup (property_name);
@@ -674,7 +676,14 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
break;
}
- G_VALUE_COLLECT_INIT (&val, node->pspec->value_type,
+ val_type = _gtk_style_property_get_value_type (node);
+ if (val_type == G_TYPE_NONE)
+ {
+ g_warning ("Style property \"%s\" is not settable", property_name);
+ break;
+ }
+
+ G_VALUE_COLLECT_INIT (&val, _gtk_style_property_get_value_type (node),
args, 0, &error);
if (error)
{
@@ -753,6 +762,11 @@ _gtk_style_properties_get_property (GtkStyleProperties *props,
g_warning ("Style property \"%s\" is not registered", property);
return FALSE;
}
+ if (_gtk_style_property_get_value_type (node) == G_TYPE_NONE)
+ {
+ g_warning ("Style property \"%s\" is not gettable", property);
+ return FALSE;
+ }
_gtk_style_property_query (node, props, state, context, value);
return TRUE;