1.52 <GtkDropTargetAsync>

Class: <GtkDropTargetAsync>

It derives from <GtkEventController>.

An event controller to receive Drag-and-Drop operations, asynchronously.

It is the more complete but also more complex method of handling drop operations compared to <GtkDropTarget>, and you should only use it if <GtkDropTarget> doesn’t provide all the features you need.

To use a <GtkDropTargetAsync> to receive drops on a widget, you create a <GtkDropTargetAsync> object, configure which data formats and actions you support, connect to its signals, and then attach it to the widget with widget:add-controller.

During a drag operation, the first signal that a <GtkDropTargetAsync> emits is drop-target-async:accept, which is meant to determine whether the target is a possible drop site for the ongoing drop. The default handler for the ::accept signal accepts the drop if it finds a compatible data format and an action that is supported on both sides.

If it is, and the widget becomes a target, you will receive a drop-target-async:drag-enter signal, followed by drop-target-async:drag-motion signals as the pointer moves, optionally a drop-target-async:drop signal when a drop happens, and finally a drop-target-async:drag-leave signal when the pointer moves off the widget.

The ::drag-enter and ::drag-motion handler return a <GdkDragAction> to update the status of the ongoing operation. The ::drop handler should decide if it ultimately accepts the drop and if it does, it should initiate the data transfer and finish the operation by calling drop:finish.

Between the ::drag-enter and ::drag-leave signals the widget is a current drop target, and will receive the drop-active state, which can be used by themes to style the widget as a drop target.

Properties

Property: drop-target-async:actions self

The GdkDragActions that this drop target supports.

Its value is a <GdkDragAction> (or, to set it, a list of its symbols, or one of them).

Set it with (set! (drop-target-async:actions self) value).

Property: drop-target-async:formats self

The <GdkContentFormats> that determines the supported data formats.

Its value is a <GdkContentFormats>, or #f.

Set it with (set! (drop-target-async:formats self) value).

Procedures

Method: drop-target-async:get-actions self ⇒ %return
Method: get-actions self ⇒ %return

Gets the actions that this drop target supports.

self

Passed: a <GtkDropTargetAsync>.

a <GtkDropTargetAsync>

%return

Returned: a <GdkDragAction>.

the actions that this drop target supports

Method: drop-target-async:get-formats self ⇒ %return
Method: get-formats self ⇒ %return

Gets the data formats that this drop target accepts.

If the result is #f, all formats are expected to be supported.

self

Passed: a <GtkDropTargetAsync>.

a <GtkDropTargetAsync>

%return

Returned: a <GdkContentFormats>, or #f.

the supported data formats

Procedure: drop-target-async:new formats actions ⇒ %return

Creates a new <GtkDropTargetAsync> object.

formats

Passed: a <GdkContentFormats>, or #f.

the supported data formats

actions

Passed: a <GdkDragAction>, or a list of its symbols, or one of them.

the supported actions

%return

Returned: a <GtkDropTargetAsync>.

the new <GtkDropTargetAsync>

Method: drop-target-async:reject-drop self drop
Method: reject-drop self drop

Sets the drop as not accepted on this drag site.

This function should be used when delaying the decision on whether to accept a drag or not until after reading the data.

self

Passed: a <GtkDropTargetAsync>.

a <GtkDropTargetAsync>

drop

Passed: a <GdkDrop>.

the <GdkDrop> of an ongoing drag operation

Method: drop-target-async:set-actions self actions
Method: set-actions self actions

Sets the actions that this drop target supports.

self

Passed: a <GtkDropTargetAsync>.

a <GtkDropTargetAsync>

actions

Passed: a <GdkDragAction>, or a list of its symbols, or one of them.

the supported actions

Method: drop-target-async:set-formats self [formats]
Method: set-formats self [formats]

Sets the data formats that this drop target will accept.

self

Passed: a <GtkDropTargetAsync>.

a <GtkDropTargetAsync>

formats

Passed, or left out: a <GdkContentFormats>, or #f.

the supported data formats or #f for any format

Signals

Signal: drop-target-async:accept

Connect a handler with (connect object drop-target-async:accept handler). It is called as (handler self drop) ⇒ %return.

Emitted on the drop site when a drop operation is about to begin.

If the drop is not accepted, #f will be returned and the drop target will ignore the drop. If #t is returned, the drop is accepted for now but may be rejected later via a call to drop-target-async:reject-drop or ultimately by returning #f from a drop-target-async:drop handler.

The default handler for this signal decides whether to accept the drop based on the formats provided by the drop.

If the decision whether the drop will be accepted or rejected needs further processing, such as inspecting the data, this function should return #t and proceed as is drop was accepted and if it decides to reject the drop later, it should call drop-target-async:reject-drop.

self

Passed: a <GtkDropTargetAsync>.

drop

Passed: a <GdkDrop>.

the <GdkDrop>

%return

Returned: a boolean.

#t if drop is accepted

Signal: drop-target-async:drag-enter

Connect a handler with (connect object drop-target-async:drag-enter handler). It is called as (handler self drop x y) ⇒ %return.

Emitted on the drop site when the pointer enters the widget.

It can be used to set up custom highlighting.

self

Passed: a <GtkDropTargetAsync>.

drop

Passed: a <GdkDrop>.

the <GdkDrop>

x

Passed: a real number.

the x coordinate of the current pointer position

y

Passed: a real number.

the y coordinate of the current pointer position

%return

Returned: a <GdkDragAction>, or a list of its symbols, or one of them.

Preferred action for this drag operation.

Signal: drop-target-async:drag-leave

Connect a handler with (connect object drop-target-async:drag-leave handler). It is called as (handler self drop).

Emitted on the drop site when the pointer leaves the widget.

Its main purpose it to undo things done in <GtkDropTargetAsync>::drag-enter.

self

Passed: a <GtkDropTargetAsync>.

drop

Passed: a <GdkDrop>.

the <GdkDrop>

Signal: drop-target-async:drag-motion

Connect a handler with (connect object drop-target-async:drag-motion handler). It is called as (handler self drop x y) ⇒ %return.

Emitted while the pointer is moving over the drop target.

self

Passed: a <GtkDropTargetAsync>.

drop

Passed: a <GdkDrop>.

the <GdkDrop>

x

Passed: a real number.

the x coordinate of the current pointer position

y

Passed: a real number.

the y coordinate of the current pointer position

%return

Returned: a <GdkDragAction>, or a list of its symbols, or one of them.

Preferred action for this drag operation.

Signal: drop-target-async:drop

Connect a handler with (connect object drop-target-async:drop handler). It is called as (handler self drop x y) ⇒ %return.

Emitted on the drop site when the user drops the data onto the widget.

The signal handler must determine whether the pointer position is in a drop zone or not. If it is not in a drop zone, it returns #f and no further processing is necessary.

Otherwise, the handler returns #t. In this case, this handler will accept the drop. The handler must ensure that drop:finish is called to let the source know that the drop is done. The call to drop:finish must only be done when all data has been received.

To receive the data, use one of the read functions provided by <GdkDrop> such as drop:read-async or drop:read-value-async.

self

Passed: a <GtkDropTargetAsync>.

drop

Passed: a <GdkDrop>.

the <GdkDrop>

x

Passed: a real number.

the x coordinate of the current pointer position

y

Passed: a real number.

the y coordinate of the current pointer position

%return

Returned: a boolean.

whether the drop is accepted at the given pointer position