DropTargetAsyncProtocol
public protocol DropTargetAsyncProtocol : EventControllerProtocol
GtkDropTargetAsync
is 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 [classGtk.DropTarget
], 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 [methodGtk.Widget.add_controller
].
During a drag operation, the first signal that a GtkDropTargetAsync
emits is [signalGtk.DropTargetAsync::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
[signalGtk.DropTargetAsync::drag-enter
] signal, followed by
[signalGtk.DropTargetAsync::drag-motion
] signals as the pointer moves,
optionally a [signalGtk.DropTargetAsync::drop
] signal when a drop happens,
and finally a [signalGtk.DropTargetAsync::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
[methodGdk.Drop.finish
].
Between the drag-enter
and drag-leave
signals the widget is a
current drop target, and will receive the GTK_STATE_FLAG_DROP_ACTIVE
state, which can be used by themes to style the widget as a drop target.
The DropTargetAsyncProtocol
protocol exposes the methods and properties of an underlying GtkDropTargetAsync
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see DropTargetAsync
.
Alternatively, use DropTargetAsyncRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkDropTargetAsync
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
drop_target_async_ptr
Default implementationTyped pointer to the underlying
GtkDropTargetAsync
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkDropTargetAsync
instance.Declaration
Swift
var drop_target_async_ptr: UnsafeMutablePointer<GtkDropTargetAsync>! { get }
-
Required Initialiser for types conforming to
DropTargetAsyncProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
DropTargetAsyncPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: DropTargetAsyncPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a DropTargetAsync property
Declaration
Swift
@inlinable func get(property: DropTargetAsyncPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a DropTargetAsync property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: DropTargetAsyncPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
DropTargetAsyncSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: DropTargetAsyncSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
DropTargetAsyncSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: DropTargetAsyncSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onAccept(flags:
Extension methodhandler: ) Emitted on the drop site when a drop operation is about to begin.
If the drop is not accepted,
false
will be returned and the drop target will ignore the drop. Iftrue
is returned, the drop is accepted for now but may be rejected later via a call to [methodGtk.DropTargetAsync.reject_drop
] or ultimately by returningfalse
from a [signalGtk.DropTargetAsync::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
true
and proceed as isdrop
was accepted and if it decides to reject the drop later, it should call [methodGtk.DropTargetAsync.reject_drop
].Note
This represents the underlyingaccept
signalDeclaration
Swift
@discardableResult @inlinable func onAccept(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ drop: Gdk.DropRef) -> Bool) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
drop
the
GdkDrop
handler
true
ifdrop
is accepted Run the given callback whenever theaccept
signal is emitted -
acceptSignal
Extension methodTyped
accept
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var acceptSignal: DropTargetAsyncSignalName { get }
-
onDragEnter(flags:
Extension methodhandler: ) Emitted on the drop site when the pointer enters the widget.
It can be used to set up custom highlighting.
Note
This represents the underlyingdrag-enter
signalDeclaration
Swift
@discardableResult @inlinable func onDragEnter(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ drop: Gdk.DropRef, _ x: Double, _ y: Double) -> Gdk.DragAction) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
drop
the
GdkDrop
x
the x coordinate of the current pointer position
y
the y coordinate of the current pointer position
handler
Preferred action for this drag operation. Run the given callback whenever the
dragEnter
signal is emitted -
dragEnterSignal
Extension methodTyped
drag-enter
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var dragEnterSignal: DropTargetAsyncSignalName { get }
-
onDragLeave(flags:
Extension methodhandler: ) Emitted on the drop site when the pointer leaves the widget.
Its main purpose it to undo things done in
GtkDropTargetAsync
drag-enter
.Note
This represents the underlyingdrag-leave
signalDeclaration
Swift
@discardableResult @inlinable func onDragLeave(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ drop: Gdk.DropRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
drop
the
GdkDrop
handler
The signal handler to call Run the given callback whenever the
dragLeave
signal is emitted -
dragLeaveSignal
Extension methodTyped
drag-leave
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var dragLeaveSignal: DropTargetAsyncSignalName { get }
-
onDragMotion(flags:
Extension methodhandler: ) Emitted while the pointer is moving over the drop target.
Note
This represents the underlyingdrag-motion
signalDeclaration
Swift
@discardableResult @inlinable func onDragMotion(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ drop: Gdk.DropRef, _ x: Double, _ y: Double) -> Gdk.DragAction) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
drop
the
GdkDrop
x
the x coordinate of the current pointer position
y
the y coordinate of the current pointer position
handler
Preferred action for this drag operation. Run the given callback whenever the
dragMotion
signal is emitted -
dragMotionSignal
Extension methodTyped
drag-motion
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var dragMotionSignal: DropTargetAsyncSignalName { get }
-
onDrop(flags:
Extension methodhandler: ) 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
false
and no further processing is necessary.Otherwise, the handler returns
true
. In this case, this handler will accept the drop. The handler must ensure that [methodGdk.Drop.finish
] is called to let the source know that the drop is done. The call to [methodGdk.Drop.finish
] must only be done when all data has been received.To receive the data, use one of the read functions provided by [class
Gdk.Drop
] such as [methodGdk.Drop.read_async
] or [methodGdk.Drop.read_value_async
].Note
This represents the underlyingdrop
signalDeclaration
Swift
@discardableResult @inlinable func onDrop(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ drop: Gdk.DropRef, _ x: Double, _ y: Double) -> Bool) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
drop
the
GdkDrop
x
the x coordinate of the current pointer position
y
the y coordinate of the current pointer position
handler
whether the drop is accepted at the given pointer position Run the given callback whenever the
drop
signal is emitted -
dropSignal
Extension methodTyped
drop
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var dropSignal: DropTargetAsyncSignalName { get }
-
onNotifyActions(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::actions
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyActions(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyActions
signal is emitted -
notifyActionsSignal
Extension methodTyped
notify::actions
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyActionsSignal: DropTargetAsyncSignalName { get }
-
onNotifyFormats(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::formats
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyFormats(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DropTargetAsyncRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyFormats
signal is emitted -
notifyFormatsSignal
Extension methodTyped
notify::formats
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyFormatsSignal: DropTargetAsyncSignalName { get }
-
getActions()
Extension methodGets the actions that this drop target supports.
Declaration
Swift
@inlinable func getActions() -> Gdk.DragAction
-
getFormats()
Extension methodGets the data formats that this drop target accepts.
If the result is
nil
, all formats are expected to be supported.Declaration
Swift
@inlinable func getFormats() -> Gdk.ContentFormatsRef!
-
reject(drop:
Extension method) 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.
Declaration
Swift
@inlinable func reject<DropT>(drop: DropT) where DropT : DropProtocol
-
set(actions:
Extension method) Sets the actions that this drop target supports.
Declaration
Swift
@inlinable func set(actions: Gdk.DragAction)
-
set(formats:
Extension method) Sets the data formats that this drop target will accept.
Declaration
Swift
@inlinable func set(formats: Gdk.ContentFormatsRef? = nil)
-
set(formats:
Extension method) Sets the data formats that this drop target will accept.
Declaration
Swift
@inlinable func set<ContentFormatsT>(formats: ContentFormatsT?) where ContentFormatsT : ContentFormatsProtocol
-
actions
Extension methodThe
GdkDragActions
that this drop target supports.Declaration
Swift
@inlinable var actions: Gdk.DragAction { get nonmutating set }
-
formats
Extension methodThe
GdkContentFormats
that determines the supported data formats.Declaration
Swift
@inlinable var formats: Gdk.ContentFormatsRef! { get nonmutating set }