class Gdk::Drop

Overview

The Gdk::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 Gdk::Drop object can be obtained from these Gdk::Event types using Gdk::DNDEvent#drop.

The actual data transfer is initiated from the target side via an async read, using one of the Gdk::Drop methods for this purpose: Gdk::Drop#read_async or Gdk::Drop#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.

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/drop.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new #

Initialize a new Drop.


def self.new(*, actions : Gdk::DragAction? = nil, device : Gdk::Device? = nil, display : Gdk::Display? = nil, drag : Gdk::Drag? = nil, formats : Gdk::ContentFormats? = nil, surface : Gdk::Surface? = nil) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def actions : Gdk::DragAction #

Returns the possible actions for this Gdk::Drop.

If this value contains multiple actions - i.e. Gdk::DragAction#is_unique? returns false for the result - Gdk::Drop#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 Gdk::Drop#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 Gdk::Drop both as a response to source side actions as well as to calls to Gdk::Drop#status or Gdk::Drop#finish. The source side will not change this value anymore once a drop has started.


def actions=(value : Gdk::DragAction) : Gdk::DragAction #

def device : Gdk::Device #

Returns the Gdk::Device performing the drop.


def device=(value : Gdk::Device?) : Gdk::Device? #

def display : Gdk::Display #

Gets the Gdk::Display that @self was created for.


def drag : Gdk::Drag? #

If this is an in-app drag-and-drop operation, returns the Gdk::Drag that corresponds to this drop.

If it is not, nil is returned.


def drag=(value : Gdk::Drag?) : Gdk::Drag? #

def finish(action : Gdk::DragAction) : Nil #

Ends the drag operation after a drop.

The @action must be a single action selected from the actions available via Gdk::Drop#actions.


def formats : Gdk::ContentFormats #

Returns the Gdk::ContentFormats that the drop offers the data to be read in.


def formats=(value : Gdk::ContentFormats?) : Gdk::ContentFormats? #

def read_async(mime_types : Enumerable(String), io_priority : Int32, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil #

Asynchronously read the dropped data from a Gdk::Drop in a format that complies with one of the mime types.


def read_finish(result : Gio::AsyncResult, out_mime_type : String) : Gio::InputStream? #

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 Gdk::Drop#read_async.


def read_value_async(type : UInt64, io_priority : Int32, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil #

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 Gdk::Drop#read_value_finish to get the resulting GValue.

For local drag-and-drop operations that are available in the given GType, the value will be copied directly. Otherwise, GDK will try to use Gdk::content_deserialize_async to convert the data.


def read_value_finish(result : Gio::AsyncResult) : GObject::Value #

Finishes an async drop read.

See Gdk::Drop#read_value_async.


def status(actions : Gdk::DragAction, preferred : Gdk::DragAction) : Nil #

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 Gdk::Drop#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.


def surface : Gdk::Surface #

Returns the Gdk::Surface performing the drop.


def surface=(value : Gdk::Surface?) : Gdk::Surface? #