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

GI.Gtk.Objects.DropTargetAsync

Description

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

Exported types

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 GtkDropTargetAsync

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

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

Creates a new GtkDropTargetAsync object.

rejectDrop

dropTargetAsyncRejectDrop Source #

Arguments

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

self: a GtkDropTargetAsync

-> b

drop: the GdkDrop 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 GtkDropTargetAsync

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

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

Arguments

 = Drop

drop: the GdkDrop

-> IO Bool

Returns: True if drop is accepted

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 #

Arguments

 = Drop

drop: the GdkDrop

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

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 #

Arguments

 = Drop

drop: the GdkDrop

-> IO () 

Emitted on the drop site when the pointer leaves the widget.

Its main purpose it to undo things done in GtkDropTargetAsyncdragEnter.

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 #

Arguments

 = Drop

drop: the GdkDrop

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

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 #

Arguments

 = Drop

drop: the GdkDrop

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

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