Top |
Functions
Description
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.
Functions
gdk_content_provider_new_for_value ()
GdkContentProvider *
gdk_content_provider_new_for_value (const GValue *value
);
Create a content provider that provides the given value
.
gdk_content_provider_new_typed ()
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()
.
gdk_content_provider_new_for_bytes ()
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
.
gdk_content_provider_new_union ()
GdkContentProvider * gdk_content_provider_new_union (GdkContentProvider **providers
,gsize n_providers
);
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
1 2 3 4 |
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); |
Parameters
providers |
The GdkContentProviders to present the union of. |
[nullable][array length=n_providers][transfer full] |
n_providers |
the number of providers |
gdk_content_provider_ref_formats ()
GdkContentFormats *
gdk_content_provider_ref_formats (GdkContentProvider *provider
);
Gets the formats that the provider can provide its current contents in.
gdk_content_provider_ref_storable_formats ()
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()
.
gdk_content_provider_content_changed ()
void
gdk_content_provider_content_changed (GdkContentProvider *provider
);
Emits the “content-changed” signal.
gdk_content_provider_write_mime_type_async ()
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.
Parameters
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] |
gdk_content_provider_write_mime_type_finish ()
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()
.
gdk_content_provider_get_value ()
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.
Types and Values
GdkContentProvider
typedef struct _GdkContentProvider GdkContentProvider;
Should not be directly accessed.
struct GdkContentProviderClass
struct GdkContentProviderClass { GObjectClass parent_class; /* signals */ void (* content_changed) (GdkContentProvider *provider); };
Class structure for GdkContentProvider.
Property Details
The “formats”
property
“formats” GdkContentFormats *
The possible formats that the provider can provide its data in.
Owner: GdkContentProvider
Flags: Read
The “storable-formats”
property
“storable-formats” GdkContentFormats *
The subset of formats that clipboard managers should store this provider's data in.
Owner: GdkContentProvider
Flags: Read
Signal Details
The “content-changed”
signal
void user_function (GdkContentProvider *gdkcontentprovider, gpointer user_data)
Emitted whenever the content provided by this provider has changed.
Flags: Run Last