Gnome::Gdk4::Drag

#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

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

=end rakudoc

#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

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! )

=end rakudoc

#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Methods =end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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 )

Return value; the drag surface.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-formats

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

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

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
}

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- #--[Functions]------------------------------------------------------------------ #-------------------------------------------------------------------------------

=begin rakudoc

Functions =end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

=end rakudoc

#------------------------------------------------------------------------------- #--[Signal Documentation]------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Signals

cancel

Emitted when the drag operation is cancelled.

method handler (
  UInt $reason,
  Int :$_handle_id,
  N-Object :$_native-object,
  *%user-options
)

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-Object :$_native-object,
  *%user-options
)
  • $_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-Object :$_native-object,
  *%user-options
)
  • $_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.

=end rakudoc

Gnome::Gdk4 v0.1.23

Authors

  • Marcel Timmerman

License

Artistic-2.0

Dependencies

Gnome::Gio:api<2>Gnome::GObject:api<2>Gnome::Glib:api<2>Gnome::N:api<2>

Test Dependencies

Provides

  • Gnome::Gdk4::ContentProvider
  • Gnome::Gdk4::Display
  • Gnome::Gdk4::Drag
  • Gnome::Gdk4::Drop
  • Gnome::Gdk4::MemoryTexture
  • Gnome::Gdk4::N-ContentFormats
  • Gnome::Gdk4::N-ContentFormatsBuilder
  • Gnome::Gdk4::N-FileList
  • Gnome::Gdk4::N-RGBA
  • Gnome::Gdk4::N-Rectangle
  • Gnome::Gdk4::R-Paintable
  • Gnome::Gdk4::Snapshot
  • Gnome::Gdk4::Surface
  • Gnome::Gdk4::T-contentformats
  • Gnome::Gdk4::T-drag
  • Gnome::Gdk4::T-enums
  • Gnome::Gdk4::T-keysyms
  • Gnome::Gdk4::T-paintable
  • Gnome::Gdk4::T-rgba
  • Gnome::Gdk4::T-texture
  • Gnome::Gdk4::T-types
  • Gnome::Gdk4::Texture

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.