css: Add a constructor for GtkCssImageFallback

Add a way to create a solid color image.
This commit is contained in:
Matthias Clasen 2021-01-26 21:10:11 -05:00
parent 51122dd287
commit 25409c5a5a
2 changed files with 19 additions and 6 deletions

View File

@ -148,11 +148,11 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
GtkCssValue *computed_color = NULL;
if (fallback->color)
computed_color= _gtk_css_value_compute (fallback->color,
property_id,
provider,
style,
parent_style);
computed_color = _gtk_css_value_compute (fallback->color,
property_id,
provider,
style,
parent_style);
/* image($color) that didn't change */
if (computed_color && !fallback->images &&
@ -331,3 +331,14 @@ _gtk_css_image_fallback_init (GtkCssImageFallback *image_fallback)
{
image_fallback->used = -1;
}
GtkCssImage *
_gtk_css_image_fallback_new_for_color (GtkCssValue *color)
{
GtkCssImageFallback *image;
image = g_object_new (GTK_TYPE_CSS_IMAGE_FALLBACK, NULL);
image->color = gtk_css_value_ref (color);
return (GtkCssImage *)image;
}

View File

@ -52,7 +52,9 @@ struct _GtkCssImageFallbackClass
GtkCssImageClass parent_class;
};
GType _gtk_css_image_fallback_get_type (void) G_GNUC_CONST;
GType _gtk_css_image_fallback_get_type (void) G_GNUC_CONST;
GtkCssImage *_gtk_css_image_fallback_new_for_color (GtkCssValue *color);
G_END_DECLS