[gtk+/wip/otte/clipboard: 20/64] clipboard: Implement gdk_clipboard_read()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/clipboard: 20/64] clipboard: Implement gdk_clipboard_read()
- Date: Fri, 1 Dec 2017 05:23:54 +0000 (UTC)
commit 60dee191b3f7a9de63f492ac325b1f400fb35278
Author: Benjamin Otte <otte redhat com>
Date: Mon Nov 20 02:06:21 2017 +0100
clipboard: Implement gdk_clipboard_read()
gdk/gdkclipboard.c | 23 +++++++++++++++++++++++
gdk/gdkclipboard.h | 3 +++
gdk/gdkclipboardprivate.h | 4 +++-
gdk/x11/gdkclipboard-x11.c | 16 +++++++++++++++-
4 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdkclipboard.c b/gdk/gdkclipboard.c
index 77862dd..eee9284 100644
--- a/gdk/gdkclipboard.c
+++ b/gdk/gdkclipboard.c
@@ -113,6 +113,14 @@ gdk_clipboard_finalize (GObject *object)
G_OBJECT_CLASS (gdk_clipboard_parent_class)->finalize (object);
}
+static GInputStream *
+gdk_clipboard_real_read (GdkClipboard *clipboard,
+ const char *mime_type)
+{
+ /* whoop whooop */
+ return g_memory_input_stream_new ();
+}
+
static void
gdk_clipboard_class_init (GdkClipboardClass *class)
{
@@ -122,6 +130,8 @@ gdk_clipboard_class_init (GdkClipboardClass *class)
object_class->set_property = gdk_clipboard_set_property;
object_class->finalize = gdk_clipboard_finalize;
+ class->read = gdk_clipboard_real_read;
+
/**
* GdkClipboard:display:
*
@@ -227,6 +237,19 @@ gdk_clipboard_get_formats (GdkClipboard *clipboard)
return priv->formats;
}
+GInputStream *
+gdk_clipboard_read (GdkClipboard *clipboard,
+ const char *mime_type)
+{
+ GdkClipboardPrivate *priv = gdk_clipboard_get_instance_private (clipboard);
+
+ g_return_val_if_fail (GDK_IS_CLIPBOARD (clipboard), NULL);
+ g_return_val_if_fail (mime_type != NULL, NULL);
+ g_return_val_if_fail (gdk_content_formats_contain_mime_type (priv->formats, mime_type), NULL);
+
+ return GDK_CLIPBOARD_GET_CLASS (clipboard)->read (clipboard, mime_type);
+}
+
GdkClipboard *
gdk_clipboard_new (GdkDisplay *display)
{
diff --git a/gdk/gdkclipboard.h b/gdk/gdkclipboard.h
index 08943e5..6c36c94 100644
--- a/gdk/gdkclipboard.h
+++ b/gdk/gdkclipboard.h
@@ -42,6 +42,9 @@ GdkDisplay * gdk_clipboard_get_display (GdkClipboard *
GDK_AVAILABLE_IN_3_94
GdkContentFormats * gdk_clipboard_get_formats (GdkClipboard *clipboard);
+GDK_AVAILABLE_IN_3_94
+GInputStream * gdk_clipboard_read (GdkClipboard *clipboard,
+ const char *mime_type);
G_END_DECLS
diff --git a/gdk/gdkclipboardprivate.h b/gdk/gdkclipboardprivate.h
index adc6c0a..faf1ce6 100644
--- a/gdk/gdkclipboardprivate.h
+++ b/gdk/gdkclipboardprivate.h
@@ -38,9 +38,11 @@ struct _GdkClipboardClass
GObjectClass parent_class;
/* signals */
- void (* changed) (GdkClipboard *clipboard);
+ void (* changed) (GdkClipboard *clipboard);
/* vfuncs */
+ GInputStream * (* read) (GdkClipboard *clipboard,
+ const char *mime_type);
};
GdkClipboard * gdk_clipboard_new (GdkDisplay *display);
diff --git a/gdk/x11/gdkclipboard-x11.c b/gdk/x11/gdkclipboard-x11.c
index 28def4e..b692006 100644
--- a/gdk/x11/gdkclipboard-x11.c
+++ b/gdk/x11/gdkclipboard-x11.c
@@ -180,13 +180,27 @@ gdk_x11_clipboard_finalize (GObject *object)
G_OBJECT_CLASS (gdk_x11_clipboard_parent_class)->finalize (object);
}
+static GInputStream *
+gdk_x11_clipboard_read (GdkClipboard *clipboard,
+ const char *mime_type)
+{
+ GdkX11Clipboard *cb = GDK_X11_CLIPBOARD (clipboard);
+
+ return gdk_x11_selection_input_stream_new (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)),
+ cb->selection,
+ mime_type,
+ cb->timestamp);
+}
+
static void
gdk_x11_clipboard_class_init (GdkX11ClipboardClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- //GdkClipboardClass *clipboard_class = GDK_CLIPBOARD_CLASS (class);
+ GdkClipboardClass *clipboard_class = GDK_CLIPBOARD_CLASS (class);
object_class->finalize = gdk_x11_clipboard_finalize;
+
+ clipboard_class->read = gdk_x11_clipboard_read;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]