diff options
author | Benjamin Otte <otte@redhat.com> | 2012-01-02 22:22:25 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-01-09 18:37:56 +0100 |
commit | 0bc170cd8457fbb64538851082442f57aa262651 (patch) | |
tree | a1ed60620ce544c5784dd33a6570676d79707401 /gtk/gtkcssstyleproperty.c | |
parent | 2bb899b5c02d09b860e3cebc70511b1a0cfd03a2 (diff) | |
download | gtk+-0bc170cd8457fbb64538851082442f57aa262651.tar.gz |
styleproperty: Convert background-image from pattern to GtkCssImage
Diffstat (limited to 'gtk/gtkcssstyleproperty.c')
-rw-r--r-- | gtk/gtkcssstyleproperty.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c index 4791857243..da1a6b708c 100644 --- a/gtk/gtkcssstyleproperty.c +++ b/gtk/gtkcssstyleproperty.c @@ -28,6 +28,9 @@ #include "gtkprivatetypebuiltins.h" #include "gtkstylepropertiesprivate.h" +#include "gtkcssimagegradientprivate.h" +#include "gtkcssimageprivate.h" + enum { PROP_0, PROP_ID, @@ -131,7 +134,36 @@ _gtk_css_style_property_query (GtkStyleProperty *property, val = _gtk_style_properties_peek_property (props, GTK_CSS_STYLE_PROPERTY (property), state); if (val) - g_value_copy (val, value); + { + /* Somebody make this a vfunc */ + if (G_VALUE_TYPE (val) == GTK_TYPE_CSS_IMAGE) + { + GtkCssImage *image = g_value_get_object (val); + cairo_pattern_t *pattern; + cairo_surface_t *surface; + cairo_matrix_t matrix; + + if (image == NULL) + g_value_set_boxed (value, NULL); + else if (GTK_IS_CSS_IMAGE_GRADIENT (image)) + g_value_set_boxed (value, GTK_CSS_IMAGE_GRADIENT (image)->pattern); + else + { + double width, height; + + /* the 100, 100 is rather random */ + _gtk_css_image_get_concrete_size (image, 0, 0, 100, 100, &width, &height); + surface = _gtk_css_image_get_surface (image, NULL, width, height); + pattern = cairo_pattern_create_for_surface (surface); + cairo_matrix_init_scale (&matrix, width, height); + cairo_pattern_set_matrix (pattern, &matrix); + cairo_surface_destroy (surface); + g_value_take_boxed (value, pattern); + } + } + else + g_value_copy (val, value); + } else _gtk_style_property_default_value (property, props, state, value); } |