[gtk+/wip/otte/clipboard: 98/102] clipboard: Change image convenience APIs



commit 30a121945c6f28e6e64f3f308183b3c248657381
Author: Benjamin Otte <otte redhat com>
Date:   Sat Dec 2 14:38:57 2017 +0100

    clipboard: Change image convenience APIs
    
    Don't use pixbufs anymore, use textures.

 gdk/gdkclipboard.c     |   49 ++++++++++++++++++++++++-----------------------
 gdk/gdkclipboard.h     |   10 ++++----
 tests/testclipboard2.c |   20 +++++++++---------
 3 files changed, 40 insertions(+), 39 deletions(-)
---
diff --git a/gdk/gdkclipboard.c b/gdk/gdkclipboard.c
index 1e723d3..94e2247 100644
--- a/gdk/gdkclipboard.c
+++ b/gdk/gdkclipboard.c
@@ -28,6 +28,7 @@
 #include "gdkdisplay.h"
 #include "gdkintl.h"
 #include "gdkpipeiostreamprivate.h"
+#include "gdktexture.h"
 
 typedef struct _GdkClipboardPrivate GdkClipboardPrivate;
 
@@ -859,7 +860,7 @@ gdk_clipboard_read_value_finish (GdkClipboard  *clipboard,
 }
 
 /**
- * gdk_clipboard_read_pixbuf_async:
+ * gdk_clipboard_read_texture_async:
  * @clipboard: a #GdkClipboard
  * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore.
  * @callback: (scope async): callback to call when the request is satisfied
@@ -867,25 +868,25 @@ gdk_clipboard_read_value_finish (GdkClipboard  *clipboard,
  *
  * Asynchronously request the @clipboard contents converted to a #GdkPixbuf.
  * When the operation is finished @callback will be called. You can then
- * call gdk_clipboard_read_pixbuf_finish() to get the result.
+ * call gdk_clipboard_read_texture_finish() to get the result.
  *
  * This is a simple wrapper around gdk_clipboard_read_value_async(). Use
  * that function or gdk_clipboard_read_async() directly if you need more
  * control over the operation.
  **/
 void
