[gtksourceview/wip/chergert/gsv-gtk4: 87/175] markattributes: port to GTK 4



commit 0d7d4ddbbfb57e3d0ec4675b82b3abad96d5f9f1
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 15 14:23:55 2020 -0800

    markattributes: port to GTK 4
    
     - Use GdkPaintable instead of GdkPixbuf for better GPU caching

 gtksourceview/gtksourcemarkattributes.c | 16 +++++++++++-----
 gtksourceview/gtksourcemarkattributes.h |  2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/gtksourceview/gtksourcemarkattributes.c b/gtksourceview/gtksourcemarkattributes.c
index 6a2f7058..24f65d73 100644
--- a/gtksourceview/gtksourcemarkattributes.c
+++ b/gtksourceview/gtksourcemarkattributes.c
@@ -529,21 +529,27 @@ gtk_source_mark_attributes_get_pixbuf (GtkSourceMarkAttributes *attributes)
  * gtk_source_mark_attributes_set_gicon() or
  * gtk_source_mark_attributes_set_icon_name(). @size cannot be lower than 1.
  *
- * Returns: (transfer none): A rendered pixbuf. The pixbuf belongs to @attributes
+ * Returns: (transfer none): A #GdkPaintable. The paintable belongs to @attributes
  * and should not be unreffed.
  */
-const GdkPixbuf *
+GdkPaintable *
 gtk_source_mark_attributes_render_icon (GtkSourceMarkAttributes *attributes,
                                         GtkWidget               *widget,
                                         gint                     size)
 {
+       GdkPaintable *ret;
+
        g_return_val_if_fail (GTK_SOURCE_IS_MARK_ATTRIBUTES (attributes), NULL);
        g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
        g_return_val_if_fail (size > 0, NULL);
 
-       return gtk_source_pixbuf_helper_render (attributes->helper,
-                                               widget,
-                                               size);
+       ret = gtk_source_pixbuf_helper_render (attributes->helper,
+                                              widget,
+                                              size);
+
+       g_return_val_if_fail (ret == NULL || GDK_IS_PAINTABLE (ret), NULL);
+
+       return ret;
 }
 
 /**
diff --git a/gtksourceview/gtksourcemarkattributes.h b/gtksourceview/gtksourcemarkattributes.h
index 29cb0c85..867d9392 100644
--- a/gtksourceview/gtksourcemarkattributes.h
+++ b/gtksourceview/gtksourcemarkattributes.h
@@ -60,7 +60,7 @@ void                     gtk_source_mark_attributes_set_pixbuf         (GtkSourc
 GTK_SOURCE_AVAILABLE_IN_ALL
 const GdkPixbuf         *gtk_source_mark_attributes_get_pixbuf         (GtkSourceMarkAttributes *attributes);
 GTK_SOURCE_AVAILABLE_IN_ALL
-const GdkPixbuf         *gtk_source_mark_attributes_render_icon        (GtkSourceMarkAttributes *attributes,
+GdkPaintable            *gtk_source_mark_attributes_render_icon        (GtkSourceMarkAttributes *attributes,
                                                                         GtkWidget               *widget,
                                                                         gint                     size);
 GTK_SOURCE_AVAILABLE_IN_ALL


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