Gdk.ContentProvider¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/en |
|||
r/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted whenever the content provided by this provider has changed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Gdk.ContentProvider(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A
GdkContentProvider
is used to provide content for the clipboard or for drag-and-drop operations in a number of formats.To create a
GdkContentProvider
, use [ctor`Gdk`.ContentProvider.new_for_value] or [ctor`Gdk`.ContentProvider.new_for_bytes].GDK knows how to handle common text and image formats out-of-the-box. See [class`Gdk`.ContentSerializer] and [class`Gdk`.ContentDeserializer] if you want to add support for application-specific data formats.
- classmethod new_for_bytes(mime_type, bytes)[source]¶
- Parameters:
mime_type (
str
) – the mime typebytes (
GLib.Bytes
) – aGBytes
with the data for mime_type
- Returns:
a new
GdkContentProvider
- Return type:
Create a content provider that provides the given bytes as data for the given mime_type.
- classmethod new_for_value(value)[source]¶
- Parameters:
value (
GObject.Value
) – aGValue
- Returns:
a new
GdkContentProvider
- Return type:
Create a content provider that provides the given value.
- classmethod new_union(providers)[source]¶
- Parameters:
providers ([
Gdk.ContentProvider
] orNone
) – The ``GdkContentProvider``s to present the union of- Returns:
a new
GdkContentProvider
- Return type:
Creates a content provider that represents all the given providers.
Whenever data needs to be written, the union provider will try the given providers in the given order and the first one supporting a format will be chosen to provide it.
This allows an easy way to support providing data in different formats. For example, an image may be provided by its file and by the image contents with a call such as ``c gdk_content_provider_new_union ((GdkContentProvider *[2]) {
gdk_content_provider_new_typed (G_TYPE_FILE, file), gdk_content_provider_new_typed (G_TYPE_TEXTURE, texture)
}, 2);
- content_changed()[source]¶
Emits the
::content-changed
signal.
- get_value()[source]¶
- Raises:
- Returns:
True
if the value was set successfully. Otherwise error will be set to describe the failure.- value:
the
GValue
to fill
- Return type:
(
bool
, value:GObject.Value
)
Gets the contents of self stored in value.
The value will have been initialized to the
GType
the value should be provided in. This givenGType
does not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the givenGType
is not supported, this operation can fail andG_IO_ERROR_NOT_SUPPORTED
will be reported.
- ref_formats()[source]¶
- Returns:
The formats of the provider
- Return type:
Gets the formats that the provider can provide its current contents in.
- ref_storable_formats()[source]¶
- Returns:
The storable formats of the provider
- Return type:
Gets the formats that the provider suggests other applications to store the data in.
An example of such an application would be a clipboard manager.
This can be assumed to be a subset of [method`Gdk`.ContentProvider.ref_formats].
- write_mime_type_async(mime_type, stream, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
mime_type (
str
) – the mime type to provide the data instream (
Gio.OutputStream
) – theGOutputStream
to write toio_priority (
int
) – I/O priority of the request.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 writes the contents of self to stream in the given mime_type.
When the operation is finished callback will be called. You must then call [method`Gdk`.ContentProvider.write_mime_type_finish] to get the result of the operation.
The given mime type does not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the given
GType
is not supported,G_IO_ERROR_NOT_SUPPORTED
will be reported.The given stream will not be closed.
- write_mime_type_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
True
if the operation was completed successfully. Otherwise error will be set to describe the failure.- Return type:
Finishes an asynchronous write operation.
See [method`Gdk`.ContentProvider.write_mime_type_async].
- do_attach_clipboard(clipboard) virtual¶
- Parameters:
clipboard (
Gdk.Clipboard
) –
- do_content_changed() virtual¶
Emits the
::content-changed
signal.
- do_detach_clipboard(clipboard) virtual¶
- Parameters:
clipboard (
Gdk.Clipboard
) –
- do_get_value() virtual¶
- Returns:
True
if the value was set successfully. Otherwise error will be set to describe the failure.- value:
the
GValue
to fill
- Return type:
(
bool
, value:GObject.Value
)
Gets the contents of provider stored in value.
The value will have been initialized to the
GType
the value should be provided in. This givenGType
does not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the givenGType
is not supported, this operation can fail andG_IO_ERROR_NOT_SUPPORTED
will be reported.
- do_ref_formats() virtual¶
- Returns:
The formats of the provider
- Return type:
Gets the formats that the provider can provide its current contents in.
- do_ref_storable_formats() virtual¶
- Returns:
The storable formats of the provider
- Return type:
Gets the formats that the provider suggests other applications to store the data in.
An example of such an application would be a clipboard manager.
This can be assumed to be a subset of [method`Gdk`.ContentProvider.ref_formats].
- do_write_mime_type_async(mime_type, stream, io_priority, cancellable, callback, *user_data) virtual¶
- Parameters:
mime_type (
str
) – the mime type to provide the data instream (
Gio.OutputStream
) – theGOutputStream
to write toio_priority (
int
) – I/O priority of the request.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 writes the contents of provider to stream in the given mime_type.
When the operation is finished callback will be called. You must then call [method`Gdk`.ContentProvider.write_mime_type_finish] to get the result of the operation.
The given mime type does not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the given
GType
is not supported,G_IO_ERROR_NOT_SUPPORTED
will be reported.The given stream will not be closed.
- do_write_mime_type_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Returns:
True
if the operation was completed successfully. Otherwise error will be set to describe the failure.- Return type:
Finishes an asynchronous write operation.
See [method`Gdk`.ContentProvider.write_mime_type_async].
Signal Details¶
- Gdk.ContentProvider.signals.content_changed(content_provider)¶
- Signal Name:
content-changed
- Flags:
- Parameters:
content_provider (
Gdk.ContentProvider
) – The object which received the signal
Emitted whenever the content provided by this provider has changed.
Property Details¶
- Gdk.ContentProvider.props.formats¶
- Name:
formats
- Type:
- Default Value:
- Flags:
The possible formats that the provider can provide its data in.
- Gdk.ContentProvider.props.storable_formats¶
- Name:
storable-formats
- Type:
- Default Value:
- Flags:
The subset of formats that clipboard managers should store this provider’s data in.