[gtk+/wip/clipboard: 1/8] A GdkClipboard API draft



commit aa16eee0d10c0a5d77dcf5f002ccd612349d9007
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 28 23:55:53 2014 -0400

    A GdkClipboard API draft
    
    This commit adds a GdkClipboard object which is intended to
    replace GtkClipboard, eventually. Currently, it supports setting
    text, pixbufs and general data with mime types.

 gdk/Makefile.am           |    5 +-
 gdk/gdk.h                 |    1 +
 gdk/gdkclipboard.c        |  374 +++++++++++++++++++++++++++++++++++++++++++++
 gdk/gdkclipboard.h        |  124 +++++++++++++++
 gdk/gdkclipboardprivate.h |   99 ++++++++++++
 5 files changed, 602 insertions(+), 1 deletions(-)
---
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 6adaa7a..11a1109 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -67,6 +67,7 @@ gdk_public_h_sources =                                \
        gdk.h                                   \
        gdkapplaunchcontext.h                   \
        gdkcairo.h                              \
+       gdkclipboard.h                          \
        gdkcursor.h                             \
        gdkdevice.h                             \
        gdkdevicemanager.h                      \
@@ -103,6 +104,7 @@ gdk_h_sources =                                     \
 
 gdk_private_headers =                          \
        gdkapplaunchcontextprivate.h            \
+       gdkclipboardprivate.h                   \
        gdkcursorprivate.h                      \
        gdkdevicemanagerprivate.h               \
        gdkdeviceprivate.h                      \
@@ -111,9 +113,9 @@ gdk_private_headers =                               \
        gdkdndprivate.h                         \
        gdkframeclockidle.h                     \
        gdkframeclockprivate.h                  \
-       gdkscreenprivate.h                      \
        gdkinternals.h                          \
        gdkintl.h                               \
+       gdkscreenprivate.h                      \
        gdkkeysprivate.h                        \
        gdkvisualprivate.h                      \
        gdkx.h
@@ -126,6 +128,7 @@ gdk_c_sources =                             \
        gdk.c                                   \
        gdkapplaunchcontext.c                   \
        gdkcairo.c                              \
+       gdkclipboard.c                          \
        gdkcursor.c                             \
        gdkdeprecated.c                         \
        gdkdevice.c                             \
diff --git a/gdk/gdk.h b/gdk/gdk.h
index 5761fa1..bdf402d 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -31,6 +31,7 @@
 #include <gdk/gdkversionmacros.h>
 #include <gdk/gdkapplaunchcontext.h>
 #include <gdk/gdkcairo.h>
+#include <gdk/gdkclipboard.h>
 #include <gdk/gdkcursor.h>
 #include <gdk/gdkdevice.h>
 #include <gdk/gdkdevicemanager.h>
