gi-gtk-4.0.4: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.DropTargetAsync

Description

GtkDropTargetAsync is an auxiliary object that can be used to receive Drag-and-Drop operations. It is the more complete but also more complex method of handling drop operations compared to DropTarget and you should only use it if DropTarget doesn't provide all the features you need.

To use a DropTargetAsync to receive drops on a widget, you create a DropTargetAsync 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 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 dragEnter signal, followed by dragMotion signals as the pointer moves, optionally a drop signal when a drop happens, and finally a dragLeave signal when the pointer moves off the widget.

The dragEnter and dragMotion handler return a DragAction 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

Exported types

newtype DropTargetAsync Source #

Memory-managed wrapper type.

Constructors

DropTargetAsync (ManagedPtr DropTargetAsync) 

Instances

Instances details
Eq DropTargetAsync Source # 
Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

GObject DropTargetAsync Source # 
Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

ManagedPtrNewtype DropTargetAsync Source # 
Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

TypedObject DropTargetAsync Source # 
Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

Methods

glibType :: IO GType

HasParentTypes DropTargetAsync Source # 
Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

IsGValue (Maybe DropTargetAsync) Source #

Convert DropTargetAsync to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe DropTargetAsync -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe DropTargetAsync)

type ParentTypes DropTargetAsync Source # 
Instance details

Defined in GI.Gtk.Objects.DropTargetAsync

type ParentTypes DropTargetAsync = '[EventController, Object]

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

Instances details
(GObject o, IsDescendantOf DropTargetAsync o) => IsDropTargetAsync o Source # 
Instance details

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

getActions

dropTargetAsyncGetActions Source #

Arguments

:: (HasCallStack, MonadIO m, IsDropTargetAsync a) 
=> a

self: a DropTargetAsync

-> m [DragAction]

Returns: the actions that this drop target supports

Gets the actions that this drop target supports.

getFormats

dropTargetAsyncGetFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsDropTargetAsync a) 
=> a

self: a DropTargetAsync

-> 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

dropTargetAsyncNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe ContentFormats

formats: the supported data formats

-> [DragAction]

actions: the supported actions

-> m DropTargetAsync

Returns: the new DropTargetAsync

Creates a new DropTargetAsync object.

rejectDrop

dropTargetAsyncRejectDrop Source #

Arguments

:: (HasCallStack, MonadIO m, IsDropTargetAsync a, IsDrop b) 
=> a

self: a DropTargetAsync

-> b

drop: the Drop of an ongoing drag operation

-> 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 #

Arguments

:: (HasCallStack, MonadIO m, IsDropTargetAsync a) 
=> a

self: a DropTargetAsync

-> [DragAction]

actions: the supported actions

-> m () 

Sets the actions that this drop target supports.

setFormats

dropTargetAsyncSetFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsDropTargetAsync a) 
=> a

self: a DropTargetAsync

-> Maybe ContentFormats

formats: the supported data formats or Nothing for any format.

-> 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 ContentFormats 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 C_DropTargetAsyncAcceptCallback = Ptr () -> Ptr Drop -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type DropTargetAsyncAcceptCallback Source #

Arguments

 = Drop

drop: the Drop

-> IO Bool

Returns: True if drop is accepted

The accept signal is 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 gtk_drop_target_async_reject() or ultimately by returning False from drop.

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 -> 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

onDropTargetAsyncAccept :: (IsDropTargetAsync a, MonadIO m) => 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 C_DropTargetAsyncDragEnterCallback = Ptr () -> Ptr Drop -> CDouble -> CDouble -> Ptr () -> IO CUInt Source #

Type for the callback on the (unwrapped) C side.

type DropTargetAsyncDragEnterCallback Source #

Arguments

 = Drop

drop: the Drop

-> Double

x: the x coordinate of the current pointer position

-> Double

y: the y coordinate of the current pointer position

-> IO [DragAction]

Returns: Preferred action for this drag operation.

The dragEnter signal is 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 -> 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

onDropTargetAsyncDragEnter :: (IsDropTargetAsync a, MonadIO m) => 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 C_DropTargetAsyncDragLeaveCallback = Ptr () -> Ptr Drop -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type DropTargetAsyncDragLeaveCallback Source #

Arguments

 = Drop

drop: the Drop

-> IO () 

The dragLeave signal is emitted on the drop site when the pointer leaves the widget. Its main purpose it to undo things done in dragEnter.

afterDropTargetAsyncDragLeave :: (IsDropTargetAsync a, MonadIO m) => 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

onDropTargetAsyncDragLeave :: (IsDropTargetAsync a, MonadIO m) => 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 C_DropTargetAsyncDragMotionCallback = Ptr () -> Ptr Drop -> CDouble -> CDouble -> Ptr () -> IO CUInt Source #

Type for the callback on the (unwrapped) C side.

type DropTargetAsyncDragMotionCallback Source #

Arguments

 = Drop

drop: the Drop

-> Double

x: the x coordinate of the current pointer position

-> Double

y: the y coordinate of the current pointer position

-> IO [DragAction]

Returns: Preferred action for this drag operation.

The dragMotion signal is emitted while the pointer is moving over the drop target.

afterDropTargetAsyncDragMotion :: (IsDropTargetAsync a, MonadIO m) => 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

onDropTargetAsyncDragMotion :: (IsDropTargetAsync a, MonadIO m) => 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 C_DropTargetAsyncDropCallback = Ptr () -> Ptr Drop -> CDouble -> CDouble -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type DropTargetAsyncDropCallback Source #

Arguments

 = Drop

drop: the Drop

-> Double

x: the x coordinate of the current pointer position

-> Double

y: the y coordinate of the current pointer position

-> IO Bool

Returns: whether the drop is accepted at the given pointer position

The drop signal is 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 provides by Drop such as dropReadAsync or dropReadValueAsync.

afterDropTargetAsyncDrop :: (IsDropTargetAsync a, MonadIO m) => 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

onDropTargetAsyncDrop :: (IsDropTargetAsync a, MonadIO m) => 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