[gtk+] css: Return GArrays from shorthand parsing
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Return GArrays from shorthand parsing
- Date: Wed, 25 Jan 2012 18:06:19 +0000 (UTC)
commit 8da4c2affabd02628f5151abd166f72dfbaa88b1
Author: Benjamin Otte <otte redhat com>
Date: Wed Jan 25 18:28:26 2012 +0100
css: Return GArrays from shorthand parsing
GValueArray is deprecated now.
gtk/gtkcssprovider.c | 7 ++++---
gtk/gtkcssshorthandproperty.c | 20 ++++++++++----------
2 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 5285d29..7d2f183 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1194,17 +1194,18 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
if (GTK_IS_CSS_SHORTHAND_PROPERTY (prop))
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (prop);
- GValueArray *array = g_value_get_boxed (&value->value);
+ GArray *array = g_value_get_boxed (&value->value);
guint i;
for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
{
GtkCssStyleProperty *child = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
+ const GValue *sub = &g_array_index (array, GValue, i);
PropertyValue *val;
val = property_value_new (value->section);
- g_value_init (&val->value, G_VALUE_TYPE (g_value_array_get_nth (array, i)));
- g_value_copy (g_value_array_get_nth (array, i), &val->value);
+ g_value_init (&val->value, G_VALUE_TYPE (sub));
+ g_value_copy (sub, &val->value);
gtk_css_ruleset_add (ruleset, GTK_STYLE_PROPERTY (child), val);
}
property_value_free (value);
diff --git a/gtk/gtkcssshorthandproperty.c b/gtk/gtkcssshorthandproperty.c
index 303376e..c74ddae 100644
--- a/gtk/gtkcssshorthandproperty.c
+++ b/gtk/gtkcssshorthandproperty.c
@@ -91,12 +91,12 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
GFile *base)
{
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
- GValueArray *array;
+ GArray *array;
guint i;
- array = g_value_array_new (shorthand->subproperties->len);
- for (i = 0; i < shorthand->subproperties->len; i++)
- g_value_array_append (array, NULL);
+ array = g_array_new (FALSE, TRUE, sizeof (GValue));
+ g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
+ g_array_set_size (array, shorthand->subproperties->len);
if (_gtk_css_parser_try (parser, "initial", TRUE))
{
@@ -105,7 +105,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
*/
for (i = 0; i < shorthand->subproperties->len; i++)
{
- GValue *val = g_value_array_get_nth (array, i);
+ GValue *val = &g_array_index (array, GValue, i);
g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
g_value_set_enum (val, GTK_CSS_INITIAL);
}
@@ -120,14 +120,14 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
*/
for (i = 0; i < shorthand->subproperties->len; i++)
{
- GValue *val = g_value_array_get_nth (array, i);
+ GValue *val = &g_array_index (array, GValue, i);
g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
g_value_set_enum (val, GTK_CSS_INHERIT);
}
}
- else if (!shorthand->parse (shorthand, array->values, parser, base))
+ else if (!shorthand->parse (shorthand, (GValue *) array->data, parser, base))
{
- g_value_array_free (array);
+ g_array_free (array, TRUE);
return FALSE;
}
@@ -136,14 +136,14 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
* XXX: Is the default always initial or can it be inherit? */
for (i = 0; i < shorthand->subproperties->len; i++)
{
- GValue *val = g_value_array_get_nth (array, i);
+ GValue *val = &g_array_index (array, GValue, i);
if (G_IS_VALUE (val))
continue;
g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
g_value_set_enum (val, GTK_CSS_INITIAL);
}
- g_value_init (value, G_TYPE_VALUE_ARRAY);
+ g_value_init (value, G_TYPE_ARRAY);
g_value_take_boxed (value, array);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]