Class Drop
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Drop.DropImpl
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 EventType.DRAG_ENTER
, EventType.DRAG_LEAVE
,
EventType.DRAG_MOTION
and EventType.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(java.lang.String[], int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
or readValueAsync(org.gnome.glib.Type, int, org.gnome.gio.Cancellable, org.gnome.gio.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
Modifier and TypeClassDescriptionstatic class
Drop.Builder<B extends Drop.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
The DropImpl type represents a native instance of the abstract Drop class.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionDrop
(MemorySegment address) Create a Drop proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Drop
asParent()
Returns this instance as if it were its parent type.static Drop.Builder
<? extends Drop.Builder> builder()
ADrop.Builder
object constructs aDrop
with the specified properties.void
finish
(Set<DragAction> action) Ends the drag operation after a drop.void
finish
(DragAction... action) Ends the drag operation after a drop.Returns the possible actions for thisGdkDrop
.Returns theGdkDevice
performing the drop.Gets theGdkDisplay
that this Drop was created for.getDrag()
If this is an in-app drag-and-drop operation, returns theGdkDrag
that corresponds to this drop.Returns theGdkContentFormats
that the drop offers the data to be read in.Returns theGdkSurface
performing the drop.static Type
getType()
Get the GType of the Drop classvoid
readAsync
(String[] mimeTypes, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously read the dropped data from aGdkDrop
in a format that complies with one of the mime types.readFinish
(AsyncResult result, Out<String> outMimeType) Finishes an async drop read operation.void
readValueAsync
(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.void
status
(Set<DragAction> actions, Set<DragAction> preferred) Selects all actions that are potentially supported by the destination.void
status
(DragAction actions, DragAction... preferred) Selects all actions that are potentially supported by the destination.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Drop
Create a Drop proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
finish
Ends the drag operation after a drop.The
action
must be a single action selected from the actions available viagetActions()
.- Parameters:
action
- the action performed by the destination or 0 if the drop failed
-
finish
Ends the drag operation after a drop.The
action
must be a single action selected from the actions available viagetActions()
.- Parameters:
action
- the action performed by the destination or 0 if the drop failed
-
getActions
Returns the possible actions for thisGdkDrop
.If this value contains multiple actions - i.e.
DragAction.isUnique()
returnsfalse
for the result -finish(java.util.Set<org.gnome.gdk.DragAction>)
must choose the action to use when accepting the drop. This will only happen if you passedDragAction.ASK
as one of the possible actions instatus(java.util.Set<org.gnome.gdk.DragAction>, java.util.Set<org.gnome.gdk.DragAction>)
.DragAction.ASK
itself will not be included in the actions returned by this function.This value may change over the lifetime of the
Drop
both as a response to source side actions as well as to calls tostatus(java.util.Set<org.gnome.gdk.DragAction>, java.util.Set<org.gnome.gdk.DragAction>)
orfinish(java.util.Set<org.gnome.gdk.DragAction>)
. The source side will not change this value anymore once a drop has started.- Returns:
- The possible
GdkDragActions
-
getDevice
Returns theGdkDevice
performing the drop.- Returns:
- The
GdkDevice
performing the drop.
-
getDisplay
Gets theGdkDisplay
that this Drop was created for.- Returns:
- a
GdkDisplay
-
getDrag
If this is an in-app drag-and-drop operation, returns theGdkDrag
that corresponds to this drop.If it is not,
null
is returned.- Returns:
- the corresponding
GdkDrag
-
getFormats
Returns theGdkContentFormats
that the drop offers the data to be read in.- Returns:
- The possible
GdkContentFormats
-
getSurface
Returns theGdkSurface
performing the drop.- Returns:
- The
GdkSurface
performing the drop.
-
readAsync
public void readAsync(String[] mimeTypes, int ioPriority, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously read the dropped data from aGdkDrop
in 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
- optionalGCancellable
objectcallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
readFinish
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(java.lang.String[], int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
.- Parameters:
result
- aGAsyncResult
outMimeType
- return location for the used mime type- Returns:
- the
GInputStream
- Throws:
GErrorException
- seeGError
-
readValueAsync
public void readValueAsync(Type type, int ioPriority, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously request the drag operation's contents converted to the giventype
.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(org.gnome.gio.InputStream, java.lang.String, org.gnome.glib.Type, int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
to convert the data.- Parameters:
type
- aGType
to readioPriority
- the I/O priority of the request.cancellable
- optionalGCancellable
object,null
to ignore.callback
- callback to call when the request is satisfied
-
readValueFinish
Finishes an async drop read.- Parameters:
result
- aGAsyncResult
- Returns:
- a
GValue
containing 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
preferred
action 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
EventType.DRAG_ENTER
orEventType.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.- Parameters:
actions
- Supported actions of the destination, or 0 to indicate that a drop will not be acceptedpreferred
- A unique action that's a member ofactions
indicating 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
preferred
action 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
EventType.DRAG_ENTER
orEventType.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.- Parameters:
actions
- Supported actions of the destination, or 0 to indicate that a drop will not be acceptedpreferred
- A unique action that's a member ofactions
indicating the preferred action
-
builder
ADrop.Builder
object constructs aDrop
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDrop.Builder.build()
.
-