Class Drop
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Drop.Drop$Impl
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 Event types using DNDEvent.getDrop().
The actual data transfer is initiated from the target side via an async
read, using one of the GdkDrop methods for this purpose:
readAsync(String[], int, Cancellable, AsyncReadyCallback) or readValueAsync(Type, int, Cancellable, AsyncReadyCallback).
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDrop.Builder<B extends Drop.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe Drop$Impl type represents a native instance of the abstract Drop class.Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionDrop()Create a new Drop.Drop(MemorySegment address) Create a Drop instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DropasParent()Return this instance as if it were its parent type.voidfinish(Set<DragAction> action) Ends the drag operation after a drop.voidfinish(DragAction... action) Ends the drag operation after a drop.Returns the possible actions for thisGdkDrop.Returns theGdkDeviceperforming the drop.Gets theGdkDisplaythat this Drop was created for.@Nullable DraggetDrag()If this is an in-app drag-and-drop operation, returns theGdkDragthat corresponds to this drop.Returns theGdkContentFormatsthat the drop offers the data to be read in.static MemoryLayoutThe memory layout of the native struct.Returns theGdkSurfaceperforming the drop.static @Nullable TypegetType()Get the GType of the Drop class.voidreadAsync(@Nullable String @Nullable [] mimeTypes, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously read the dropped data from aGdkDropin a format that complies with one of the mime types.@Nullable InputStreamreadFinish(AsyncResult result, Out<String> outMimeType) Finishes an async drop read operation.voidreadValueAsync(Type type, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously request the drag operation's contents converted to the giventype.readValueFinish(AsyncResult result) Finishes an async drop read.voidstatus(Set<DragAction> actions, Set<DragAction> preferred) Selects all actions that are potentially supported by the destination.voidstatus(DragAction actions, DragAction... preferred) Selects all actions that are potentially supported by the destination.Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Drop
Create a Drop instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Drop
public Drop()Create a new Drop.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
-
finish
Ends the drag operation after a drop.
The
actionmust be a single action selected from the actions available viagetActions().- Parameters:
action- the action performed by the destination orGDK_ACTION_NONEif the drop failed
-
finish
Ends the drag operation after a drop.
The
actionmust be a single action selected from the actions available viagetActions().- Parameters:
action- the action performed by the destination orGDK_ACTION_NONEif the drop failed
-
getActions
Returns the possible actions for this
GdkDrop.If this value contains multiple actions - i.e.
DragAction.isUnique()returns false for the result -finish(Set)must choose the action to use when accepting the drop. This will only happen if you passedGDK_ACTION_ASKas one of the possible actions instatus(Set, Set).GDK_ACTION_ASKitself will not be included in the actions returned by this function.This value may change over the lifetime of the
Dropboth as a response to source side actions as well as to calls tostatus(Set, Set)orfinish(Set). The source side will not change this value anymore once a drop has started.- Returns:
- The possible
GdkDragActions
-
getDevice
Returns theGdkDeviceperforming the drop.- Returns:
- The
GdkDeviceperforming the drop.
-
getDisplay
Gets theGdkDisplaythat this Drop was created for.- Returns:
- a
GdkDisplay
-
getDrag
If this is an in-app drag-and-drop operation, returns the
GdkDragthat corresponds to this drop.If it is not,
NULLis returned.- Returns:
- the corresponding
GdkDrag
-
getFormats
Returns theGdkContentFormatsthat the drop offers the data to be read in.- Returns:
- The possible
GdkContentFormats
-
getSurface
Returns theGdkSurfaceperforming the drop.- Returns:
- The
GdkSurfaceperforming the drop.
-
readAsync
public void readAsync(@Nullable String @Nullable [] mimeTypes, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously read the dropped data from aGdkDropin a format that complies with one of the mime types.- Parameters:
mimeTypes- pointer to an array of mime typesioPriority- the I/O priority for the read operationcancellable- optionalGCancellableobjectcallback- aGAsyncReadyCallbackto call when the request is satisfied
-
readFinish
public @Nullable InputStream readFinish(AsyncResult result, Out<String> outMimeType) throws GErrorException 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
readAsync(String[], int, Cancellable, AsyncReadyCallback).- Parameters:
result- aGAsyncResultoutMimeType- return location for the used mime type- Returns:
- the
GInputStream - Throws:
GErrorException- seeGError
-
readValueAsync
public void readValueAsync(Type type, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously request the drag operation's contents converted to the given
type.For local drag-and-drop operations that are available in the given
GType, the value will be copied directly. Otherwise, GDK will try to useGdk.contentDeserializeAsync(InputStream, String, Type, int, Cancellable, AsyncReadyCallback)to convert the data.- Parameters:
type- aGTypeto readioPriority- the I/O priority of the request.cancellable- optionalGCancellableobject,nullto ignore.callback- callback to call when the request is satisfied
-
readValueFinish
Finishes an async drop read.
See
readValueAsync(Type, int, Cancellable, AsyncReadyCallback).- Parameters:
result- aGAsyncResult- Returns:
- a
GValuecontaining the result. - Throws:
GErrorException- seeGError
-
status
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
getActions(). Those actions may change in the future, even depending on the actions you provide here.The
preferredaction is a hint to the drag-and-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_ENTERorGDK_DRAG_MOTIONevents. 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.- Parameters:
actions- Supported actions of the destination, orGDK_ACTION_NONEto indicate that a drop will not be acceptedpreferred- A unique action that's a member ofactionsindicating the preferred action
-
status
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
getActions(). Those actions may change in the future, even depending on the actions you provide here.The
preferredaction is a hint to the drag-and-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_ENTERorGDK_DRAG_MOTIONevents. 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.- Parameters:
actions- Supported actions of the destination, orGDK_ACTION_NONEto indicate that a drop will not be acceptedpreferred- A unique action that's a member ofactionsindicating the preferred action
-