diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c index 11f3a80e72..b8eda5fa11 100644 --- a/gtk/gtkcssimage.c +++ b/gtk/gtkcssimage.c @@ -324,7 +324,8 @@ gtk_css_image_get_parser_type (GtkCssParser *parser) { "url", _gtk_css_image_url_get_type }, { "-gtk-gradient", _gtk_css_image_gradient_get_type }, { "-gtk-win32-theme-part", _gtk_css_image_win32_get_type }, - { "linear-gradient", _gtk_css_image_linear_get_type } + { "linear-gradient", _gtk_css_image_linear_get_type }, + { "repeating-linear-gradient", _gtk_css_image_linear_get_type } }; guint i; diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index 890465c454..130f9d9963 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -168,7 +168,10 @@ gtk_css_image_linear_draw (GtkCssImage *image, gtk_css_image_linear_get_start_end (linear, length, &start, &end); pattern = cairo_pattern_create_linear (x * (start - 0.5), y * (start - 0.5), x * (end - 0.5), y * (end - 0.5)); - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); + if (linear->repeating) + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + else + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); offset = start; last = -1; @@ -230,7 +233,11 @@ gtk_css_image_linear_parse (GtkCssImage *image, GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image); guint i; - if (!_gtk_css_parser_try (parser, "linear-gradient(", TRUE)) + if (_gtk_css_parser_try (parser, "repeating-linear-gradient(", TRUE)) + linear->repeating = TRUE; + else if (_gtk_css_parser_try (parser, "linear-gradient(", TRUE)) + linear->repeating = FALSE; + else { _gtk_css_parser_error (parser, "Not a linear gradient"); return FALSE; @@ -356,7 +363,11 @@ gtk_css_image_linear_print (GtkCssImage *image, /* XXX: Do these need to be prinatable? */ g_return_if_fail (!linear->is_computed); - g_string_append (string, "linear-gradient("); + if (linear->repeating) + g_string_append (string, "repeating-linear-gradient("); + else + g_string_append (string, "linear-gradient("); + if (linear->angle.unit == GTK_CSS_NUMBER) { guint side = linear->angle.value; @@ -421,6 +432,7 @@ gtk_css_image_linear_compute (GtkCssImage *image, copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL); copy->is_computed = TRUE; + copy->repeating = linear->repeating; _gtk_css_number_compute (©->angle, &linear->angle, context); diff --git a/gtk/gtkcssimagelinearprivate.h b/gtk/gtkcssimagelinearprivate.h index 67191b1e14..f664c5be5e 100644 --- a/gtk/gtkcssimagelinearprivate.h +++ b/gtk/gtkcssimagelinearprivate.h @@ -51,6 +51,7 @@ struct _GtkCssImageLinear GtkCssNumber angle; /* warning: We use GTK_CSS_NUMBER as an enum for the corners */ GArray *stops; guint is_computed :1; + guint repeating :1; }; struct _GtkCssImageLinearClass