diff options
Diffstat (limited to 'gtk/gtkcssarrayvalue.c')
-rw-r--r-- | gtk/gtkcssarrayvalue.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/gtk/gtkcssarrayvalue.c b/gtk/gtkcssarrayvalue.c index 4a52ef84db..985d195762 100644 --- a/gtk/gtkcssarrayvalue.c +++ b/gtk/gtkcssarrayvalue.c @@ -40,6 +40,33 @@ gtk_css_value_array_free (GtkCssValue *value) g_slice_free1 (sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (value->n_values - 1), value); } +static GtkCssValue * +gtk_css_value_array_compute (GtkCssValue *value, + GtkStyleContext *context) +{ + GtkCssValue *result; + gboolean changed = FALSE; + guint i; + + if (value->n_values == 0) + return _gtk_css_value_ref (value); + + result = _gtk_css_array_value_new_from_array (value->values, value->n_values); + for (i = 0; i < value->n_values; i++) + { + result->values[i] = _gtk_css_value_compute (value->values[i], context); + changed |= (result->values[i] != value->values[i]); + } + + if (!changed) + { + _gtk_css_value_unref (result); + return _gtk_css_value_ref (value); + } + + return result; +} + static gboolean gtk_css_value_array_equal (const GtkCssValue *value1, const GtkCssValue *value2) @@ -89,6 +116,7 @@ gtk_css_value_array_print (const GtkCssValue *value, static const GtkCssValueClass GTK_CSS_VALUE_ARRAY = { gtk_css_value_array_free, + gtk_css_value_array_compute, gtk_css_value_array_equal, gtk_css_value_array_transition, gtk_css_value_array_print @@ -154,37 +182,6 @@ _gtk_css_array_value_parse (GtkCssParser *parser, } GtkCssValue * -_gtk_css_array_value_compute (GtkCssValue *value, - GtkCssValue * (* compute_func) (GtkCssValue *, GtkStyleContext *), - GtkStyleContext *context) -{ - GtkCssValue *result; - gboolean changed = FALSE; - guint i; - - g_return_val_if_fail (value->class == >K_CSS_VALUE_ARRAY, NULL); - g_return_val_if_fail (compute_func != NULL, NULL); - - if (value->n_values == 0) - return _gtk_css_value_ref (value); - - result = _gtk_css_array_value_new_from_array (value->values, value->n_values); - for (i = 0; i < value->n_values; i++) - { - result->values[i] = (* compute_func) (value->values[i], context); - changed |= (result->values[i] != value->values[i]); - } - - if (!changed) - { - _gtk_css_value_unref (result); - return _gtk_css_value_ref (value); - } - - return result; -} - -GtkCssValue * _gtk_css_array_value_get_nth (const GtkCssValue *value, guint i) { |