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

GI.Gtk.Objects.DragSource

Description

GtkDragSource is an auxiliary object that is used to initiate Drag-And-Drop operations. It can be set up with the necessary ingredients for a DND operation ahead of time. This includes the source for the data that is being transferred, in the form of a ContentProvider, the desired action, and the icon to use during the drag operation. After setting it up, the drag source must be added to a widget as an event controller, using widgetAddController.

Setting up the content provider and icon ahead of time only makes sense when the data does not change. More commonly, you will want to set them up just in time. To do so, DragSource has prepare and dragBegin signals. The prepare signal is emitted before a drag is started, and can be used to set the content provider and actions that the drag should be started with. The dragBegin signal is emitted after the Drag object has been created, and can be used to set up the drag icon.

During the DND operation, GtkDragSource emits signals that can be used to obtain updates about the status of the operation, but it is not normally necessary to connect to any signals, except for one case: when the supported actions include DragActionMove, you need to listen for the dragEnd signal and delete the data after it has been transferred.

Synopsis

Exported types

newtype DragSource Source #

Memory-managed wrapper type.

class (GObject o, IsDescendantOf DragSource o) => IsDragSource o Source #

Type class for types which can be safely cast to DragSource, for instance with toDragSource.

Instances

Instances details
(GObject o, IsDescendantOf DragSource o) => IsDragSource o Source # 
Instance details

Defined in GI.Gtk.Objects.DragSource

toDragSource :: (MonadIO m, IsDragSource o) => o -> m DragSource Source #

Cast to DragSource, for types for which this is known to be safe. For general casts, use castTo.

Methods

Overloaded methods

dragCancel

dragSourceDragCancel Source #

Arguments

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

source: a DragSource

-> m () 

Cancels a currently ongoing drag operation.

getActions

dragSourceGetActions Source #

Arguments

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

source: a DragSource

-> m [DragAction]

Returns: the actions set on source

Gets the actions that are currently set on the DragSource.

getContent

dragSourceGetContent Source #

Arguments

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

source: a DragSource

-> m ContentProvider

Returns: the ContentProvider of source

Gets the current content provider of a DragSource.

getDrag

dragSourceGetDrag Source #

Arguments

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

source: a DragSource

-> m (Maybe Drag)

Returns: the Drag of the current drag operation, or Nothing

Returns the underlying Drag object for an ongoing drag.

new

dragSourceNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m DragSource

Returns: the new DragSource

Creates a new DragSource object.

setActions

dragSourceSetActions Source #

Arguments

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

source: a DragSource

-> [DragAction]

actions: the actions to offer

-> m () 

Sets the actions on the DragSource.

During a DND operation, the actions are offered to potential drop targets. If actions include DragActionMove, you need to listen to the dragEnd signal and handle deleteData being True.

This function can be called before a drag is started, or in a handler for the prepare signal.

setContent

dragSourceSetContent Source #

Arguments

:: (HasCallStack, MonadIO m, IsDragSource a, IsContentProvider b) 
=> a

source: a DragSource

-> Maybe b

content: a ContentProvider, or Nothing

-> m () 

Sets a content provider on a DragSource.

When the data is requested in the cause of a DND operation, it will be obtained from the content provider.

This function can be called before a drag is started, or in a handler for the prepare signal.

You may consider setting the content provider back to Nothing in a dragEnd signal handler.

setIcon

dragSourceSetIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsDragSource a, IsPaintable b) 
=> a

source: a DragSource

-> Maybe b

paintable: the Paintable to use as icon, or Nothing

-> Int32

hotX: the hotspot X coordinate on the icon

-> Int32

hotY: the hotspot Y coordinate on the icon

-> m () 

Sets a paintable to use as icon during DND operations.

The hotspot coordinates determine the point on the icon that gets aligned with the hotspot of the cursor.

If paintable is Nothing, a default icon is used.

This function can be called before a drag is started, or in a prepare or dragBegin signal handler.

Properties

actions

The actions that are supported by drag operations from the source.

Note that you must handle the dragEnd signal if the actions include DragActionMove.

