[gtk+/wip/multiple-backgrounds: 5/15] styleproperty: make background-image an array value



commit 9c30ad6d925baeeae89d84f2edfcfdad53112aca
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu May 10 11:18:29 2012 -0400

    styleproperty: make background-image an array value
    
    This also requires having the GtkCssArrayValue parse func forward the
    base GFile from the style property parse implementation.

 gtk/gtkcssstylepropertyimpl.c |   53 +++++++++++++++++++++++++++++++++++++----
 gtk/gtkthemingbackground.c    |    2 +-
 2 files changed, 49 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index ad60d93..6cf1d03 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -617,6 +617,49 @@ css_image_value_assign (GtkCssStyleProperty *property,
 }
 
 static GtkCssValue *
+background_image_value_parse_one (GtkCssParser *parser)
+{
+  return css_image_value_parse (NULL, parser);
+}
+
+static GtkCssValue *
+background_image_value_parse (GtkCssStyleProperty *property,
+                              GtkCssParser        *parser)
+{
+  return _gtk_css_array_value_parse (parser, background_image_value_parse_one, FALSE);
+}
+
+static GtkCssValue *
+background_image_value_compute_one (GtkCssValue     *value,
+                                    GtkStyleContext *context)
+{
+  return css_image_value_compute (NULL, context, value);
+}
+
+static GtkCssValue *
+background_image_value_compute (GtkCssStyleProperty    *property,
+                                GtkStyleContext        *context,
+                                GtkCssValue            *specified)
+{
+  return _gtk_css_array_value_compute (specified, background_image_value_compute_one, context);
+}
+
+static void
+background_image_value_query (GtkCssStyleProperty *property,
+                              const GtkCssValue   *css_value,
+                              GValue              *value)
+{
+  css_image_value_query (property, _gtk_css_array_value_get_nth (css_value, 0), value);
+}
+
+static GtkCssValue *
+background_image_value_assign (GtkCssStyleProperty *property,
+                               const GValue        *value)
+{
+  return _gtk_css_array_value_new (css_image_value_assign (property, value));
+}
+
+static GtkCssValue *
 font_size_parse (GtkCssStyleProperty *property,
                  GtkCssParser        *parser)
 {
@@ -1374,12 +1417,12 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
                                           CAIRO_GOBJECT_TYPE_PATTERN,
                                           GTK_STYLE_PROPERTY_ANIMATED,
-                                          css_image_value_parse,
+                                          background_image_value_parse,
                                           NULL,
-                                          css_image_value_compute,
-                                          css_image_value_query,
-                                          css_image_value_assign,
-                                          _gtk_css_image_value_new (NULL));
+                                          background_image_value_compute,
+                                          background_image_value_query,
+                                          background_image_value_assign,
+                                          _gtk_css_array_value_new (_gtk_css_image_value_new (NULL)));
 
   gtk_css_style_property_register        ("border-image-source",
                                           GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
diff --git a/gtk/gtkthemingbackground.c b/gtk/gtkthemingbackground.c
index 4bc5d5e..ead7518 100644
--- a/gtk/gtkthemingbackground.c
+++ b/gtk/gtkthemingbackground.c
@@ -292,7 +292,7 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg)
   _gtk_theming_background_apply_clip (bg);
   _gtk_theming_background_apply_origin (bg);
 
-  bg->image = _gtk_css_image_value_get_image (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE));
+  bg->image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE), 0));
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]