Class: Gdk::Clipboard
- Inherits:
-
Object
- Object
- Gdk::Clipboard
- Defined in:
- (unknown)
Overview
The GdkClipboard object represents data shared between applications or
inside an application.
To get a GdkClipboard object, use [methodGdk.Display.get_clipboard] or
[methodGdk.Display.get_primary_clipboard]. You can find out about the data
that is currently available in a clipboard using
[methodGdk.Clipboard.get_formats].
To make text or image data available in a clipboard, use [methodGdk.Clipboard.set_text] or [methodGdk.Clipboard.set_texture]. For other data, you can use [methodGdk.Clipboard.set_content], which takes a [classGdk.ContentProvider] object.
To read textual or image data from a clipboard, use
[methodGdk.Clipboard.read_text_async] or
[methodGdk.Clipboard.read_texture_async]. For other data, use
[methodGdk.Clipboard.read_async], which provides a GInputStream object.
Instance Method Summary collapse
-
#content ⇒ Gdk::ContentProvider
The
GdkContentProvideror nil if the clipboard is empty or contents are provided otherwise. -
#content=(content) ⇒ Gdk::ContentProvider
The
GdkContentProvideror nil if the clipboard is empty or contents are provided otherwise. -
#display ⇒ Gdk::Display
The
GdkDisplaythat the clipboard belongs to. -
#display=(display) ⇒ Gdk::Display
The
GdkDisplaythat the clipboard belongs to. -
#formats ⇒ Gdk::ContentFormats
The possible formats that the clipboard can provide its data in.
-
#formats=(formats) ⇒ Gdk::ContentFormats
The possible formats that the clipboard can provide its data in.
-
#is_local ⇒ Boolean
Returns if the clipboard is local.
-
#local=(local) ⇒ Boolean
true if the contents of the clipboard are owned by this process.
-
#local? ⇒ Boolean
true if the contents of the clipboard are owned by this process.
-
#read_async(mime_types, io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously requests an input stream to read the clipboard's contents from.
-
#read_finish(result, out_mime_type) ⇒ Gio::InputStream
Finishes an asynchronous clipboard read.
-
#read_text_async(cancellable, callback, user_data) ⇒ nil
Asynchronously request the clipboard contents converted to a string.
-
#read_text_finish(result) ⇒ String
Finishes an asynchronous clipboard read.
-
#read_texture_async(cancellable, callback, user_data) ⇒ nil
Asynchronously request the clipboard contents converted to a
GdkPixbuf. -
#read_texture_finish(result) ⇒ Gdk::Texture
Finishes an asynchronous clipboard read.
-
#read_value_async(type, io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously request the clipboard contents converted to the given type.
-
#read_value_finish(result) ⇒ GObject::Value
Finishes an asynchronous clipboard read.
-
#set(type, array) ⇒ nil
Sets the clipboard to contain the value collected from the given varargs.
-
#set_valist(type, args) ⇒ nil
Sets the clipboard to contain the value collected from the given args.
-
#store_async(io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously instructs the clipboard to store its contents remotely.
-
#store_finish(result) ⇒ Boolean
Finishes an asynchronous clipboard store.
-
#text=(text) ⇒ nil
Puts the given text into the clipboard.
-
#texture=(texture) ⇒ nil
Puts the given texture into the clipboard.
-
#value=(value) ⇒ nil
Sets the clipboard to contain the given value.
Instance Method Details
#content ⇒ Gdk::ContentProvider
The GdkContentProvider or nil if the clipboard is empty or contents are
provided otherwise.
#content=(content) ⇒ Gdk::ContentProvider
The GdkContentProvider or nil if the clipboard is empty or contents are
provided otherwise.
#display ⇒ Gdk::Display
The GdkDisplay that the clipboard belongs to.
#display=(display) ⇒ Gdk::Display
The GdkDisplay that the clipboard belongs to.
#formats ⇒ Gdk::ContentFormats
The possible formats that the clipboard can provide its data in.
#formats=(formats) ⇒ Gdk::ContentFormats
The possible formats that the clipboard can provide its data in.
#is_local ⇒ Boolean
Returns if the clipboard is local.
A clipboard is considered local if it was last claimed by the running application.
Note that [methodGdk.Clipboard.get_content] may return nil even on a local clipboard. In this case the clipboard is empty.
#local=(local) ⇒ Boolean
true if the contents of the clipboard are owned by this process.
#local? ⇒ Boolean
true if the contents of the clipboard are owned by this process.
#read_async(mime_types, io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously requests an input stream to read the clipboard's contents from.
When the operation is finished callback will be called. You must then call [methodGdk.Clipboard.read_finish] to get the result of the operation.
The clipboard will choose the most suitable mime type from the given list to fulfill the request, preferring the ones listed first.
#read_finish(result, out_mime_type) ⇒ Gio::InputStream
Finishes an asynchronous clipboard read.
See [methodGdk.Clipboard.read_async].
#read_text_async(cancellable, callback, user_data) ⇒ nil
Asynchronously request the clipboard contents converted to a string.
When the operation is finished callback will be called. You must then call [methodGdk.Clipboard.read_text_finish] to get the result.
This is a simple wrapper around [methodGdk.Clipboard.read_value_async]. Use that function or [methodGdk.Clipboard.read_async] directly if you need more control over the operation.
#read_text_finish(result) ⇒ String
Finishes an asynchronous clipboard read.
See [methodGdk.Clipboard.read_text_async].
#read_texture_async(cancellable, callback, user_data) ⇒ nil
Asynchronously request the clipboard contents converted to a GdkPixbuf.
When the operation is finished callback will be called. You must then call [methodGdk.Clipboard.read_texture_finish] to get the result.
This is a simple wrapper around [methodGdk.Clipboard.read_value_async]. Use that function or [methodGdk.Clipboard.read_async] directly if you need more control over the operation.
#read_texture_finish(result) ⇒ Gdk::Texture
Finishes an asynchronous clipboard read.
See [methodGdk.Clipboard.read_texture_async].
#read_value_async(type, io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously request the clipboard contents converted to the given type.
When the operation is finished callback will be called. You must then call
[methodGdk.Clipboard.read_value_finish] to get the resulting GValue.
For local clipboard contents that are available in the given GType,
the value will be copied directly. Otherwise, GDK will try to use
[funccontent_deserialize_async] to convert the clipboard's data.
#read_value_finish(result) ⇒ GObject::Value
Finishes an asynchronous clipboard read.
See [methodGdk.Clipboard.read_value_async].
#set(type, array) ⇒ nil
Sets the clipboard to contain the value collected from the given varargs.
Values should be passed the same way they are passed to other value collecting APIs, such as [methodGObject.Object.set] or [funcGObject.signal_emit].
gdk_clipboard_set (clipboard, GTK_TYPE_STRING, "Hello World");
gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, some_texture);
#set_valist(type, args) ⇒ nil
Sets the clipboard to contain the value collected from the given args.
#store_async(io_priority, cancellable, callback, user_data) ⇒ nil
Asynchronously instructs the clipboard to store its contents remotely.
If the clipboard is not local, this function does nothing but report success.
The callback must call [methodGdk.Clipboard.store_finish].
The purpose of this call is to preserve clipboard contents beyond the lifetime of an application, so this function is typically called on exit. Depending on the platform, the functionality may not be available unless a "clipboard manager" is running.
This function is called automatically when a GtkApplication is shut down, so you likely don't need to call it.
#store_finish(result) ⇒ Boolean
Finishes an asynchronous clipboard store.
See [methodGdk.Clipboard.store_async].
#text=(text) ⇒ nil
Puts the given text into the clipboard.
#texture=(texture) ⇒ nil
Puts the given texture into the clipboard.
#value=(value) ⇒ nil
Sets the clipboard to contain the given value.