diff options
author | Benjamin Otte <otte@redhat.com> | 2011-12-31 16:31:25 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-01-09 18:37:52 +0100 |
commit | 2128b356b2b2e9b14d1a33ef29bd435f1a52c153 (patch) | |
tree | c5d2bddc9f044ddc126bdac36fda50ce404484a6 /gtk/gtkcssshorthandproperty.c | |
parent | 4383701e258fcda37d980d5bd3114f028e567550 (diff) | |
download | gtk+-2128b356b2b2e9b14d1a33ef29bd435f1a52c153.tar.gz |
shorthand: Add a property for all subproperties
Diffstat (limited to 'gtk/gtkcssshorthandproperty.c')
-rw-r--r-- | gtk/gtkcssshorthandproperty.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gtk/gtkcssshorthandproperty.c b/gtk/gtkcssshorthandproperty.c index 6c29a69049..64c8633d03 100644 --- a/gtk/gtkcssshorthandproperty.c +++ b/gtk/gtkcssshorthandproperty.c @@ -22,15 +22,80 @@ #include "gtkcssshorthandpropertyprivate.h" +#include "gtkintl.h" + +enum { + PROP_0, + PROP_SUBPROPERTIES, +}; + G_DEFINE_TYPE (GtkCssShorthandProperty, _gtk_css_shorthand_property, GTK_TYPE_STYLE_PROPERTY) static void +gtk_css_shorthand_property_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkCssShorthandProperty *property = GTK_CSS_SHORTHAND_PROPERTY (object); + const char **subproperties; + guint i; + + switch (prop_id) + { + case PROP_SUBPROPERTIES: + subproperties = g_value_get_boxed (value); + g_assert (subproperties); + for (i = 0; subproperties[i] != NULL; i++) + { + GtkStyleProperty *subproperty = _gtk_style_property_lookup (subproperties[i]); + g_assert (GTK_IS_CSS_STYLE_PROPERTY (subproperty)); + g_ptr_array_add (property->subproperties, subproperty); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void _gtk_css_shorthand_property_class_init (GtkCssShorthandPropertyClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = gtk_css_shorthand_property_set_property; + + g_object_class_install_property (object_class, + PROP_SUBPROPERTIES, + g_param_spec_boxed ("subproperties", + P_("Subproperties"), + P_("The list of subproperties"), + G_TYPE_STRV, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); } static void _gtk_css_shorthand_property_init (GtkCssShorthandProperty *shorthand) { + shorthand->subproperties = g_ptr_array_new_with_free_func (g_object_unref); +} + +GtkCssStyleProperty * +_gtk_css_shorthand_property_get_subproperty (GtkCssShorthandProperty *shorthand, + guint property) +{ + g_return_val_if_fail (GTK_IS_CSS_SHORTHAND_PROPERTY (shorthand), NULL); + g_return_val_if_fail (property < shorthand->subproperties->len, NULL); + + return g_ptr_array_index (shorthand->subproperties, property); +} + +guint +_gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand) +{ + g_return_val_if_fail (GTK_IS_CSS_SHORTHAND_PROPERTY (shorthand), 0); + + return shorthand->subproperties->len; } |