[balsa/gtk4: 270/312] files: Return a pixbuf




commit 9ad3e0d21df982e84ab4f17103db623f72da58fe
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Nov 18 10:31:53 2020 -0500

    files: Return a pixbuf

 libbalsa/files.c | 22 ++++++++++++++++------
 libbalsa/files.h |  6 +++---
 2 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/libbalsa/files.c b/libbalsa/files.c
index fd16a32fe..1a2923c87 100644
--- a/libbalsa/files.c
+++ b/libbalsa/files.c
@@ -98,13 +98,16 @@ libbalsa_default_attachment_icon(void)
  *   non-NULL, 'mime-type' has priority.  If both are NULL, the default
  *   'attachment.png' icon will be returned.
  */
-GIcon *
+GdkPixbuf *
 libbalsa_icon_finder(const char        * mime_type,
                      const LibbalsaVfs * for_file,
                      char             ** used_type)
 {
     const gchar *content_type;
-    GIcon *gicon;
+    GIcon *icon;
+    GtkWidget *image;
+    GdkPaintable *paintable;
+    GdkPixbuf *pixbuf;
 
     if (mime_type)
         content_type = mime_type;
@@ -113,17 +116,24 @@ libbalsa_icon_finder(const char        * mime_type,
     } else
         content_type = "application/octet-stream";
 
-    gicon = g_content_type_get_icon(content_type);
+    icon = g_content_type_get_icon(content_type);
 
-    if (gicon == NULL) {
+    if (icon == NULL) {
         /* load the default icon */
-        gicon = libbalsa_default_attachment_icon();
+        icon = libbalsa_default_attachment_icon();
     }
 
+    image = gtk_image_new_from_gicon(icon);
+    g_object_unref(icon);
+
+    paintable = gtk_image_get_paintable(GTK_IMAGE(image));
+    pixbuf = gdk_pixbuf_get_from_texture(GDK_TEXTURE(paintable));
+    g_object_unref(g_object_ref_sink(image));
+
     if (used_type)
         *used_type = g_strdup(content_type);
 
-    return gicon;
+    return pixbuf;
 }
 
 
diff --git a/libbalsa/files.h b/libbalsa/files.h
index 415de7e0b..c34b401de 100644
--- a/libbalsa/files.h
+++ b/libbalsa/files.h
@@ -39,9 +39,9 @@ gchar *balsa_file_finder(const char * filename,
 
 #define balsa_pixmap_finder(filename) (balsa_file_finder((filename), "pixmaps"))
 
-GIcon * libbalsa_icon_finder(const char        * mime_type,
-                             const LibbalsaVfs * for_file,
-                             gchar            ** used_type);
+GdkPixbuf * libbalsa_icon_finder(const char        * mime_type,
+                                 const LibbalsaVfs * for_file,
+                                 char             ** used_type);
 char * libbalsa_icon_name_finder(const char        * mime_type,
                                  const LibbalsaVfs * for_file,
                                  char             ** used_type);


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