-gdk_clipboard_read_pixbuf_async (GdkClipboard        *clipboard,
-                                 GCancellable        *cancellable,
-                                 GAsyncReadyCallback  callback,
-                                 gpointer             user_data)
+gdk_clipboard_read_texture_async (GdkClipboard        *clipboard,
+                                  GCancellable        *cancellable,
+                                  GAsyncReadyCallback  callback,
+                                  gpointer             user_data)
 {
   g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
   g_return_if_fail (callback != NULL);
 
   gdk_clipboard_read_value_internal (clipboard,
-                                     GDK_TYPE_PIXBUF,
-                                     gdk_clipboard_read_pixbuf_async,
+                                     GDK_TYPE_TEXTURE,
+                                     gdk_clipboard_read_texture_async,
                                      G_PRIORITY_DEFAULT,
                                      cancellable,
                                      callback,
@@ -893,26 +894,26 @@ gdk_clipboard_read_pixbuf_async (GdkClipboard        *clipboard,
 }
 
 /**
- * gdk_clipboard_read_pixbuf_finish:
+ * gdk_clipboard_read_texture_finish:
  * @clipboard: a #GdkClipboard
  * @result: a #GAsyncResult
  * @error: a #GError location to store the error occurring, or %NULL to 
  * ignore.
  *
  * Finishes an asynchronous clipboard read started with
- * gdk_clipboard_read_pixbuf_async().
+ * gdk_clipboard_read_texture_async().
  *
- * Returns: (transfer full) (nullable): a new #GdkPixbuf or %NULL on error.
+ * Returns: (transfer full) (nullable): a new #GdkTexture or %NULL on error.
  **/
-GdkPixbuf *
-gdk_clipboard_read_pixbuf_finish (GdkClipboard  *clipboard,
-                                  GAsyncResult  *res,
-                                  GError       **error)
+GdkTexture *
+gdk_clipboard_read_texture_finish (GdkClipboard  *clipboard,
+                                   GAsyncResult  *res,
+                                   GError       **error)
 {
   const GValue *value;
 
   g_return_val_if_fail (g_task_is_valid (res, clipboard), NULL);
-  g_return_val_if_fail (g_task_get_source_tag (G_TASK (res)) == gdk_clipboard_read_pixbuf_async, NULL);
+  g_return_val_if_fail (g_task_get_source_tag (G_TASK (res)) == gdk_clipboard_read_texture_async, NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   value = g_task_propagate_pointer (G_TASK (res), error);
@@ -1234,24 +1235,24 @@ gdk_clipboard_set_text (GdkClipboard *clipboard,
 }
 
 /**
- * gdk_clipboard_set_pixbuf:
+ * gdk_clipboard_set_texture:
  * @clipboard: a #GdkClipboard
- * @pixbuf: a #GdkPixbuf to put into the clipboard
+ * @texture: a #GdkTexture to put into the clipboard
  *
- * Puts the given @pixbuf into the clipboard.
+ * Puts the given @texture into the clipboard.
  **/
 void
-gdk_clipboard_set_pixbuf (GdkClipboard *clipboard,
-                          GdkPixbuf    *pixbuf)
+gdk_clipboard_set_texture (GdkClipboard *clipboard,
+                           GdkTexture   *texture)
 {
   GdkContentProvider *provider;
   GValue value = G_VALUE_INIT;
 
   g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
-  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+  g_return_if_fail (GDK_IS_TEXTURE (texture));
 
-  g_value_init (&value, GDK_TYPE_PIXBUF);
-  g_value_set_object (&value, pixbuf);
+  g_value_init (&value, GDK_TYPE_TEXTURE);
+  g_value_set_object (&value, texture);
   provider = gdk_content_provider_new_for_value (&value);
   g_value_unset (&value);
 
diff --git a/gdk/gdkclipboard.h b/gdk/gdkclipboard.h
index 87f873a..02b13b0 100644
--- a/gdk/gdkclipboard.h
+++ b/gdk/gdkclipboard.h
@@ -25,7 +25,7 @@
 
 #include <gdk/gdkversionmacros.h>
 #include <gdk/gdktypes.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gio/gio.h>
 
 
 G_BEGIN_DECLS
@@ -81,12 +81,12 @@ const GValue *          gdk_clipboard_read_value_finish (GdkClipboard          *
                                                          GAsyncResult          *res,
                                                          GError               **error);
 GDK_AVAILABLE_IN_3_94
-void                    gdk_clipboard_read_pixbuf_async (GdkClipboard          *clipboard,
+void                    gdk_clipboard_read_texture_async(GdkClipboard          *clipboard,
                                                          GCancellable          *cancellable,
                                                          GAsyncReadyCallback    callback,
                                                          gpointer               user_data);
 GDK_AVAILABLE_IN_3_94
-GdkPixbuf *             gdk_clipboard_read_pixbuf_finish(GdkClipboard          *clipboard,
+GdkTexture *            gdk_clipboard_read_texture_finish (GdkClipboard        *clipboard,
                                                          GAsyncResult          *res,
                                                          GError               **error);
 GDK_AVAILABLE_IN_3_94
@@ -106,8 +106,8 @@ GDK_AVAILABLE_IN_3_94
 void                    gdk_clipboard_set_text          (GdkClipboard          *clipboard,
                                                          const char            *text);
 GDK_AVAILABLE_IN_3_94
-void                    gdk_clipboard_set_pixbuf        (GdkClipboard          *clipboard,
-                                                         GdkPixbuf             *pixbuf);
+void                    gdk_clipboard_set_texture       (GdkClipboard          *clipboard,
+                                                         GdkTexture            *texture);
 
 G_END_DECLS
 
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index cd72696..5bbe112 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -33,23 +33,23 @@ clipboard_changed_cb (GdkClipboard *clipboard,
 }
 
 static void
-pixbuf_loaded_cb (GObject      *clipboard,
+texture_loaded_cb (GObject      *clipboard,
                   GAsyncResult *res,
                   gpointer      data)
 {
   GError *error = NULL;
-  GdkPixbuf *pixbuf;
+  GdkTexture *texture;
 
-  pixbuf = gdk_clipboard_read_pixbuf_finish (GDK_CLIPBOARD (clipboard), res, &error);
-  if (pixbuf == NULL)
+  texture = gdk_clipboard_read_texture_finish (GDK_CLIPBOARD (clipboard), res, &error);
+  if (texture == NULL)
     {
       g_print ("%s\n", error->message);
       g_error_free (error);
       return;
     }
 
-  gtk_image_set_from_pixbuf (data, pixbuf);
-  g_object_unref (pixbuf);
+  gtk_image_set_from_texture (data, texture);
+  g_object_unref (texture);
 }
 
 static void
@@ -87,10 +87,10 @@ visible_child_changed_cb (GtkWidget    *stack,
     {
       GtkWidget *image = gtk_stack_get_child_by_name (GTK_STACK (stack), "image");
 
-      gdk_clipboard_read_pixbuf_async (clipboard,
-                                       NULL,
-                                       pixbuf_loaded_cb,
-                                       image);
+      gdk_clipboard_read_texture_async (clipboard,
+                                        NULL,
+                                        texture_loaded_cb,
+                                        image);
     }
   else if (g_str_equal (visible_child, "text"))
     {


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