[gtk/css-crossfade-color: 2/3] css: Add a constructor for GtkCssImageFallback




commit 25409c5a5a369968d93ff9fe45146a4abd922836
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 26 21:10:11 2021 -0500

    css: Add a constructor for GtkCssImageFallback
    
    Add a way to create a solid color image.

 gtk/gtkcssimagefallback.c        | 21 ++++++++++++++++-----
 gtk/gtkcssimagefallbackprivate.h |  4 +++-
 2 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssimagefallback.c b/gtk/gtkcssimagefallback.c
index e214172cc0..d6ca07bc98 100644
--- a/gtk/gtkcssimagefallback.c
+++ b/gtk/gtkcssimagefallback.c
@@ -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;
+}
diff --git a/gtk/gtkcssimagefallbackprivate.h b/gtk/gtkcssimagefallbackprivate.h
index 7de1ba96b1..d3313c77f2 100644
--- a/gtk/gtkcssimagefallbackprivate.h
+++ b/gtk/gtkcssimagefallbackprivate.h
@@ -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
 


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