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:
Provides 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) – aGByteswith 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 (GDK_TYPE_TEXTURE, texture)
}, 2);
- content_changed()[source]¶
Emits the
::content-changedsignal.
- get_value()[source]¶
- Raises:
- Returns:
Trueif the value was set successfully. Otherwise error will be set to describe the failure.- value:
the
GValueto fill
- Return type:
(
bool, value:GObject.Value)
Gets the contents of self stored in value.
The value will have been initialized to the
GTypethe value should be provided in. This givenGTypedoes not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the givenGTypeis not supported, this operation can fail andG_IO_ERROR_NOT_SUPPORTEDwill 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) – theGOutputStreamto write toio_priority (
int) – I/O priority of the request.cancellable (
Gio.CancellableorNone) – optionalGCancellableobject,Noneto ignore.callback (
Gio.AsyncReadyCallbackorNone) – callback to call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
Asynchronously writes the contents of self to stream in the given mime_type.
The given mime type does not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the given
GTypeis not supported,G_IO_ERROR_NOT_SUPPORTEDwill be reported.The given stream will not be closed.
- write_mime_type_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult) – aGAsyncResult- Raises:
- Returns:
Trueif 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-changedsignal.
- do_detach_clipboard(clipboard) virtual¶
- Parameters:
clipboard (
Gdk.Clipboard) –
- do_get_value() virtual¶
- Returns:
Trueif the value was set successfully. Otherwise error will be set to describe the failure.- value:
the
GValueto fill
- Return type:
(
bool, value:GObject.Value)
Gets the contents of provider stored in value.
The value will have been initialized to the
GTypethe value should be provided in. This givenGTypedoes not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the givenGTypeis not supported, this operation can fail andG_IO_ERROR_NOT_SUPPORTEDwill 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) – theGOutputStreamto write toio_priority (
int) – I/O priority of the request.cancellable (
Gio.CancellableorNone) – optionalGCancellableobject,Noneto ignore.callback (
Gio.AsyncReadyCallbackorNone) – callback to call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
Asynchronously writes the contents of provider to stream in the given mime_type.
The given mime type does not need to be listed in the formats returned by [method`Gdk`.ContentProvider.ref_formats]. However, if the given
GTypeis not supported,G_IO_ERROR_NOT_SUPPORTEDwill be reported.The given stream will not be closed.
- do_write_mime_type_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult) – aGAsyncResult- Returns:
Trueif 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.