About my projects, examples and tutorials
Gnome::Gdk4::Drag

Gnome::Gdk4::Drag

Description§

The Gnome::Gdk4::Drag object represents the source of an ongoing DND operation.

A Gnome::Gdk4::Drag is created when a drag is started, and stays alive for duration of the DND operation. After a drag has been started with .begin(), the caller gets informed about the status of the ongoing drag operation with signals on the Gnome::Gdk4::Drag object.

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.

Uml Diagram§

UNKNOWN image§

=for image :class<inline> :src<asset_files/images/plantuml/Drag.png> :width<70\%>

Class initialization§

new§

:native-object§

Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object() :$native-object! )
Code

Methods§

drop-done§

Informs GDK that the drop ended.

Passing False for $success may trigger a drag cancellation animation.

This function is called by the drag source, and should be the last call before dropping the reference to the $drag.

The Gnome::Gdk4::Drag will only take the first .drop-done() call as effective, if this function is called multiple times, all subsequent calls will be ignored.

method drop-done ( Bool() $success )
Code
  • $success; whether the drag was ultimatively successful.

get-actions§

Determines the bitmask of possible actions proposed by the source.

method get-actions ( --> UInt )
Code

Return value; the bit field GdkDragAction defined in Gnome::Gdk4::T-enums flags.

get-content§

Returns the Gnome::Gdk4::ContentProvider associated to the Gnome::Gdk4::Drag object.

method get-content ( --> N-Object )
Code

Return value; The Gnome::Gdk4::ContentProvider associated to $drag.

get-device§

Returns the Gnome::Gdk4::Device associated to the Gnome::Gdk4::Drag object.

method get-device ( --> N-Object )
Code

Return value; The Gnome::Gdk4::Device associated to $drag.

get-display§

Gets the Gnome::Gdk4::Display that the drag object was created for.

method get-display ( --> N-Object )
Code

Return value; a Gnome::Gdk4::Display.

get-drag-surface§

Returns the surface on which the drag icon should be rendered during the drag operation.

Note that the surface may not be available until the drag operation has begun. GDK will move the surface in accordance with the ongoing drag operation. The surface is owned by the drag object and will be destroyed when the drag operation is over.

method get-drag-surface ( --> N-Object )
Code

Return value; the drag surface.

get-formats§

Retrieves the formats supported by this Gnome::Gdk4::Drag object.

method get-formats ( --> N-Object )
Code

Return value; a native Gnome::Gdk4::N-ContentFormats object.

Example§

my Gnome::Gdk4::N-ContentFormats() $formats = $drag.get-formats;
my $size = CArray[gsize].new(0);
my Array $mime-types = $formats.get-mime-types($size);

if $mime-types.first( 'text/plain', :k) {
  # process the data as a text
}
Code

get-selected-action§

Determines the action chosen by the drag destination.

method get-selected-action ( --> UInt )
Code

Return value; a bit field GdkDragAction defined in Gnome::Gdk4::T-enums value.

get-surface§

Returns the Gnome::Gdk4::Surface where the drag originates.

method get-surface ( --> N-Object )
Code

Return value; The Gnome::Gdk4::Surface where the drag originates.

set-hotspot§

Sets the position of the drag surface that will be kept under the cursor hotspot.

Initially, the hotspot is at the top left corner of the drag surface.

method set-hotspot ( Int() $hot-x, Int() $hot-y )
Code
  • $hot-x; x coordinate of the drag surface hotspot.
  • $hot-y; y coordinate of the drag surface hotspot.

Functions§

begin§

Starts a drag and creates a new drag context for it.

This function is called by the drag source. After this call, you probably want to set up the drag icon using the surface returned by .get-drag-surface().

This function returns a reference to the Gnome::Gdk4::Drag object, but GTK keeps its own reference as well, as long as the DND operation is going on.

Note: if $actions include GDK_ACTION_MOVE, you need to listen for the dnd-finished signal and delete the data at the source if .get-selected-action() returns GDK_ACTION_MOVE.

method begin (
  N-Object() $surface, N-Object() $device, N-Object() $content,
  UInt $actions, Num() $dx, Num() $dy
  --> N-Object
)
Code
  • $surface; the source surface for this drag.
  • $device; the device that controls this drag.
  • $content; the offered content.
  • $actions; the actions supported by this drag.
  • $dx; the x offset to $device's position where the drag nominally started.
  • $dy; the y offset to $device's position where the drag nominally started.

Return value; a newly created Gnome::Gdk4::Drag.

Signals§

cancel§

Emitted when the drag operation is cancelled.

method handler (
  UInt $reason,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gdk4::Drag :$_widget,
  *%user-options
)
Code

dnd-finished§

Emitted when the destination side has finished reading all data.

The drag object can now free all miscellaneous data.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gdk4::Drag :$_widget,
  *%user-options
)
Code
  • $_handle_id; The registered event handler id.
  • $_native-object; The native object provided by the Raku object which registered this event. This is a native Gnome::Gdk4::Drag object.
  • %user-options; A list of named arguments provided by .register-signal() in class Gnome.

drop-performed§

Emitted when the drop operation is performed on an accepting client.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gdk4::Drag :$_widget,
  *%user-options
)
Code
  • $_handle_id; The registered event handler id.
  • $_native-object; The native object provided by the Raku object which registered this event. This is a native Gnome::Gdk4::Drag object.
  • %user-options; A list of named arguments provided by .register-signal() in class Gnome.