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.
-
Untyped pointer to the underlying
GdkDrop
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
drop_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 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 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:
Extension methodvalue: ) 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
-
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 methodReturns the possible actions for this
GdkDrop
.If this value contains multiple actions - i.e. [func
Gdk.DragAction.is_unique
] returnsfalse
for the result - [methodGdk.Drop.finish
] must choose the action to use when accepting the drop. This will only happen if you passedGDK_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 [class
Gdk.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 methodReturns the
GdkDevice
performing the drop.Declaration
Swift
@inlinable func getDevice() -> DeviceRef!
-
getDisplay()
Extension methodGets the
GdkDisplay
thatself
was created for.Declaration
Swift
@inlinable func getDisplay() -> DisplayRef!
-
getDrag()
Extension methodIf 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 methodReturns the
GdkContentFormats
that the drop offers the data to be read in.Declaration
Swift
@inlinable func getFormats() -> ContentFormatsRef!
-
getSurface()
Extension methodReturns the
GdkSurface
performing the drop.Declaration
Swift
@inlinable func getSurface() -> SurfaceRef!
-
readAsync(mimeTypes:
Extension methodioPriority: cancellable: callback: userData: ) 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)
-
readAsync(mimeTypes:
Extension methodioPriority: cancellable: callback: userData: ) 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
-
readFinish(result:
Extension methodoutMimeType: ) 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 [method
Gdk.Drop.read_async
].Declaration
Swift
@inlinable func readFinish<AsyncResultT>(result: AsyncResultT, outMimeType: UnsafeMutablePointer<UnsafePointer<CChar>?>!) throws -> GIO.InputStreamRef! where AsyncResultT : AsyncResultProtocol
-
readValueAsync(type:
Extension methodioPriority: cancellable: callback: userData: ) 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 resultingGValue
.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)
-
readValueAsync(type:
Extension methodioPriority: cancellable: callback: userData: ) 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 resultingGValue
.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 [method
Gdk.Drop.read_value_async
].Declaration
Swift
@inlinable func readValueFinish<AsyncResultT>(result: AsyncResultT) throws -> GLibObject.ValueRef! where AsyncResultT : AsyncResultProtocol
-
status(actions:
Extension methodpreferred: ) 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 [method
Gdk.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
orGDK_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 methodThe possible actions for this drop
Declaration
Swift
@inlinable var actions: DragAction { get }
-
device
Extension methodThe
GdkDevice
performing the dropDeclaration
Swift
@inlinable var device: DeviceRef! { get }
-
display
Extension methodThe
GdkDisplay
that the drop belongs to.Declaration
Swift
@inlinable var display: DisplayRef! { get }
-
drag
Extension methodThe
GdkDrag
that initiated this dropDeclaration
Swift
@inlinable var drag: DragRef! { get }
-
formats
Extension methodThe possible formats that the drop can provide its data in.
Declaration
Swift
@inlinable var formats: ContentFormatsRef! { get }
-
surface
Extension methodThe
GdkSurface
the drop happens onDeclaration
Swift
@inlinable var surface: SurfaceRef! { get }