DropProtocol

public protocol DropProtocol : ObjectProtocol

The DropProtocol protocol exposes the methods and properties of an underlying GdkDrop 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 Drop. Alternatively, use DropRef as a lighweight, unowned reference if you already have an instance you just want to use.

The GdkDrop 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 GdkDrop object can be obtained from these [classGdk.Event] types using [methodGdk.DNDEvent.get_drop].

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

  • ptr

    Untyped pointer to the underlying GdkDrop instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GdkDrop instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkDrop instance.

    Declaration

    Swift

    var drop_ptr: UnsafeMutablePointer<GdkDrop>! { get }
  • Required Initialiser for types conforming to DropProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Drop Class

  • Bind a DropPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: DropPropertyName, 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 Drop property

    Declaration

    Swift

    @inlinable
    func get(property: DropPropertyName) -> 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 Drop property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: DropPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Drop Class: DropProtocol extension (methods and fields)

  • finish(action:) Extension method

    Ends the drag operation after a drop.

    The action must be a single action selected from the actions available via [methodGdk.Drop.get_actions].

    Declaration

    Swift

    @inlinable
    func finish(action: DragAction)
  • getActions() Extension method

    Returns the possible actions for this GdkDrop.

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

    Declaration

    Swift

    @inlinable
    func getActions() -> DragAction
  • getDevice() Extension method

    Returns the GdkDevice performing the drop.

    Declaration

    Swift

    @inlinable
    func getDevice() -> DeviceRef!
  • getDisplay() Extension method

    Gets the GdkDisplay that self was created for.

    Declaration

    Swift

    @inlinable
    func getDisplay() -> DisplayRef!
  • getDrag() Extension method

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

    If it is not, nil is returned.

    Declaration

    Swift

    @inlinable
    func getDrag() -> DragRef!
  • getFormats() Extension method

    Returns the GdkContentFormats that the drop offers the data to be read in.

    Declaration

    Swift

    @inlinable
    func getFormats() -> ContentFormatsRef!
  • getSurface() Extension method

    Returns the GdkSurface performing the drop.

    Declaration

    Swift

    @inlinable
    func getSurface() -> SurfaceRef!
  • Asynchronously read the dropped data from a GdkDrop in a format that complies with one of the mime types.

    Declaration

    Swift

    @inlinable
    func readAsync(mimeTypes: UnsafeMutablePointer<UnsafePointer<CChar>?>!, ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil)
  • Asynchronously read the dropped data from a GdkDrop in a format that complies with one of the mime types.

    Declaration

    Swift

    @inlinable
    func readAsync<CancellableT>(mimeTypes: UnsafeMutablePointer<UnsafePointer<CChar>?>!, ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol
  • 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 [methodGdk.Drop.read_async].

    Declaration

    Swift

    @inlinable
    func readFinish<AsyncResultT>(result: AsyncResultT, outMimeType: UnsafeMutablePointer<UnsafePointer<CChar>?>!) throws -> GIO.InputStreamRef! where AsyncResultT : AsyncResultProtocol
  • 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 [methodGdk.Drop.read_value_finish] to get the resulting GValue.

    For local drag'n'drop operations that are available in the given GType, the value will be copied directly. Otherwise, GDK will try to use [funcGdk.content_deserialize_async] to convert the data.

    Declaration

    Swift

    @inlinable
    func readValueAsync(type: GType, ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = 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 [methodGdk.Drop.read_value_finish] to get the resulting GValue.

    For local drag'n'drop operations that are available in the given GType, the value will be copied directly. Otherwise, GDK will try to use [funcGdk.content_deserialize_async] to convert the data.

    Declaration

    Swift

    @inlinable
    func readValueAsync<CancellableT>(type: GType, ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol
  • readValueFinish(result:) Extension method

    Finishes an async drop read.

    See [methodGdk.Drop.read_value_async].

    Declaration

    Swift

    @inlinable
    func readValueFinish<AsyncResultT>(result: AsyncResultT) throws -> GLibObject.ValueRef! where AsyncResultT : AsyncResultProtocol
  • status(actions:preferred:) Extension method

    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 [methodGdk.Drop.get_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'n'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.

    Declaration

    Swift

    @inlinable
    func status(actions: DragAction, preferred: DragAction)
  • actions Extension method

    The possible actions for this drop

    Declaration

    Swift

    @inlinable
    var actions: DragAction { get }
  • device Extension method

    The GdkDevice performing the drop

    Declaration

    Swift

    @inlinable
    var device: DeviceRef! { get }
  • display Extension method

    The GdkDisplay that the drop belongs to.

    Declaration

    Swift

    @inlinable
    var display: DisplayRef! { get }
  • drag Extension method

    The GdkDrag that initiated this drop

    Declaration

    Swift

    @inlinable
    var drag: DragRef! { get }
  • formats Extension method

    The possible formats that the drop can provide its data in.

    Declaration

    Swift

    @inlinable
    var formats: ContentFormatsRef! { get }
  • surface Extension method

    The GdkSurface the drop happens on

    Declaration

    Swift

    @inlinable
    var surface: SurfaceRef! { get }