Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 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 widgetAddController
.
During a drag operation, the first signal that a GtkDropTargetAsync
emits is 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 DropTargetAsync::dragEnter signal, followed by DropTargetAsync::dragMotion signals as the pointer moves, optionally a DropTargetAsync::drop signal when a drop happens, and finally a DropTargetAsync::dragLeave signal when the pointer moves off the widget.
The dragEnter and dragMotion 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
dropFinish
.
Between the dragEnter and dragLeave signals the widget is a
current drop target, and will receive the StateFlagsDropActive
state, which can be used by themes to style the widget as a drop target.
Synopsis
- newtype DropTargetAsync = DropTargetAsync (ManagedPtr DropTargetAsync)
- class (GObject o, IsDescendantOf DropTargetAsync o) => IsDropTargetAsync o
- toDropTargetAsync :: (MonadIO m, IsDropTargetAsync o) => o -> m DropTargetAsync
- dropTargetAsyncGetActions :: (HasCallStack, MonadIO m, IsDropTargetAsync a) => a -> m [DragAction]
- dropTargetAsyncGetFormats :: (HasCallStack, MonadIO m, IsDropTargetAsync a) => a -> m (Maybe ContentFormats)
- dropTargetAsyncNew :: (HasCallStack, MonadIO m) => Maybe ContentFormats -> [DragAction] -> m DropTargetAsync
- dropTargetAsyncRejectDrop :: (HasCallStack, MonadIO m, IsDropTargetAsync a, IsDrop b) => a -> b -> m ()
- dropTargetAsyncSetActions :: (HasCallStack, MonadIO m, IsDropTargetAsync a) => a -> [DragAction] -> m ()
- dropTargetAsyncSetFormats :: (HasCallStack, MonadIO m, IsDropTargetAsync a) => a -> Maybe ContentFormats -> m ()
- constructDropTargetAsyncActions :: (IsDropTargetAsync o, MonadIO m) => [DragAction] -> m (GValueConstruct o)
- getDropTargetAsyncActions :: (MonadIO m, IsDropTargetAsync o) => o -> m [DragAction]
- setDropTargetAsyncActions :: (MonadIO m, IsDropTargetAsync o) => o -> [DragAction] -> m ()
- clearDropTargetAsyncFormats :: (MonadIO m, IsDropTargetAsync o) => o -> m ()
- constructDropTargetAsyncFormats :: (IsDropTargetAsync o, MonadIO m) => ContentFormats -> m (GValueConstruct o)
- getDropTargetAsyncFormats :: (MonadIO m, IsDropTargetAsync o) => o -> m (Maybe ContentFormats)
- setDropTargetAsyncFormats :: (MonadIO m, IsDropTargetAsync o) => o -> ContentFormats -> m ()
- type DropTargetAsyncAcceptCallback = Drop -> IO Bool
- afterDropTargetAsyncAccept :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncAcceptCallback) -> m SignalHandlerId
- onDropTargetAsyncAccept :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncAcceptCallback) -> m SignalHandlerId
- type DropTargetAsyncDragEnterCallback = Drop -> Double -> Double -> IO [DragAction]
- afterDropTargetAsyncDragEnter :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragEnterCallback) -> m SignalHandlerId
- onDropTargetAsyncDragEnter :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragEnterCallback) -> m SignalHandlerId
- type DropTargetAsyncDragLeaveCallback = Drop -> IO ()
- afterDropTargetAsyncDragLeave :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragLeaveCallback) -> m SignalHandlerId
- onDropTargetAsyncDragLeave :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragLeaveCallback) -> m SignalHandlerId
- type DropTargetAsyncDragMotionCallback = Drop -> Double -> Double -> IO [DragAction]
- afterDropTargetAsyncDragMotion :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragMotionCallback) -> m SignalHandlerId
- onDropTargetAsyncDragMotion :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragMotionCallback) -> m SignalHandlerId
- type DropTargetAsyncDropCallback = Drop -> Double -> Double -> IO Bool
- afterDropTargetAsyncDrop :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDropCallback) -> m SignalHandlerId
- onDropTargetAsyncDrop :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDropCallback) -> m SignalHandlerId
Exported types
newtype DropTargetAsync Source #
Memory-managed wrapper type.
DropTargetAsync (ManagedPtr DropTargetAsync) |
Instances
Eq DropTargetAsync Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync (==) :: DropTargetAsync -> DropTargetAsync -> Bool # (/=) :: DropTargetAsync -> DropTargetAsync -> Bool # | |
GObject DropTargetAsync Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync | |
ManagedPtrNewtype DropTargetAsync Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync toManagedPtr :: DropTargetAsync -> ManagedPtr DropTargetAsync | |
TypedObject DropTargetAsync Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync | |
HasParentTypes DropTargetAsync Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync | |
IsGValue (Maybe DropTargetAsync) Source # | Convert |
Defined in GI.Gtk.Objects.DropTargetAsync gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe DropTargetAsync -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe DropTargetAsync) | |
type ParentTypes DropTargetAsync Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync |
class (GObject o, IsDescendantOf DropTargetAsync o) => IsDropTargetAsync o Source #
Type class for types which can be safely cast to DropTargetAsync
, for instance with toDropTargetAsync
.
Instances
(GObject o, IsDescendantOf DropTargetAsync o) => IsDropTargetAsync o Source # | |
Defined in GI.Gtk.Objects.DropTargetAsync |
toDropTargetAsync :: (MonadIO m, IsDropTargetAsync o) => o -> m DropTargetAsync Source #
Cast to DropTargetAsync
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, rejectDrop, reset, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getActions, getCurrentEvent, getCurrentEventDevice, getCurrentEventState, getCurrentEventTime, getData, getFormats, getName, getPropagationLimit, getPropagationPhase, getProperty, getQdata, getWidget.
Setters
setActions, setData, setDataFull, setFormats, setName, setPropagationLimit, setPropagationPhase, setProperty, setStaticName.
getActions
dropTargetAsyncGetActions Source #
:: (HasCallStack, MonadIO m, IsDropTargetAsync a) | |
=> a |
|
-> m [DragAction] | Returns: the actions that this drop target supports |
Gets the actions that this drop target supports.
getFormats
dropTargetAsyncGetFormats Source #
:: (HasCallStack, MonadIO m, IsDropTargetAsync a) | |
=> a |
|
-> m (Maybe ContentFormats) | Returns: the supported data formats |
Gets the data formats that this drop target accepts.
If the result is Nothing
, all formats are expected to be supported.
new
:: (HasCallStack, MonadIO m) | |
=> Maybe ContentFormats |
|
-> [DragAction] |
|
-> m DropTargetAsync | Returns: the new |
Creates a new GtkDropTargetAsync
object.
rejectDrop
dropTargetAsyncRejectDrop Source #
:: (HasCallStack, MonadIO m, IsDropTargetAsync a, IsDrop b) | |
=> a |
|
-> b |
|
-> m () |
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.
setActions
dropTargetAsyncSetActions Source #
:: (HasCallStack, MonadIO m, IsDropTargetAsync a) | |
=> a |
|
-> [DragAction] |
|
-> m () |
Sets the actions that this drop target supports.
setFormats
dropTargetAsyncSetFormats Source #
:: (HasCallStack, MonadIO m, IsDropTargetAsync a) | |
=> a |
|
-> Maybe ContentFormats |
|
-> m () |
Sets the data formats that this drop target will accept.
Properties
actions
The GdkDragActions
that this drop target supports.
constructDropTargetAsyncActions :: (IsDropTargetAsync o, MonadIO m) => [DragAction] -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “actions
” property. This is rarely needed directly, but it is used by new
.
getDropTargetAsyncActions :: (MonadIO m, IsDropTargetAsync o) => o -> m [DragAction] Source #
Get the value of the “actions
” property.
When overloading is enabled, this is equivalent to
get
dropTargetAsync #actions
setDropTargetAsyncActions :: (MonadIO m, IsDropTargetAsync o) => o -> [DragAction] -> m () Source #
Set the value of the “actions
” property.
When overloading is enabled, this is equivalent to
set
dropTargetAsync [ #actions:=
value ]
formats
The GdkContentFormats
that determines the supported data formats.
clearDropTargetAsyncFormats :: (MonadIO m, IsDropTargetAsync o) => o -> m () Source #
Set the value of the “formats
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#formats
constructDropTargetAsyncFormats :: (IsDropTargetAsync o, MonadIO m) => ContentFormats -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “formats
” property. This is rarely needed directly, but it is used by new
.
getDropTargetAsyncFormats :: (MonadIO m, IsDropTargetAsync o) => o -> m (Maybe ContentFormats) Source #
Get the value of the “formats
” property.
When overloading is enabled, this is equivalent to
get
dropTargetAsync #formats
setDropTargetAsyncFormats :: (MonadIO m, IsDropTargetAsync o) => o -> ContentFormats -> m () Source #
Set the value of the “formats
” property.
When overloading is enabled, this is equivalent to
set
dropTargetAsync [ #formats:=
value ]
Signals
accept
type DropTargetAsyncAcceptCallback Source #
Emitted on the drop site when a drop operation is about to begin.
If the drop is not accepted, False
will be returned and the drop target
will ignore the drop. If True
is returned, the drop is accepted for now
but may be rejected later via a call to dropTargetAsyncRejectDrop
or ultimately by returning False
from a DropTargetAsync::drop
handler.
The default handler for this signal decides whether to accept the drop
based on the formats provided by the drop
.
If the decision whether the drop will be accepted or rejected needs
further processing, such as inspecting the data, this function should
return True
and proceed as is drop
was accepted and if it decides to
reject the drop later, it should call dropTargetAsyncRejectDrop
.
afterDropTargetAsyncAccept :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncAcceptCallback) -> m SignalHandlerId Source #
Connect a signal handler for the accept signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
dropTargetAsync #accept callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDropTargetAsyncAccept :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncAcceptCallback) -> m SignalHandlerId Source #
Connect a signal handler for the accept signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
dropTargetAsync #accept callback
dragEnter
type DropTargetAsyncDragEnterCallback Source #
= Drop |
|
-> Double |
|
-> Double |
|
-> IO [DragAction] | Returns: Preferred action for this drag operation. |
Emitted on the drop site when the pointer enters the widget.
It can be used to set up custom highlighting.
afterDropTargetAsyncDragEnter :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragEnterCallback) -> m SignalHandlerId Source #
Connect a signal handler for the dragEnter signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
dropTargetAsync #dragEnter callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDropTargetAsyncDragEnter :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragEnterCallback) -> m SignalHandlerId Source #
Connect a signal handler for the dragEnter signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
dropTargetAsync #dragEnter callback
dragLeave
type DropTargetAsyncDragLeaveCallback Source #
= Drop |
|
-> IO () |
Emitted on the drop site when the pointer leaves the widget.
Its main purpose it to undo things done in
GtkDropTargetAsync
dragEnter.
afterDropTargetAsyncDragLeave :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragLeaveCallback) -> m SignalHandlerId Source #
Connect a signal handler for the dragLeave signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
dropTargetAsync #dragLeave callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDropTargetAsyncDragLeave :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragLeaveCallback) -> m SignalHandlerId Source #
Connect a signal handler for the dragLeave signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
dropTargetAsync #dragLeave callback
dragMotion
type DropTargetAsyncDragMotionCallback Source #
= Drop |
|
-> Double |
|
-> Double |
|
-> IO [DragAction] | Returns: Preferred action for this drag operation. |
Emitted while the pointer is moving over the drop target.
afterDropTargetAsyncDragMotion :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragMotionCallback) -> m SignalHandlerId Source #
Connect a signal handler for the dragMotion signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
dropTargetAsync #dragMotion callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDropTargetAsyncDragMotion :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDragMotionCallback) -> m SignalHandlerId Source #
Connect a signal handler for the dragMotion signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
dropTargetAsync #dragMotion callback
drop
type DropTargetAsyncDropCallback Source #
= Drop |
|
-> Double |
|
-> Double |
|
-> IO Bool | Returns: whether the drop is accepted at the given pointer position |
Emitted on the drop site when the user drops the data onto the widget.
The signal handler must determine whether the pointer position is in a
drop zone or not. If it is not in a drop zone, it returns False
and no
further processing is necessary.
Otherwise, the handler returns True
. In this case, this handler will
accept the drop. The handler must ensure that dropFinish
is called to let the source know that the drop is done. The call to
dropFinish
must only be done when all data has been received.
To receive the data, use one of the read functions provided by
Drop
such as dropReadAsync
or
dropReadValueAsync
.
afterDropTargetAsyncDrop :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDropCallback) -> m SignalHandlerId Source #
Connect a signal handler for the drop signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
dropTargetAsync #drop callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDropTargetAsyncDrop :: (IsDropTargetAsync a, MonadIO m) => a -> ((?self :: a) => DropTargetAsyncDropCallback) -> m SignalHandlerId Source #
Connect a signal handler for the drop signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
dropTargetAsync #drop callback