Top | ![]() |
![]() |
![]() |
![]() |
A GdkContentProvider is used to provide content for the clipboard in a number of formats.
To create a GdkContentProvider, use gdk_content_provider_new_for_value()
or
gdk_content_provider_new_for_bytes()
.
GDK knows how to handle common text and image formats out-of-the-box. See GdkContentSerializer and GdkContentDeserializer if you want to add support for application-specific data formats.
GdkContentProvider *
gdk_content_provider_new_for_value (const GValue *value
);
Create a content provider that provides the given value
.
GdkContentProvider * gdk_content_provider_new_typed (GType type
,...
);
Create a content provider that provides the value of the given
type
.
The value is provided using G_VALUE_COLLECT()
, so the same rules
apply as when calling g_object_new()
or g_object_set()
.
GdkContentProvider * gdk_content_provider_new_for_bytes (const char *mime_type
,GBytes *bytes
);
Create a content provider that provides the given bytes
as data for
the given mime_type
.
GdkContentFormats *
gdk_content_provider_ref_formats (GdkContentProvider *provider
);
Gets the formats that the provider can provide its current contents in.
GdkContentFormats *
gdk_content_provider_ref_storable_formats
(GdkContentProvider *provider
);
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 gdk_content_provider_ref_formats()
.
void
gdk_content_provider_content_changed (GdkContentProvider *provider
);
Emits the “contents-changed” signal.
void gdk_content_provider_write_mime_type_async (GdkContentProvider *provider
,const char *mime_type
,GOutputStream *stream
,int io_priority
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronously writes the contents of provider
to stream
in the given
mime_type
. When the operation is finished callback
will be called. You
can then call gdk_content_provider_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
gdk_content_provider_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.
provider |
||
mime_type |
the mime type to provide the data in |
|
stream |
the GOutputStream to write to |
|
io_priority |
the I/O priority of the request. |
|
cancellable |
optional GCancellable object, |
[nullable] |
callback |
callback to call when the request is satisfied. |
[scope async] |
user_data |
the data to pass to callback function. |
[closure] |
gboolean gdk_content_provider_write_mime_type_finish (GdkContentProvider *provider
,GAsyncResult *result
,GError **error
);
Finishes an asynchronous write operation started with
gdk_content_provider_write_mime_type_async()
.
gboolean gdk_content_provider_get_value (GdkContentProvider *provider
,GValue *value
,GError **error
);
Gets the contents of provider
stored in value
.
The value
will have been initialized to the GType the value should be
provided in. This given GType does not need to be listed in the formats
returned by gdk_content_provider_ref_formats()
. However, if the given
GType is not supported, this operation can fail and
G_IO_ERROR_NOT_SUPPORTED will be reported.
“formats”
property“formats” GdkContentFormats *
The possible formats that the provider can provide its data in.
Owner: GdkContentProvider
Flags: Read
“storable-formats”
property“storable-formats” GdkContentFormats *
The subset of formats that clipboard managers should store this provider's data in.
Owner: GdkContentProvider
Flags: Read
“content-changed”
signalvoid user_function (GdkContentProvider *gdkcontentprovider, gpointer user_data)
Emitted whenever the content provided by this provider has changed.
Flags: Run Last