diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-12-04 23:09:54 -0800 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-12-04 23:09:54 -0800 |
commit | b5c62cf86fe37e05ce2a0ae050df2a229457676b (patch) | |
tree | d9679bf4405c648552d4c80eeb140883f46515fb /gdk/gdkclipboard.c | |
parent | dc50e0637ffa8bc7a369d00a5d8e7656d03c3781 (diff) | |
download | gtk+-b5c62cf86fe37e05ce2a0ae050df2a229457676b.tar.gz |
Revert "clipboard: Add gdk_clipboard_set()"
This reverts commit dc50e0637ffa8bc7a369d00a5d8e7656d03c3781.
This broke the build.
Diffstat (limited to 'gdk/gdkclipboard.c')
-rw-r--r-- | gdk/gdkclipboard.c | 105 |
1 files changed, 85 insertions, 20 deletions
diff --git a/gdk/gdkclipboard.c b/gdk/gdkclipboard.c index 2832fcad50..befbb08aef 100644 --- a/gdk/gdkclipboard.c +++ b/gdk/gdkclipboard.c @@ -30,6 +30,8 @@ #include "gdkpipeiostreamprivate.h" #include "gdktexture.h" +#include <gobject/gvaluecollector.h> + /** * SECTION:gdkclipboard * @Short_description: Share data between applications for Copy-and-Paste @@ -1233,32 +1235,104 @@ gdk_clipboard_set_content (GdkClipboard *clipboard, } /** - * gdk_clipboard_set_text: + * gdk_clipboard_set: * @clipboard: a #GdkClipboard - * @text: Text to put into the clipboard + * @type: type of value to set + * @...: value contents conforming to @type * - * Puts the given @text into the clipboard. + * Sets the clipboard to contain the value collected from the given + * varargs. **/ void -gdk_clipboard_set_text (GdkClipboard *clipboard, - const char *text) +gdk_clipboard_set (GdkClipboard *clipboard, + GType type, + ...) +{ + va_list args; + + g_return_if_fail (GDK_IS_CLIPBOARD (clipboard)); + + va_start (args, type); + gdk_clipboard_set_valist (clipboard, type, args); + va_end (args); +} + +/** + * gdk_clipboard_set_valist: (skip) + * @clipboard: a #GdkClipboard + * @type: type of value to set + * @args: varargs containing the value of @type + * + * Sets the clipboard to contain the value collected from the given + * @args. + **/ +void +gdk_clipboard_set_valist (GdkClipboard *clipboard, + GType type, + va_list args) { - GdkContentProvider *provider; GValue value = G_VALUE_INIT; + char *error; g_return_if_fail (GDK_IS_CLIPBOARD (clipboard)); - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, text); - provider = gdk_content_provider_new_for_value (&value); + G_VALUE_COLLECT_INIT (&value, type, + args, G_VALUE_NOCOPY_CONTENTS, + &error); + if (error) + { + g_warning ("%s: %s", G_STRLOC, error); + g_free (error); + /* we purposely leak the value here, it might not be + * in a sane state if an error condition occoured + */ + return; + } + + gdk_clipboard_set_value (clipboard, &value); g_value_unset (&value); +} + +/** + * gdk_clipboard_set_value: (rename-to gdk_clipboard_set) + * @clipboard: a #GdkClipboard + * @value: a #GValue to set + * + * Sets the @clipboard to contain the given @value. + **/ +void +gdk_clipboard_set_value (GdkClipboard *clipboard, + const GValue *value) +{ + GdkContentProvider *provider; + + g_return_if_fail (GDK_IS_CLIPBOARD (clipboard)); + g_return_if_fail (G_IS_VALUE (value)); + + provider = gdk_content_provider_new_for_value (value); gdk_clipboard_set_content (clipboard, provider); g_object_unref (provider); } /** - * gdk_clipboard_set_texture: + * gdk_clipboard_set_text: (skip) + * @clipboard: a #GdkClipboard + * @text: Text to put into the clipboard + * + * Puts the given @text into the clipboard. + **/ +void +gdk_clipboard_set_text (GdkClipboard *clipboard, + const char *text) +{ + g_return_if_fail (GDK_IS_CLIPBOARD (clipboard)); + + gdk_clipboard_set (clipboard, G_TYPE_STRING, text); +} + +/** + * gdk_clipboard_set_texture: (skip) * @clipboard: a #GdkClipboard * @texture: a #GdkTexture to put into the clipboard * @@ -1268,18 +1342,9 @@ void 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_TEXTURE (texture)); - 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); - - gdk_clipboard_set_content (clipboard, provider); - g_object_unref (provider); + gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, texture); } |