Gdk.Clipboard¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/en |
|||
r/w/co/en |
|||
r/en |
|||
r/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the clipboard changes ownership. |
Fields¶
- Inherited:
Class Details¶
- class Gdk.Clipboard(**kwargs)¶
- Bases:
- Abstract:
No
The
GdkClipboard
object represents data shared between applications or inside an application.To get a
GdkClipboard
object, use [method`Gdk`.Display.get_clipboard] or [method`Gdk`.Display.get_primary_clipboard]. You can find out about the data that is currently available in a clipboard using [method`Gdk`.Clipboard.get_formats].To make text or image data available in a clipboard, use [method`Gdk`.Clipboard.set_text] or [method`Gdk`.Clipboard.set_texture]. For other data, you can use [method`Gdk`.Clipboard.set_content], which takes a [class`Gdk`.ContentProvider] object.
To read textual or image data from a clipboard, use [method`Gdk`.Clipboard.read_text_async] or [method`Gdk`.Clipboard.read_texture_async]. For other data, use [method`Gdk`.Clipboard.read_async], which provides a
GInputStream
object.- get_content()[source]¶
- Returns:
The content of a clipboard if the clipboard does not maintain any content
- Return type:
Returns the
GdkContentProvider
currently set on self.If the self is empty or its contents are not owned by the current process,
None
will be returned.
- get_display()[source]¶
- Returns:
a
GdkDisplay
- Return type:
Gets the
GdkDisplay
that the clipboard was created for.
- get_formats()[source]¶
- Returns:
The formats of the clipboard
- Return type:
Gets the formats that the clipboard can provide its current contents in.
- is_local()[source]¶
-
Returns if the clipboard is local.
A clipboard is considered local if it was last claimed by the running application.
Note that [method`Gdk`.Clipboard.get_content] may return
None
even on a local clipboard. In this case the clipboard is empty.
- read_async(mime_types, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
mime_types ([
str
]) – aNone
-terminated array of mime types to choose fromio_priority (
int
) – the I/O priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
Asynchronously requests an input stream to read the self's contents from.
When the operation is finished callback will be called. You must then call [method`Gdk`.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)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
a
GInputStream
- out_mime_type:
location to store the chosen mime type
- Return type:
(
Gio.InputStream
orNone
, out_mime_type:str
)
Finishes an asynchronous clipboard read.
See [method`Gdk`.Clipboard.read_async].
- read_text_async(cancellable, callback, *user_data)[source]¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
Asynchronously request the self contents converted to a string.
When the operation is finished callback will be called. You must then call [method`Gdk`.Clipboard.read_text_finish] to get the result.
This is a simple wrapper around [method`Gdk`.Clipboard.read_value_async]. Use that function or [method`Gdk`.Clipboard.read_async] directly if you need more control over the operation.
- read_text_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
a new string
- Return type:
Finishes an asynchronous clipboard read.
See [method`Gdk`.Clipboard.read_text_async].
- read_texture_async(cancellable, callback, *user_data)[source]¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
Asynchronously request the self contents converted to a
GdkPixbuf
.When the operation is finished callback will be called. You must then call [method`Gdk`.Clipboard.read_texture_finish] to get the result.
This is a simple wrapper around [method`Gdk`.Clipboard.read_value_async]. Use that function or [method`Gdk`.Clipboard.read_async] directly if you need more control over the operation.
- read_texture_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
a new
GdkTexture
- Return type:
Gdk.Texture
orNone
Finishes an asynchronous clipboard read.
See [method`Gdk`.Clipboard.read_texture_async].
- read_value_async(type, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
type (
GObject.GType
) – aGType
to readio_priority (
int
) – the I/O priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
Asynchronously request the self contents converted to the given type.
When the operation is finished callback will be called. You must then call [method`Gdk`.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 [func`content_deserialize_async`] to convert the clipboard’s data.
- read_value_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
a
GValue
containing the result.- Return type:
Finishes an asynchronous clipboard read.
See [method`Gdk`.Clipboard.read_value_async].
- set(value)[source]¶
- Parameters:
value (
GObject.Value
) – aGValue
to set
Sets the self to contain the given value.
- set_content(provider)[source]¶
- Parameters:
provider (
Gdk.ContentProvider
orNone
) – the new contents of self orNone
to clear the clipboard- Returns:
True
if setting the clipboard succeeded- Return type:
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
False
. 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.
- store_async(io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
io_priority (
int
) – the I/O priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGCancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – callback to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
Asynchronously instructs the self to store its contents remotely.
If the clipboard is not local, this function does nothing but report success.
The callback must call [method`Gdk`.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)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
True
if storing was successful.- Return type:
Finishes an asynchronous clipboard store.
See [method`Gdk`.Clipboard.store_async].
Signal Details¶
- Gdk.Clipboard.signals.changed(clipboard)¶
- Signal Name:
changed
- Flags:
- Parameters:
clipboard (
Gdk.Clipboard
) – The object which received the signal
Emitted when the clipboard changes ownership.
Property Details¶
- Gdk.Clipboard.props.content¶
- Name:
content
- Type:
- Default Value:
- Flags:
The
GdkContentProvider
orNone
if the clipboard is empty or contents are provided otherwise.
- Gdk.Clipboard.props.display¶
- Name:
display
- Type:
- Default Value:
- Flags:
The
GdkDisplay
that the clipboard belongs to.
- Gdk.Clipboard.props.formats¶
- Name:
formats
- Type:
- Default Value:
- Flags:
The possible formats that the clipboard can provide its data in.