[gtk/wip/baedert/icontheme2] icontheme: Return paintables from more non-symbolic API



commit 0045cf961421730e3a15d9fb857bb5b5897ed9ae
Author: Timm Bäder <mail baedert org>
Date:   Fri Aug 30 21:26:21 2019 +0200

    icontheme: Return paintables from more non-symbolic API

 gtk/gtkicontheme.c        | 41 +++++++++++++++++++++++++++--------------
 gtk/gtkicontheme.h        | 22 +++++++++++-----------
 tests/testicontheme.c     | 12 ++++++------
 testsuite/gtk/icontheme.c | 16 ++++++++--------
 4 files changed, 52 insertions(+), 39 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 46fd37ba84..c5b9c722f8 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3942,13 +3942,14 @@ gtk_icon_info_load_icon_async (GtkIconInfo         *icon_info,
  *     not modify the icon. Use g_object_unref() to release your reference
  *     to the icon.
  */
-GdkPixbuf *
+GdkPaintable *
 gtk_icon_info_load_icon_finish (GtkIconInfo   *icon_info,
                                 GAsyncResult  *result,
                                 GError       **error)
 {
   GTask *task = G_TASK (result);
   GtkIconInfo *dup;
+  GdkTexture *texture;
 
   g_return_val_if_fail (g_task_is_valid (result, icon_info), NULL);
 
@@ -3974,7 +3975,12 @@ gtk_icon_info_load_icon_finish (GtkIconInfo   *icon_info,
   g_assert (icon_info_get_pixbuf_ready (icon_info));
 
   /* This is now guaranteed to not block */
-  return gtk_icon_info_load_icon (icon_info, error);
+  texture = gtk_icon_info_load_texture (icon_info, error);
+
+  if (texture)
+    return GDK_PAINTABLE (texture);
+
+  return NULL;
 }
 
 static void
@@ -4530,13 +4536,13 @@ async_load_no_symbolic_cb (GObject      *source_object,
   GtkIconInfo *icon_info = GTK_ICON_INFO (source_object);
   GTask *task = user_data;
   GError *error = NULL;
-  GdkPixbuf *pixbuf;
+  GdkPaintable *paintable;
 
-  pixbuf = gtk_icon_info_load_icon_finish (icon_info, res, &error);
-  if (pixbuf == NULL)
+  paintable = gtk_icon_info_load_icon_finish (icon_info, res, &error);
+  if (paintable == NULL)
     g_task_return_error (task, error);
   else
-    g_task_return_pointer (task, pixbuf, g_object_unref);
+    g_task_return_pointer (task, paintable, g_object_unref);
   g_object_unref (task);
 }
 
@@ -4669,12 +4675,11 @@ gtk_icon_info_load_symbolic_async (GtkIconInfo          *icon_info,
  *
  * Finishes an async icon load, see gtk_icon_info_load_symbolic_async().
  *
- * Returns: (transfer full): the rendered icon; this may be a newly
- *     created icon or a new reference to an internal icon, so you must
- *     not modify the icon. Use g_object_unref() to release your reference
- *     to the icon.
+ * Returns: (transfer full): the rendered icon;
+ *  Use g_object_unref() to release your reference
+ *  to the icon.
  */
-GdkPixbuf *
+GdkPaintable *
 gtk_icon_info_load_symbolic_finish (GtkIconInfo   *icon_info,
                                     GAsyncResult  *result,
                                     gboolean      *was_symbolic,
@@ -4684,6 +4689,7 @@ gtk_icon_info_load_symbolic_finish (GtkIconInfo   *icon_info,
   AsyncSymbolicData *data = g_task_get_task_data (task);
   SymbolicPixbufCache *symbolic_cache;
   GdkPixbuf *pixbuf;
+  GdkTexture *texture;
 
   if (was_symbolic)
     *was_symbolic = data->is_symbolic;
@@ -4713,10 +4719,17 @@ gtk_icon_info_load_symbolic_finish (GtkIconInfo   *icon_info,
 
       g_object_unref (pixbuf);
 
-      return symbolic_cache_get_proxy (symbolic_cache, icon_info);
+      pixbuf = symbolic_cache_get_proxy (symbolic_cache, icon_info);
+    }
+  else
+    {
+      pixbuf = g_task_propagate_pointer (task, error);
     }
 
-  return g_task_propagate_pointer (task, error);
+  texture = gdk_texture_new_for_pixbuf (pixbuf);
+  g_object_unref (pixbuf);
+
+  return GDK_PAINTABLE (texture);
 }
 
 /**
@@ -4777,7 +4790,7 @@ gtk_icon_info_load_symbolic_for_context_async (GtkIconInfo         *icon_info,
  *     not modify the icon. Use g_object_unref() to release your reference
  *     to the icon.
  */
-GdkPixbuf *
+GdkPaintable *
 gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo   *icon_info,
                                                 GAsyncResult  *result,
                                                 gboolean      *was_symbolic,
diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h
index bf4588ff2b..f3d6bffd89 100644
--- a/gtk/gtkicontheme.h
+++ b/gtk/gtkicontheme.h
@@ -234,9 +234,9 @@ void                  gtk_icon_info_load_icon_async   (GtkIconInfo          *ico
                                                       GAsyncReadyCallback   callback,
                                                       gpointer              user_data);
 GDK_AVAILABLE_IN_ALL
-GdkPixbuf *           gtk_icon_info_load_icon_finish  (GtkIconInfo          *icon_info,
-                                                      GAsyncResult         *res,
-                                                      GError              **error);
+GdkPaintable *        gtk_icon_info_load_icon_finish  (GtkIconInfo          *icon_info,
+                                                       GAsyncResult         *res,
+                                                       GError              **error);
 GDK_AVAILABLE_IN_ALL
 GdkPixbuf *           gtk_icon_info_load_symbolic      (GtkIconInfo   *icon_info,
                                                         const GdkRGBA *fg,
@@ -255,10 +255,10 @@ void                  gtk_icon_info_load_symbolic_async (GtkIconInfo   *icon_inf
                                                         GAsyncReadyCallback   callback,
                                                         gpointer              user_data);
 GDK_AVAILABLE_IN_ALL
-GdkPixbuf *           gtk_icon_info_load_symbolic_finish (GtkIconInfo   *icon_info,
-                                                         GAsyncResult         *res,
-                                                         gboolean      *was_symbolic,
-                                                         GError       **error);
+GdkPaintable *        gtk_icon_info_load_symbolic_finish (GtkIconInfo   *icon_info,
+                                                          GAsyncResult  *res,
+                                                          gboolean      *was_symbolic,
+                                                          GError       **error);
 GDK_AVAILABLE_IN_ALL
 GdkPixbuf *           gtk_icon_info_load_symbolic_for_context (GtkIconInfo      *icon_info,
                                                                GtkStyleContext  *context,
@@ -271,10 +271,10 @@ void                  gtk_icon_info_load_symbolic_for_context_async (GtkIconInfo
                                                                     GAsyncReadyCallback callback,
                                                                     gpointer          user_data);
 GDK_AVAILABLE_IN_ALL
-GdkPixbuf *           gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo      *icon_info,
-                                                                     GAsyncResult     *res,
-                                                                     gboolean         *was_symbolic,
-                                                                     GError          **error);
+GdkPaintable *        gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo      *icon_info,
+                                                                      GAsyncResult     *res,
+                                                                      gboolean         *was_symbolic,
+                                                                      GError          **error);
 
 
 G_END_DECLS
diff --git a/tests/testicontheme.c b/tests/testicontheme.c
index 44a9599aaf..96cf65c1ff 100644
--- a/tests/testicontheme.c
+++ b/tests/testicontheme.c
@@ -39,21 +39,21 @@ icon_loaded_cb (GObject *source_object,
                GAsyncResult *res,
                gpointer user_data)
 {
-  GdkPixbuf *pixbuf;
+  GdkPaintable *paintable;
   GError *error;
 
   error = NULL;
-  pixbuf = gtk_icon_info_load_icon_finish (GTK_ICON_INFO (source_object),
-                                          res, &error);
+  paintable = gtk_icon_info_load_icon_finish (GTK_ICON_INFO (source_object),
+                                              res, &error);
 
-  if (pixbuf == NULL)
+  if (paintable == NULL)
     {
       g_print ("%s\n", error->message);
       exit (1);
     }
 
-  gtk_image_set_from_pixbuf (GTK_IMAGE (user_data), pixbuf);
-  g_object_unref (pixbuf);
+  gtk_image_set_from_paintable (GTK_IMAGE (user_data), paintable);
+  g_object_unref (paintable);
 }
 
 
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index 21e482477f..36a43687ae 100644
--- a/testsuite/gtk/icontheme.c
+++ b/testsuite/gtk/icontheme.c
@@ -598,12 +598,12 @@ load_icon (GObject      *source,
 {
   GtkIconInfo *info = (GtkIconInfo *)source;
   GError *error = NULL;
-  GdkPixbuf *pixbuf;
+  GdkPaintable *paintable;
 
-  pixbuf = gtk_icon_info_load_icon_finish (info, res, &error);
-  g_assert (pixbuf != NULL);
+  paintable = gtk_icon_info_load_icon_finish (info, res, &error);
+  g_assert (paintable != NULL);
   g_assert_no_error (error);
-  g_object_unref (pixbuf);
+  g_object_unref (paintable);
 
   loaded++;
 }
@@ -616,12 +616,12 @@ load_symbolic (GObject      *source,
   GtkIconInfo *info = (GtkIconInfo *)source;
   GError *error = NULL;
   gboolean symbolic;
-  GdkPixbuf *pixbuf;
+  GdkPaintable *paintable;
 
-  pixbuf = gtk_icon_info_load_symbolic_finish (info, res, &symbolic, &error);
-  g_assert (pixbuf != NULL);
+  paintable = gtk_icon_info_load_symbolic_finish (info, res, &symbolic, &error);
+  g_assert (paintable != NULL);
   g_assert_no_error (error);
-  g_object_unref (pixbuf);
+  g_object_unref (paintable);
 
   loaded++;
 }


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