
Gnome::Gdk4::Drop
Description
The Gnome::Gdk4::Drop object represents the target of an ongoing DND operation.
Possible drop sites get informed about the status of the ongoing drag operation with events of type GDK_DRAG_ENTER
, GDK_DRAG_LEAVE
, GDK_DRAG_MOTION
and GDK_DROP_START
. The Gnome::Gdk4::Drop object can be obtained from these Gnome::Gdk4::Event types using .get-drop()
in class Gnome::Gdk4::DNDEvent
.
The actual data transfer is initiated from the target side via an async read, using one of the Gnome::Gdk4::Drop methods for this purpose: .read-async()
or .read-value-async()
.
GTK provides a higher level abstraction based on top of these functions, and so they are not normally needed in GTK applications. See the "Drag and Drop" section of the GTK documentation for more information.
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! )
Methods
finish
Ends the drag operation after a drop.
The $action
must be a single action selected from the actions available via .get-actions()
.
method finish ( UInt $action )
$action; the action performed by the destination or 0 if the drop failed.
get-actions
Returns the possible actions for this Gnome::Gdk4::Drop.
If this value contains multiple actions - i.e. .DragAction.is-unique()
returns False
for the result - .finish()
must choose the action to use when accepting the drop. This will only happen if you passed GDK_ACTION_ASK
as one of the possible actions in .status()
. GDK_ACTION_ASK
itself will not be included in the actions returned by this function.
This value may change over the lifetime of the Gnome::Gdk4::Drop both as a response to source side actions as well as to calls to .status()
or .finish()
. The source side will not change this value anymore once a drop has started.
method get-actions (--> UInt )
Return value; The possible GdkDragActions.
get-device
Returns the Gnome::Gdk4::Device performing the drop.
method get-device (--> N-Object )
Return value; The Gnome::Gdk4::Device performing the drop..
get-display
Gets the Gnome::Gdk4::Display that $self
was created for.
method get-display (--> N-Object )
Return value; a Gnome::Gdk4::Display.
get-drag
If this is an in-app drag-and-drop operation, returns the Gnome::Gdk4::Drag that corresponds to this drop.
If it is not, undefined is returned.
method get-drag (--> N-Object )
Return value; the corresponding Gnome::Gdk4::Drag.
get-formats
Returns the Gnome::Gdk4::N-ContentFormats that the drop offers the data to be read in.
method get-formats (--> N-Object )
Return value; The possible Gnome::Gdk4::N-ContentFormats.
get-surface
Returns the Gnome::Gdk4::Surface performing the drop.
method get-surface (--> N-Object )
Return value; The Gnome::Gdk4::Surface performing the drop..
read-async
Asynchronously read the dropped data from a Gnome::Gdk4::Drop in a format that complies with one of the mime types.
method read-async ( Array[Str] $mime-types, Int() $io-priority, N-Object() $cancellable, GAsyncReadyCallback &callback, gpointer $user-data )
$mime-types; pointer to an array of mime types.
$io-priority; the I/O priority for the read operation.
$cancellable; optional Gnome::Gio::Cancellable object.
GAsyncReadyCallback &callback; a Gnome::Gio::T-iotypes 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
.
read-finish
Finishes an async drop read operation.
Note that you must not use blocking read calls on the returned stream in the GTK thread, since some platforms might require communication with GTK to complete the data transfer. You can use async APIs such as g_input_stream_read_bytes_async().
See .read-async()
.
method read-finish ( N-Object() $result, Array[Str] $out-mime-type, CArray[N-Error] $err --> N-Object )
$result; a Gnome::Gio::R-AsyncResult.
$out-mime-type; (transfer ownership: full) return location for the used mime type.
$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; the Gnome::Gio::InputStream.
read-value-async
Asynchronously request the drag operation's contents converted to the given $type
.
When the operation is finished $callback
will be called. You must then call .read-value-finish()
to get the resulting Gnome::GObject::N-Value.
For local drag-and-drop operations that are available in the given Gnome::GObject::Drop, the value will be copied directly. Otherwise, GDK will try to use .content-deserialize-async()
to convert the data.
method read-value-async ( GType $type, Int() $io-priority, N-Object() $cancellable, GAsyncReadyCallback &callback, gpointer $user-data )
$type; a Gnome::GObject::Drop to read.
$io-priority; the 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.
read-value-finish
Finishes an async drop read.
See .read-value-async()
.
method read-value-finish ( N-Object() $result, CArray[N-Error] $err --> N-Object )
$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; a Gnome::GObject::N-Value containing the result..
status
Selects all actions that are potentially supported by the destination.
When calling this function, do not restrict the passed in actions to the ones provided by .get-actions()
. Those actions may change in the future, even depending on the actions you provide here.
The $preferred
action is a hint to the drag-and-drop mechanism about which action to use when multiple actions are possible.
This function should be called by drag destinations in response to GDK_DRAG_ENTER
or GDK_DRAG_MOTION
events. If the destination does not yet know the exact actions it supports, it should set any possible actions first and then later call this function again.
method status ( UInt $actions, UInt $preferred )
$actions; Supported actions of the destination, or 0 to indicate that a drop will not be accepted.
$preferred; A unique action that's a member of
$actions
indicating the preferred action.