diff --git a/gdk/gdkclipboard.c b/gdk/gdkclipboard.c
new file mode 100644
index 0000000..4f25447
--- /dev/null
+++ b/gdk/gdkclipboard.c
@@ -0,0 +1,374 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <gdk/gdkclipboardprivate.h>
+
+
+typedef struct _GdkClipboardPrivate GdkClipboardPrivate;
+
+struct _GdkClipboardPrivate
+{
+  GdkClipboardContent content;
+  gchar **content_types;
+};
+
+enum {
+  CHANGED,
+  N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GdkClipboard, gdk_clipboard, G_TYPE_OBJECT)
+
+static void
+gdk_clipboard_init (GdkClipboard *clipboard)
+{
+}
+
+static void
+gdk_clipboard_finalize (GObject *object)
+{
+  GdkClipboard *clipboard = GDK_CLIPBOARD (object);
+  GdkClipboardPrivate *priv = gdk_clipboard_get_instance_private (clipboard);
+
+  g_strfreev (priv->content_types);
+
+  G_OBJECT_CLASS (gdk_clipboard_parent_class)->finalize (object);
+
+}
+
+static void
+gdk_clipboard_class_init (GdkClipboardClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->finalize = gdk_clipboard_finalize;
+
+  signals[CHANGED] =
+    g_signal_new ("changed",
+                  G_TYPE_FROM_CLASS (class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GdkClipboardClass, changed),
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
+}
+
+void
+_gdk_clipboard_set_available_content (GdkClipboard        *clipboard,
+                                      GdkClipboardContent  content,
+                                      const gchar         **content_types)
+{
+  GdkClipboardPrivate *priv = gdk_clipboard_get_instance_private (clipboard);
+
+  priv->content = content;
+  g_strfreev (priv->content_types);
+  priv->content_types = g_strdupv ((gchar **)content_types);
+  /* FIXME: should we automatically set text / image content types ? */
+
+  g_signal_emit (clipboard, signals[CHANGED], 0);
+}
+
+GdkClipboardContent
+_gdk_clipboard_get_available_content (GdkClipboard *clipboard)
+{
+  GdkClipboardPrivate *priv = gdk_clipboard_get_instance_private (clipboard);
+  
+  return priv->content;
+}
+
+const gchar **
+gdk_clipboard_get_content_types (GdkClipboard *clipboard)
+{
+  GdkClipboardPrivate *priv;
+
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), NULL);
+  
+  priv = gdk_clipboard_get_instance_private (clipboard);
+
+  return (const gchar **)priv->content_types;
+}
+
+static gboolean
+strv_contains (const gchar **strv, const gchar *s)
+{
+  gint i;
+
+  for (i = 0; strv[i]; i++)
+    {
+      if (g_strcmp0 (strv[i], s) == 0)
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
+gboolean
+gdk_clipboard_data_available (GdkClipboard *clipboard,
+                              const gchar  *content_type)
+{
+  GdkClipboardPrivate *priv;
+
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), FALSE);
+  
+  priv = gdk_clipboard_get_instance_private (clipboard);
+
+  return priv->content_types != NULL &&
+         strv_contains ((const gchar **)priv->content_types, content_type);
+}
+
+void
+gdk_clipboard_get_text_async (GdkClipboard        *clipboard,
+                              GCancellable        *cancellable,
+                              GAsyncReadyCallback  callback,
+                              gpointer             user_data)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->get_text_async (clipboard, cancellable, callback, user_data);
+}
+
+gchar *
+gdk_clipboard_get_text_finish (GdkClipboard  *clipboard,
+                               GAsyncResult  *res,
+                               GError       **error)
+{
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), NULL);
+
+  return GDK_CLIPBOARD_GET_CLASS (clipboard)->get_text_finish (clipboard, res, error);
+}
+
+void
+gdk_clipboard_set_text (GdkClipboard *clipboard,
+                        const gchar  *text)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->set_text (clipboard, text);
+}
+
+gboolean
+gdk_clipboard_text_available (GdkClipboard *clipboard)
+{
+  GdkClipboardPrivate *priv;
+
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), FALSE);
+
+  priv = gdk_clipboard_get_instance_private (clipboard);
+
+  return ((priv->content & TEXT_CONTENT) != 0);
+}
+
+void
+gdk_clipboard_get_image_async (GdkClipboard        *clipboard,
+                               GCancellable        *cancellable,
+                               GAsyncReadyCallback  callback,
+                               gpointer             user_data)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->get_image_async (clipboard, cancellable, callback, user_data);
+}
+
+GdkPixbuf *
+gdk_clipboard_get_image_finish (GdkClipboard  *clipboard,
+                                GAsyncResult  *res,
+                                GError       **error)
+{
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), NULL);
+
+  return GDK_CLIPBOARD_GET_CLASS (clipboard)->get_image_finish (clipboard, res, error);
+}
+
+void
+gdk_clipboard_set_image (GdkClipboard *clipboard,
+                         GdkPixbuf    *pixbuf)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->set_image (clipboard, pixbuf);
+}
+
+gboolean
+gdk_clipboard_image_available (GdkClipboard *clipboard)
+{
+  GdkClipboardPrivate *priv;
+
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), FALSE);
+
+  priv = gdk_clipboard_get_instance_private (clipboard);
+
+  return (priv->content & IMAGE_CONTENT) != 0;
+}
+
+void
+gdk_clipboard_get_data_async (GdkClipboard        *clipboard,
+                              const gchar         *content_type,
+                              GCancellable        *cancellable,
+                              GAsyncReadyCallback  callback,
+                              gpointer             user_data)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->get_data_async (clipboard, content_type, cancellable, callback, 
user_data);
+}
+
+GInputStream *
+gdk_clipboard_get_data_finish (GdkClipboard  *clipboard,
+                               GAsyncResult  *res,
+                               GError       **error)
+{
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), NULL);
+
+  return GDK_CLIPBOARD_GET_CLASS (clipboard)->get_data_finish (clipboard, res, error);
+}
+
+void
+gdk_clipboard_set_data (GdkClipboard          *clipboard,
+                        const gchar          **content_types,
+                        GdkClipboardProvider   callback,
+                        gpointer               user_data,
+                        GDestroyNotify         destroy)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->set_data (clipboard, content_types, callback, user_data, destroy);
+}
+
+void
+gdk_clipboard_clear (GdkClipboard *clipboard)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  GDK_CLIPBOARD_GET_CLASS (clipboard)->clear (clipboard);
+}
+
+typedef struct {
+  GAsyncReadyCallback callback;
+  gpointer            user_data;
+} GetBytesData;
+
+static void
+get_bytes (GObject      *object,
+           GAsyncResult *res,
+           gpointer      user_data)
+{
+  GdkClipboard *clipboard = GDK_CLIPBOARD (object);
+  GetBytesData *data = user_data;
+  GError *error;
+  GBytes *bytes;
+  GInputStream *istream;
+  GOutputStream *ostream;
+
+  error = NULL; 
+  bytes = NULL;
+
+  istream = gdk_clipboard_get_data_finish (clipboard, res, &error);
+  if (istream)
+    {
+      ostream = g_memory_output_stream_new_resizable ();
+      g_output_stream_splice (ostream, istream, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | 
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, NULL, NULL);
+      bytes = g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (ostream));
+      g_object_unref (ostream);
+      g_object_unref (istream);
+    }
+
+  g_object_set_data (G_OBJECT (res), "error", error);
+  g_object_set_data (G_OBJECT (res), "bytes", bytes);
+
+  data->callback (object, res, data->user_data);
+
+  g_free (data);
+}
+
+void
+gdk_clipboard_get_bytes_async (GdkClipboard        *clipboard,
+                               const gchar         *content_type,
+                               GCancellable        *cancellable,
+                               GAsyncReadyCallback  callback,
+                               gpointer             user_data)
+{
+  GetBytesData *data;
+
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+
+  data = g_new (GetBytesData, 1);
+  data->callback = callback;
+  data->user_data = user_data;
+
+  gdk_clipboard_get_data_async (clipboard, content_type, cancellable, get_bytes, data);
+}
+
+GBytes *
+gdk_clipboard_get_bytes_finish (GdkClipboard  *clipboard,
+                                GAsyncResult  *res,
+                                GError       **error)
+{
+  g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), NULL);
+  GError *inner;
+  GBytes *bytes;
+
+  inner = g_object_get_data (G_OBJECT (res), "error");
+  bytes = g_object_get_data (G_OBJECT (res), "bytes");
+
+  if (inner)
+    g_propagate_error (error, inner);
+
+  return bytes;
+}
+
+static void
+set_bytes (GdkClipboard  *clipboard,
+           const gchar   *content_type,
+           GOutputStream *stream,
+           gpointer       user_data)
+{
+  GBytes *bytes = user_data;
+  GBytes *rest;
+  gssize written;
+
+  g_bytes_ref (bytes);
+
+  while (TRUE)
+    {
+      written = g_output_stream_write_bytes (stream, bytes, NULL, NULL);
+      if (written == g_bytes_get_size (bytes) || written == -1)
+        break;
+      rest = g_bytes_new_from_bytes (bytes, written, g_bytes_get_size (bytes) - written);
+      g_bytes_unref (bytes);
+      bytes = rest;
+    }
+
+  g_bytes_unref (bytes);
+}
+
+void
+gdk_clipboard_set_bytes (GdkClipboard *clipboard,
+                         GBytes       *bytes,
+                         const gchar  *content_type)
+{
+  g_return_if_fail (GDK_IS_CLIPBOARD (clipboard));
+  const gchar *ctypes[2];
+
+  ctypes[0] = content_type;
+  ctypes[1] = NULL;
+
+  /* create stream from bytes */
+  gdk_clipboard_set_data (clipboard, ctypes, set_bytes, g_bytes_ref (bytes), (GDestroyNotify) g_bytes_unref);
+}
+
diff --git a/gdk/gdkclipboard.h b/gdk/gdkclipboard.h
new file mode 100644
index 0000000..6a141f7
--- /dev/null
+++ b/gdk/gdkclipboard.h
@@ -0,0 +1,124 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_CLIPBOARD_H__
+#define __GDK_CLIPBOARD_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdkversionmacros.h>
+#include <gdk/gdktypes.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_CLIPBOARD            (gdk_clipboard_get_type ())
+#define GDK_CLIPBOARD(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CLIPBOARD, GdkClipboard))
+#define GDK_IS_CLIPBOARD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_CLIPBOARD))
+
+typedef struct _GdkClipboard GdkClipboard;
+
+typedef void (* GdkClipboardProvider) (GdkClipboard  *clipboard,
+                                       const gchar   *content_type,
+                                       GOutputStream *output,
+                                       gpointer       user_data);
+
+GDK_AVAILABLE_IN_3_14
+GType          gdk_clipboard_get_type          (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_get_text_async    (GdkClipboard         *clipboard,
+                                                GCancellable         *cancellable,
+                                                GAsyncReadyCallback   callback,
+                                                gpointer              user_data);
+GDK_AVAILABLE_IN_3_14
+gchar *        gdk_clipboard_get_text_finish   (GdkClipboard         *clipboard,
+                                                GAsyncResult         *res,
+                                                GError              **error);
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_set_text          (GdkClipboard         *clipboard,
+                                                const gchar          *text);
+
+GDK_AVAILABLE_IN_3_14
+gboolean       gdk_clipboard_text_available   (GdkClipboard          *clipboard);
+
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_get_image_async  (GdkClipboard          *clipboard,
+                                               GCancellable          *cancellable,
+                                               GAsyncReadyCallback    callback,
+                                               gpointer               user_data);
+GDK_AVAILABLE_IN_3_14
+GdkPixbuf *    gdk_clipboard_get_image_finish (GdkClipboard          *clipboard,
+                                               GAsyncResult          *res,
+                                               GError               **error);
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_set_image        (GdkClipboard          *clipboard,
+                                               GdkPixbuf             *pixbuf);
+
+GDK_AVAILABLE_IN_3_14
+gboolean       gdk_clipboard_image_available  (GdkClipboard          *clipboard);
+
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_get_bytes_async  (GdkClipboard          *clipboard,
+                                               const gchar           *content_type,
+                                               GCancellable          *cancellable,
+                                               GAsyncReadyCallback    callback,
+                                               gpointer               user_data);
+GDK_AVAILABLE_IN_3_14
+GBytes *       gdk_clipboard_get_bytes_finish (GdkClipboard          *clipboard,
+                                               GAsyncResult          *res,
+                                               GError               **error);
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_set_bytes        (GdkClipboard          *clipboard,
+                                               GBytes                *data,
+                                               const gchar           *content_type);
+
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_get_data_async   (GdkClipboard          *clipboard,
+                                               const gchar           *content_type,
+                                               GCancellable          *cancellable,
+                                               GAsyncReadyCallback    callback,
+                                               gpointer               user_data);
+GDK_AVAILABLE_IN_3_14
+GInputStream * gdk_clipboard_get_data_finish  (GdkClipboard          *clipboard,
+                                               GAsyncResult          *res,
+                                               GError               **error);
+
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_set_data         (GdkClipboard          *clipboard,
+                                               const gchar          **content_types,
+                                               GdkClipboardProvider   callback,
+                                               gpointer               user_data,
+                                               GDestroyNotify         destroy);
+                                          
+GDK_AVAILABLE_IN_3_14
+gboolean       gdk_clipboard_data_available   (GdkClipboard          *clipboard,
+                                               const gchar           *content_type);
+
+GDK_AVAILABLE_IN_3_14
+void           gdk_clipboard_clear            (GdkClipboard          *clipboard);
+
+GDK_AVAILABLE_IN_3_14
+const gchar **gdk_clipboard_get_content_types (GdkClipboard          *clipboard);
+
+
+G_END_DECLS
+
+#endif /* __GDK_CLIPBOARD_H__ */
diff --git a/gdk/gdkclipboardprivate.h b/gdk/gdkclipboardprivate.h
new file mode 100644
index 0000000..5a2788f
--- /dev/null
+++ b/gdk/gdkclipboardprivate.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_CLIPBOARD_PRIVATE_H__
+#define __GDK_CLIPBOARD_PRIVATE_H__
+
+#include <gdk/gdkclipboard.h>
+
+G_BEGIN_DECLS
+
+#define GDK_CLIPBOARD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_CLIPBOARD, 
GdkClipboardClass))
+#define GDK_IS_CLIPBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_CLIPBOARD))
+#define GDK_CLIPBOARD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_CLIPBOARD, 
GdkClipboardClass))
+
+typedef struct _GdkClipboardClass GdkClipboardClass;
+
+struct _GdkClipboard
+{
+  GObject parent;
+};
+
+struct _GdkClipboardClass
+{
+  GObjectClass parent_class;
+
+  /* signals */
+  void          (* changed)          (GdkClipboard           *clipboard);
+
+  /* vfuncs */
+  void           (* get_text_async)   (GdkClipboard          *clipboard, 
+                                       GCancellable          *cancellable,
+                                       GAsyncReadyCallback    callback,
+                                       gpointer               user_data);
+  gchar *        (* get_text_finish)  (GdkClipboard          *clipboard,
+                                       GAsyncResult          *res,
+                                       GError               **error);
+  void           (* set_text)         (GdkClipboard          *clipboard,
+                                       const gchar           *text);
+
+  void           (* get_image_async)  (GdkClipboard          *clipboard, 
+                                       GCancellable          *cancellable,
+                                       GAsyncReadyCallback    callback,
+                                       gpointer               user_data);
+  GdkPixbuf *    (* get_image_finish) (GdkClipboard          *clipboard,
+                                       GAsyncResult          *res,
+                                       GError               **error);
+  void           (* set_image)        (GdkClipboard          *clipboard,
+                                       GdkPixbuf             *pixbuf);
+
+  void           (* get_data_async)   (GdkClipboard          *clipboard, 
+                                       const gchar           *content_type,
+                                       GCancellable          *cancellable,
+                                       GAsyncReadyCallback    callback,
+                                       gpointer               user_data);
+  GInputStream * (* get_data_finish)  (GdkClipboard          *clipboard,
+                                       GAsyncResult          *res,
+                                       GError               **error);
+  void           (* set_data)         (GdkClipboard          *clipboard,
+                                       const gchar          **content_types,
+                                       GdkClipboardProvider   provider,
+                                       gpointer               data,
+                                       GDestroyNotify         destroy);
+
+  void           (* clear)            (GdkClipboard          *clipboard);
+};
+
+
+typedef enum {
+  NO_CONTENT    = 0,
+  OTHER_CONTENT = 1 << 0,
+  TEXT_CONTENT  = 1 << 1,
+  IMAGE_CONTENT = 1 << 2
+} GdkClipboardContent;
+
+void
+_gdk_clipboard_set_available_content (GdkClipboard         *clipboard,
+                                      GdkClipboardContent   content,
+                                      const gchar         **content_types);
+
+GdkClipboardContent
+_gdk_clipboard_get_available_content (GdkClipboard        *clipboard);
+
+G_END_DECLS
+
+#endif /* __GDK_CLIPBOARD_PRIVATE_H__ */


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