constructDragSourceActions :: (IsDragSource 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.

getDragSourceActions :: (MonadIO m, IsDragSource o) => o -> m [DragAction] Source #

Get the value of the “actions” property. When overloading is enabled, this is equivalent to

get dragSource #actions

setDragSourceActions :: (MonadIO m, IsDragSource o) => o -> [DragAction] -> m () Source #

Set the value of the “actions” property. When overloading is enabled, this is equivalent to

set dragSource [ #actions := value ]

content

The data that is offered by drag operations from this source, in the form of a ContentProvider.

clearDragSourceContent :: (MonadIO m, IsDragSource o) => o -> m () Source #

Set the value of the “content” property to Nothing. When overloading is enabled, this is equivalent to

clear #content

constructDragSourceContent :: (IsDragSource o, MonadIO m, IsContentProvider a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “content” property. This is rarely needed directly, but it is used by new.

getDragSourceContent :: (MonadIO m, IsDragSource o) => o -> m ContentProvider Source #

Get the value of the “content” property. When overloading is enabled, this is equivalent to

get dragSource #content

setDragSourceContent :: (MonadIO m, IsDragSource o, IsContentProvider a) => o -> a -> m () Source #

Set the value of the “content” property. When overloading is enabled, this is equivalent to

set dragSource [ #content := value ]

Signals

dragBegin

type C_DragSourceDragBeginCallback = Ptr () -> Ptr Drag -> Ptr () -> IO () Source #

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

type DragSourceDragBeginCallback Source #

Arguments

 = Drag

drag: the Drag object

-> IO () 

The dragBegin signal is emitted on the drag source when a drag is started. It can be used to e.g. set a custom drag icon with dragSourceSetIcon.

afterDragSourceDragBegin :: (IsDragSource a, MonadIO m) => a -> DragSourceDragBeginCallback -> m SignalHandlerId Source #

Connect a signal handler for the dragBegin signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after dragSource #dragBegin callback

onDragSourceDragBegin :: (IsDragSource a, MonadIO m) => a -> DragSourceDragBeginCallback -> m SignalHandlerId Source #

Connect a signal handler for the dragBegin signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on dragSource #dragBegin callback

dragCancel

type C_DragSourceDragCancelCallback = Ptr () -> Ptr Drag -> CUInt -> Ptr () -> IO CInt Source #

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

type DragSourceDragCancelCallback Source #

Arguments

 = Drag

drag: the Drag object

-> DragCancelReason

reason: information on why the drag failed

-> IO Bool

Returns: True if the failed drag operation has been already handled

The dragCancel signal is emitted on the drag source when a drag has failed. The signal handler may handle a failed drag operation based on the type of error. It should return True if the failure has been handled and the default "drag operation failed" animation should not be shown.

afterDragSourceDragCancel :: (IsDragSource a, MonadIO m) => a -> DragSourceDragCancelCallback -> m SignalHandlerId Source #

Connect a signal handler for the dragCancel signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after dragSource #dragCancel callback

onDragSourceDragCancel :: (IsDragSource a, MonadIO m) => a -> DragSourceDragCancelCallback -> m SignalHandlerId Source #

Connect a signal handler for the dragCancel signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on dragSource #dragCancel callback

dragEnd

type C_DragSourceDragEndCallback = Ptr () -> Ptr Drag -> CInt -> Ptr () -> IO () Source #

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

type DragSourceDragEndCallback Source #

Arguments

 = Drag

drag: the Drag object

-> Bool

deleteData: True if the drag was performing DragActionMove, and the data should be deleted

-> IO () 

The dragEnd signal is emitted on the drag source when a drag is finished. A typical reason to connect to this signal is to undo things done in prepare or dragBegin.

afterDragSourceDragEnd :: (IsDragSource a, MonadIO m) => a -> DragSourceDragEndCallback -> m SignalHandlerId Source #

Connect a signal handler for the dragEnd signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after dragSource #dragEnd callback

onDragSourceDragEnd :: (IsDragSource a, MonadIO m) => a -> DragSourceDragEndCallback -> m SignalHandlerId Source #

Connect a signal handler for the dragEnd signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on dragSource #dragEnd callback

prepare

type C_DragSourcePrepareCallback = Ptr () -> CDouble -> CDouble -> Ptr () -> IO (Ptr ContentProvider) Source #

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

type DragSourcePrepareCallback Source #

Arguments

 = Double

x: the X coordinate of the drag starting point

-> Double

y: the Y coordinate fo the drag starting point

-> IO (Maybe ContentProvider)

Returns: a ContentProvider, or Nothing

The prepare signal is emitted when a drag is about to be initiated. It returns the * ContentProvider to use for the drag that is about to start. The default handler for this signal returns the value of the DragSource:content property, so if you set up that property ahead of time, you don't need to connect to this signal.

afterDragSourcePrepare :: (IsDragSource a, MonadIO m) => a -> DragSourcePrepareCallback -> m SignalHandlerId Source #

Connect a signal handler for the prepare signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after dragSource #prepare callback

onDragSourcePrepare :: (IsDragSource a, MonadIO m) => a -> DragSourcePrepareCallback -> m SignalHandlerId Source #

Connect a signal handler for the prepare signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on dragSource #prepare callback