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.

  • ptr

    Untyped pointer to the underlying GtkDropTargetAsync instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • drop_target_async_ptr Default implementation

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

DropTargetAsync Class

  • 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return 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:value:) Extension method

    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

DropTargetAsync signals

  • Connect a Swift signal handler to the given, typed DropTargetAsyncSignalName signal

    Declaration

    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 by userData

    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 a C signal handler to the given, typed DropTargetAsyncSignalName signal

    Declaration

    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 by userData

    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:handler:) Extension method

    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. If true is returned, the drop is accepted for now but may be rejected later via a call to [methodGtk.DropTargetAsync.reject_drop] or ultimately by returning false 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 is drop was accepted and if it decides to reject the drop later, it should call [methodGtk.DropTargetAsync.reject_drop].

    Note

    This represents the underlying accept signal

    Declaration

    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 if drop is accepted Run the given callback whenever the accept signal is emitted

  • acceptSignal Extension method

    Typed accept signal for using the connect(signal:) methods

    Declaration

    Swift

    static var acceptSignal: DropTargetAsyncSignalName { get }
  • onDragEnter(flags:handler:) Extension method

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

    It can be used to set up custom highlighting.

    Note

    This represents the underlying drag-enter signal

    Declaration

    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 method

    Typed drag-enter signal for using the connect(signal:) methods

    Declaration

    Swift

    static var dragEnterSignal: DropTargetAsyncSignalName { get }
  • onDragLeave(flags:handler:) Extension method

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

    Its main purpose it to undo things done in GtkDropTargetAsyncdrag-enter.

    Note

    This represents the underlying drag-leave signal

    Declaration

    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 method

    Typed drag-leave signal for using the connect(signal:) methods

    Declaration

    Swift

    static var dragLeaveSignal: DropTargetAsyncSignalName { get }
  • onDragMotion(flags:handler:) Extension method

    Emitted while the pointer is moving over the drop target.

    Note

    This represents the underlying drag-motion signal

    Declaration

    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 method

    Typed drag-motion signal for using the connect(signal:) methods

    Declaration

    Swift

    static var dragMotionSignal: DropTargetAsyncSignalName { get }
  • onDrop(flags:handler:) Extension method

    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 [classGdk.Drop] such as [methodGdk.Drop.read_async] or [methodGdk.Drop.read_value_async].

    Note

    This represents the underlying drop signal

    Declaration

    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 method

    Typed drop signal for using the connect(signal:) methods

    Declaration

    Swift

    static var dropSignal: DropTargetAsyncSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::actions signal

    Declaration

    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 method

    Typed notify::actions signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyActionsSignal: DropTargetAsyncSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::formats signal

    Declaration

    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 method

    Typed notify::formats signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyFormatsSignal: DropTargetAsyncSignalName { get }

DropTargetAsync Class: DropTargetAsyncProtocol extension (methods and fields)

  • getActions() Extension method

    Gets the actions that this drop target supports.

    Declaration

    Swift

    @inlinable
    func getActions() -> Gdk.DragAction
  • getFormats() Extension method

    Gets 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 method

    The GdkDragActions that this drop target supports.

    Declaration

    Swift

    @inlinable
    var actions: Gdk.DragAction { get nonmutating set }
  • formats Extension method

    The GdkContentFormats that determines the supported data formats.

    Declaration

    Swift

    @inlinable
    var formats: Gdk.ContentFormatsRef! { get nonmutating set }