About all my projects
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 .Drag.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.

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

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 )
  • $success; whether the drag was ultimatively successful.

get-actions

Determines the bitmask of possible actions proposed by the source.

method get-actions (--> UInt )

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 )

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 )

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 )

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 $drag and will be destroyed when the drag operation is over.

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

Return value; the drag surface.

get-formats

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

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

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

get-selected-action

Determines the action chosen by the drag destination.

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

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 )

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 )
  • $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 )
  • $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 (
   $reason,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gdk4::Drag :$_widget,
  *C<user>-options
)
  • $reason; The reason the drag was cancelled.

  • $_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::Drag 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.

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,
  *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::Drag 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.

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,
  *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::Drag 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.