Package ch.bailu.gtk.gtk
Class DropTargetAsync
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.EventController
ch.bailu.gtk.gtk.DropTargetAsync
- All Implemented Interfaces:
PointerInterface
`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 [class@Gtk.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 [method@Gtk.Widget.add_controller].
During a drag operation, the first signal that a `GtkDropTargetAsync`
emits is [signal@Gtk.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
[signal@Gtk.DropTargetAsync::drag-enter] signal, followed by
[signal@Gtk.DropTargetAsync::drag-motion] signals as the pointer moves,
optionally a [signal@Gtk.DropTargetAsync::drop] signal when a drop happens,
and finally a [signal@Gtk.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
[method@Gdk.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.
operations, asynchronously.
It is the more complete but also more complex method of handling drop
operations compared to [class@Gtk.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 [method@Gtk.Widget.add_controller].
During a drag operation, the first signal that a `GtkDropTargetAsync`
emits is [signal@Gtk.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
[signal@Gtk.DropTargetAsync::drag-enter] signal, followed by
[signal@Gtk.DropTargetAsync::drag-motion] signals as the pointer moves,
optionally a [signal@Gtk.DropTargetAsync::drop] signal when a drop happens,
and finally a [signal@Gtk.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
[method@Gdk.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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionDropTargetAsync
(ContentFormats formats, int actions) Creates a new `GtkDropTargetAsync` object.DropTargetAsync
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the actions that this drop target supports.static ClassHandler
Gets the data formats that this drop target accepts.static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
onAccept
(DropTargetAsync.OnAccept signal) Connect to signal "accept".Connect to signal "drag-enter".Connect to signal "drag-leave".Connect to signal "drag-motion".onDrop
(DropTargetAsync.OnDrop signal) Connect to signal "drop".void
rejectDrop
(Drop drop) Sets the @drop as not accepted on this drag site.void
setActions
(int actions) Sets the actions that this drop target supports.void
setFormats
(ContentFormats formats) Sets the data formats that this drop target will accept.Methods inherited from class ch.bailu.gtk.gtk.EventController
getCurrentEvent, getCurrentEventDevice, getCurrentEventState, getCurrentEventTime, getName, getPropagationLimit, getPropagationPhase, getWidget, reset, setName, setName, setPropagationLimit, setPropagationPhase, setStaticName, setStaticName
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_ACCEPT
- See Also:
-
SIGNAL_ON_DRAG_ENTER
- See Also:
-
SIGNAL_ON_DRAG_LEAVE
- See Also:
-
SIGNAL_ON_DRAG_MOTION
- See Also:
-
SIGNAL_ON_DROP
- See Also:
-
-
Constructor Details
-
DropTargetAsync
-
DropTargetAsync
Creates a new `GtkDropTargetAsync` object.- Parameters:
formats
- the supported data formatsactions
- the supported actions
-
-
Method Details
-
getClassHandler
-
getActions
public int getActions()Gets the actions that this drop target supports.- Returns:
- the actions that this drop target supports
-
getFormats
Gets the data formats that this drop target accepts.
If the result is %NULL, all formats are expected to be supported.- Returns:
- the supported data formats
-
rejectDrop
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.- Parameters:
drop
- the `GdkDrop` of an ongoing drag operation
-
setActions
public void setActions(int actions) Sets the actions that this drop target supports.- Parameters:
actions
- the supported actions
-
setFormats
Sets the data formats that this drop target will accept.- Parameters:
formats
- the supported data formats or %NULL for any format
-
onAccept
Connect to signal "accept".
SeeDropTargetAsync.OnAccept.onAccept(ch.bailu.gtk.gdk.Drop)
for signal description.
FieldSIGNAL_ON_ACCEPT
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onDragEnter
Connect to signal "drag-enter".
SeeDropTargetAsync.OnDragEnter.onDragEnter(ch.bailu.gtk.gdk.Drop, double, double)
for signal description.
FieldSIGNAL_ON_DRAG_ENTER
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onDragLeave
Connect to signal "drag-leave".
SeeDropTargetAsync.OnDragLeave.onDragLeave(ch.bailu.gtk.gdk.Drop)
for signal description.
FieldSIGNAL_ON_DRAG_LEAVE
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onDragMotion
Connect to signal "drag-motion".
SeeDropTargetAsync.OnDragMotion.onDragMotion(ch.bailu.gtk.gdk.Drop, double, double)
for signal description.
FieldSIGNAL_ON_DRAG_MOTION
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onDrop
Connect to signal "drop".
SeeDropTargetAsync.OnDrop.onDrop(ch.bailu.gtk.gdk.Drop, double, double)
for signal description.
FieldSIGNAL_ON_DROP
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-