| 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_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 convtents 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.
typedef struct _GdkContentProvider GdkContentProvider;
Should not be directly accessed.
struct GdkContentProviderClass {
GObjectClass parent_class;
/* signals */
void (* content_changed) (GdkContentProvider *provider);
/* vfuncs */
void (* attach_clipboard) (GdkContentProvider *provider,
GdkClipboard *clipboard);
void (* detach_clipboard) (GdkContentProvider *provider,
GdkClipboard *clipboard);
GdkContentFormats * (* ref_formats) (GdkContentProvider *provider);
GdkContentFormats * (* ref_storable_formats) (GdkContentProvider *provider);
void (* write_mime_type_async) (GdkContentProvider *provider,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* write_mime_type_finish) (GdkContentProvider *provider,
GAsyncResult *result,
GError **error);
gboolean (* get_value) (GdkContentProvider *provider,
GValue *value,
GError **error);
};
“formats” property“formats” GdkContentFormats *
The possible formats that the provider can provide its data in.
Flags: Read
“storable-formats” property“storable-formats” GdkContentFormats *
The subset of formats that clipboard managers should store this provider's data in.
Flags: Read
“content-changed” signalvoid user_function (GdkContentProvider *gdkcontentprovider, gpointer user_data)
Flags: Run Last