
Gnome::Gdk4::ContentProvider
Description
A Gnome::Gdk4::ContentProvider is used to provide content for the clipboard or for drag-and-drop operations in a number of formats.
To create a Gnome::Gdk4::ContentProvider, use .new-for-value()
or .new-for-bytes()
.
GDK knows how to handle common text and image formats out-of-the-box. See Gnome::Gdk4::ContentSerializer and Gnome::Gdk4::ContentDeserializer if you want to add support for application-specific data formats.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-for-bytes
Create a content provider that provides the given $bytes
as data for the given $mime-type
.
method new-for-bytes ( Str $mime-type, N-Object $bytes --> Gnome::Gdk4::ContentProvider \)
$mime-type; the mime type.
$bytes; a Gnome::Glib::N-Bytes with the data for
$mime-type
new-for-value
Create a content provider that provides the given $value
.
method new-for-value ( N-Object $value --> Gnome::Gdk4::ContentProvider \)
$value; a Gnome::GObject::N-Value
new-typed This function is not yet available
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().
method new-typed ( GType $type, … --> Gnome::Gdk4::ContentProvider \)
$type; Type of value to follow.
…; …. Note that each argument must be specified as a type followed by its value!
new-union
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
method new-union ( N-Object() $providers, Int() $n-providers --> Gnome::Gdk4::ContentProvider \)
$providers; (transfer ownership: full) The Gnome::Gdk4::ContentProviders to present the union of.
$n-providers; the number of providers.
Methods
content-changed
Emits the content-changed signal.
method content-changed ( )
get-value
Gets the contents of $provider
stored in $value
.
The $value
will have been initialized to the Gnome::GObject::ContentProvider the value should be provided in. This given Gnome::GObject::ContentProvider does not need to be listed in the formats returned by .ref-formats()
. However, if the given Gnome::GObject::ContentProvider is not supported, this operation can fail and G_IO_ERROR_NOT_SUPPORTED will be reported.
method get-value ( N-Object $value, CArray[N-Error] $err --> Bool )
$value; the Gnome::GObject::N-Value to fill
$err; Error object. When defined, an error can be returned when there is one. Use
Pointer
when you want to ignore the error. .
Return value; True
if the value was set successfully. Otherwise $error
will be set to describe the failure..
ref-formats
Gets the formats that the provider can provide its current contents in.
method ref-formats (--> N-Object )
Return value; The formats of the provider.
ref-storable-formats
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 .ref-formats()
.
method ref-storable-formats (--> N-Object )
Return value; The storable formats of the provider.
write-mime-type-async
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 .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 .ref-formats()
. However, if the given Gnome::GObject::ContentProvider is not supported, G_IO_ERROR_NOT_SUPPORTED will be reported.
The given $stream
will not be closed.
method write-mime-type-async ( Str $mime-type, N-Object() $stream, Int() $io-priority, N-Object() $cancellable, GAsyncReadyCallback &callback, gpointer $user-data )
$mime-type; the mime type to provide the data in.
$stream; the Gnome::Gio::OutputStream to write to.
$io-priority; I/O priority of the request..
$cancellable; optional Gnome::Gio::Cancellable object, undefined to ignore..
GAsyncReadyCallback &callback; callback to call when the request is satisfied. The function must be specified with the following signature;
:( N-Object $source-object, N-Object $res, gpointer $data )
.$user-data; the data to pass to callback function.
write-mime-type-finish
Finishes an asynchronous write operation.
See .write-mime-type-async()
.
method write-mime-type-finish ( N-Object() $result, CArray[N-Error] $err --> Bool )
$result; a Gnome::Gio::R-AsyncResult.
$err; Error object. When defined, an error can be returned when there is one. Use
Pointer
when you want to ignore the error. .
Return value; True
if the operation was completed successfully. Otherwise $error
will be set to describe the failure..
Signals
content-changed
Emitted whenever the content provided by this provider has changed.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gdk4::ContentProvider :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gdk4::ContentProvider object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.