1.5 <GdkClipboard>

Class: <GdkClipboard>

It derives from <GObject>.

Represents data shared between applications or inside an application.

To get a <GdkClipboard> object, use display:get-clipboard or display:get-primary-clipboard. You can find out about the data that is currently available in a clipboard using clipboard:get-formats.

To make text or image data available in a clipboard, use Gdk.Clipboard.set_text or Gdk.Clipboard.set_texture. For other data, you can use clipboard:set-content?, which takes a <GdkContentProvider> object.

To read textual or image data from a clipboard, use clipboard:read-text-async or clipboard:read-texture-async. For other data, use clipboard:read-async, which provides a <GInputStream> object.

Properties

Property: clipboard:content self

The <GdkContentProvider> or #f if the clipboard is empty or contents are provided otherwise.

Its value is a <GdkContentProvider>, or #f.

It is read only.

Property: clipboard:display self

The <GdkDisplay> that the clipboard belongs to.

Its value is a <GdkDisplay>, or #f.

It can only be set when the object is made, with #:display.

Property: clipboard:formats self

The possible formats that the clipboard can provide its data in.

Its value is a <GdkContentFormats>, or #f.

It is read only.

Property: clipboard:local self

#t if the contents of the clipboard are owned by this process.

Its value is a boolean.

It is read only.

Procedures

Method: clipboard:get-content self ⇒ %return
Method: get-content self ⇒ %return

Returns the <GdkContentProvider> currently set on self.

If the self is empty or its contents are not owned by the current process, #f will be returned.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

%return

Returned: a <GdkContentProvider>, or #f.

The content of a clipboard if the clipboard does not maintain any content

Method: clipboard:get-display self ⇒ %return
Method: get-display self ⇒ %return

Gets the <GdkDisplay> that the clipboard was created for.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

%return

Returned: a <GdkDisplay>.

a <GdkDisplay>

Method: clipboard:get-formats self ⇒ %return
Method: get-formats self ⇒ %return

Gets the formats that the clipboard can provide its current contents in.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

%return

Returned: a <GdkContentFormats>.

The formats of the clipboard

Method: clipboard:is-local? self ⇒ %return
Method: is-local? self ⇒ %return

Returns if the clipboard is local.

A clipboard is considered local if it was last claimed by the running application.

Note that clipboard:get-content may return #f even on a local clipboard. In this case the clipboard is empty.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

%return

Returned: a boolean.

#t if the clipboard is local

Method: clipboard:read-async self mime-types io-priority [cancellable] [callback]
Method: read-async self mime-types io-priority [cancellable] [callback]

Asynchronously requests an input stream to read the self’s contents from.

The clipboard will choose the most suitable mime type from the given list to fulfill the request, preferring the ones listed first.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

mime-types

Passed: a list or vector, each a string.

a #f-terminated array of mime types to choose from

io-priority

Passed: a 32-bit integer.

the I/O priority of the request

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: clipboard:read-finish self result ⇒ %return out-mime-type
Method: read-finish self result ⇒ %return out-mime-type

Finishes an asynchronous clipboard read.

See clipboard:read-async.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a <GInputStream>, or #f.

a <GInputStream>

out-mime-type

Returned: a string.

location to store the chosen mime type

Method: clipboard:read-text-async self [cancellable] [callback]
Method: read-text-async self [cancellable] [callback]

Asynchronously request the self contents converted to a string.

This is a simple wrapper around clipboard:read-value-async. Use that function or clipboard:read-async directly if you need more control over the operation.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: clipboard:read-text-finish self result ⇒ %return
Method: read-text-finish self result ⇒ %return

Finishes an asynchronous clipboard read.

See clipboard:read-text-async.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a string, or #f.

a new string

Method: clipboard:read-texture-async self [cancellable] [callback]
Method: read-texture-async self [cancellable] [callback]

Asynchronously request the self contents converted to a <GdkPixbuf>.

This is a simple wrapper around clipboard:read-value-async. Use that function or clipboard:read-async directly if you need more control over the operation.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore.

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: clipboard:read-texture-finish self result ⇒ %return
Method: read-texture-finish self result ⇒ %return

Finishes an asynchronous clipboard read.

See clipboard:read-texture-async.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a <GdkTexture>, or #f.

a new <GdkTexture>

Method: clipboard:read-value-async self type io-priority [cancellable] [callback]
Method: read-value-async self type io-priority [cancellable] [callback]

Asynchronously request the self contents converted to the given type.

For local clipboard contents that are available in the given GType, the value will be copied directly. Otherwise, GDK will try to use content_deserialize_async to convert the clipboard’s data.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

type

Passed: a class, or a GType number.

a GType to read

io-priority

Passed: a 32-bit integer.

the I/O priority of the request

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: clipboard:read-value-finish self result ⇒ %return
Method: read-value-finish self result ⇒ %return

Finishes an asynchronous clipboard read.

See clipboard:read-value-async.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a <GValue>.

a <GValue> containing the result.

Method: clipboard:set self value
Method: set self value

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 GObject.Object.set or GObject.signal_emit.

gdk_clipboard_set (clipboard, G_TYPE_STRING, "Hello World");

gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, some_texture);
self

Passed: a <GdkClipboard>.

a <GdkClipboard>

value

Passed: a <GValue>.

type

type of value to set

...

value contents conforming to type

Method: clipboard:set-content? self [provider] ⇒ %return
Method: set-content? self [provider] ⇒ %return

Sets a new content provider on self.

The clipboard will claim the <GdkDisplay>’s resources and advertise these new contents to other applications.

In the rare case of a failure, this function will return #f. The clipboard will then continue reporting its old contents and ignore provider.

If the contents are read by either an external application or the self’s read functions, self will select the best format to transfer the contents and then request that format from provider.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

provider

Passed, or left out: a <GdkContentProvider>, or #f.

the new contents of self or #f to clear the clipboard

%return

Returned: a boolean.

#t if setting the clipboard succeeded

Method: clipboard:store-async self io-priority [cancellable] [callback]
Method: store-async self io-priority [cancellable] [callback]

Asynchronously instructs the self to store its contents remotely.

If the clipboard is not local, this function does nothing but report success.

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.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

io-priority

Passed: a 32-bit integer.

the I/O priority of the request

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object

callback

Passed, or left out: a procedure, or #f.

callback to call when the request is satisfied

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

the data to pass to callback function

Method: clipboard:store-finish? self result ⇒ %return
Method: store-finish? self result ⇒ %return

Finishes an asynchronous clipboard store.

See clipboard:store-async.

self

Passed: a <GdkClipboard>.

a <GdkClipboard>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t if storing was successful.

Signals

Signal: clipboard:changed

Connect a handler with (connect object clipboard:changed handler). It is called as (handler self).

Emitted when the clipboard changes ownership.

self

Passed: a <GdkClipboard>.