gi-gdk4-4.0.10: Gdk bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gdk.Objects.Drag

Contents

- Exported types
- Methods
  - begin
  - dropDone
  - getActions
  - getContent
  - getDevice
  - getDisplay
  - getDragSurface
  - getFormats
  - getSelectedAction
  - getSurface
  - setHotspot
- Properties
  - actions
  - content
  - device
  - display
  - formats
  - selectedAction
  - surface
- Signals
  - cancel
  - dndFinished
  - dropPerformed

Description

Represents the source of an ongoing DND operation.

A `GdkDrag` is created when a drag is started, and stays alive for duration of the DND operation. After a drag has been started with `dragBegin`, the caller gets informed about the status of the ongoing drag operation with signals on the `GdkDrag` object.

GTK provides a higher level abstraction based on top of these functions, and so they are not normally needed in GTK applications. See the "Drag and Drop" section of the GTK documentation for more information.

Synopsis

- newtype Drag = Drag (ManagedPtr Drag)
- class (GObject o, IsDescendantOf Drag o) => IsDrag o
- toDrag :: (MonadIO m, IsDrag o) => o -> m Drag
- dragBegin :: (HasCallStack, MonadIO m, IsSurface a, IsDevice b, IsContentProvider c) => a -> b -> c -> [DragAction] -> Double -> Double -> m (Maybe Drag)
- dragDropDone :: (HasCallStack, MonadIO m, IsDrag a) => a -> Bool -> m ()
- dragGetActions :: (HasCallStack, MonadIO m, IsDrag a) => a -> m [DragAction]
- dragGetContent :: (HasCallStack, MonadIO m, IsDrag a) => a -> m ContentProvider
- dragGetDevice :: (HasCallStack, MonadIO m, IsDrag a) => a -> m Device
- dragGetDisplay :: (HasCallStack, MonadIO m, IsDrag a) => a -> m Display
- dragGetDragSurface :: (HasCallStack, MonadIO m, IsDrag a) => a -> m (Maybe Surface)
- dragGetFormats :: (HasCallStack, MonadIO m, IsDrag a) => a -> m ContentFormats
- dragGetSelectedAction :: (HasCallStack, MonadIO m, IsDrag a) => a -> m [DragAction]
- dragGetSurface :: (HasCallStack, MonadIO m, IsDrag a) => a -> m Surface
- dragSetHotspot :: (HasCallStack, MonadIO m, IsDrag a) => a -> Int32 -> Int32 -> m ()
- constructDragActions :: (IsDrag o, MonadIO m) => [DragAction] -> m (GValueConstruct o)
- getDragActions :: (MonadIO m, IsDrag o) => o -> m [DragAction]
- setDragActions :: (MonadIO m, IsDrag o) => o -> [DragAction] -> m ()
- constructDragContent :: (IsDrag o, MonadIO m, IsContentProvider a) => a -> m (GValueConstruct o)
- getDragContent :: (MonadIO m, IsDrag o) => o -> m ContentProvider
- constructDragDevice :: (IsDrag o, MonadIO m, IsDevice a) => a -> m (GValueConstruct o)
- getDragDevice :: (MonadIO m, IsDrag o) => o -> m Device
- getDragDisplay :: (MonadIO m, IsDrag o) => o -> m Display
- constructDragFormats :: (IsDrag o, MonadIO m) => ContentFormats -> m (GValueConstruct o)
- getDragFormats :: (MonadIO m, IsDrag o) => o -> m ContentFormats
- constructDragSelectedAction :: (IsDrag o, MonadIO m) => [DragAction] -> m (GValueConstruct o)
- getDragSelectedAction :: (MonadIO m, IsDrag o) => o -> m [DragAction]
- setDragSelectedAction :: (MonadIO m, IsDrag o) => o -> [DragAction] -> m ()
- constructDragSurface :: (IsDrag o, MonadIO m, IsSurface a) => a -> m (GValueConstruct o)
- getDragSurface :: (MonadIO m, IsDrag o) => o -> m Surface
- type DragCancelCallback = DragCancelReason -> IO ()
- afterDragCancel :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragCancelCallback) -> m SignalHandlerId
- onDragCancel :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragCancelCallback) -> m SignalHandlerId
- type DragDndFinishedCallback = IO ()
- afterDragDndFinished :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDndFinishedCallback) -> m SignalHandlerId
- onDragDndFinished :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDndFinishedCallback) -> m SignalHandlerId
- type DragDropPerformedCallback = IO ()
- afterDragDropPerformed :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDropPerformedCallback) -> m SignalHandlerId
- onDragDropPerformed :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDropPerformedCallback) -> m SignalHandlerId

# Exported types

newtype Drag Source #

Memory-managed wrapper type.

Constructors

Drag (ManagedPtr Drag) |

#### Instances

Instances details

Eq Drag Source # |
Instance details Defined in GI.Gdk.Objects.Drag Methods (==) :: Drag -> Drag -> Bool Source # (/=) :: Drag -> Drag -> Bool Source #
GObject Drag Source # |
Instance details Defined in GI.Gdk.Objects.Drag
ManagedPtrNewtype Drag Source # |
Instance details Defined in GI.Gdk.Objects.Drag Methods toManagedPtr :: Drag -> ManagedPtr Drag Source #
TypedObject Drag Source # |
Instance details Defined in GI.Gdk.Objects.Drag Methods glibType :: IO GType Source #
HasParentTypes Drag Source # |
Instance details Defined in GI.Gdk.Objects.Drag
IsGValue (Maybe Drag) Source # | Convert `Drag` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gdk.Objects.Drag Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Drag -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Drag) Source #
type ParentTypes Drag Source # |
Instance details Defined in GI.Gdk.Objects.Drag type ParentTypes Drag = '[Object]

class (GObject o, IsDescendantOf Drag o) => IsDrag o Source #

Type class for types which can be safely cast to `Drag`, for instance with `toDrag`.

#### Instances

Instances details

(GObject o, IsDescendantOf Drag o) => IsDrag o Source # |
Instance details Defined in GI.Gdk.Objects.Drag

toDrag :: (MonadIO m, IsDrag o) => o -> m Drag Source #

Cast to `Drag`, 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

Expand

#### Methods

bindProperty, bindPropertyFull, dropDone, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getActions, getContent, getData, getDevice, getDisplay, getDragSurface, getFormats, getProperty, getQdata, getSelectedAction, getSurface.

#### Setters

setData, setDataFull, setHotspot, setProperty.

## begin

dragBegin Source #

Arguments

:: (HasCallStack, MonadIO m, IsSurface a, IsDevice b, IsContentProvider c) |
=> a | `surface`: the source surface for this drag
-> b | `device`: the device that controls this drag
-> c | `content`: the offered content
-> [DragAction] | `actions`: the actions supported by this drag
-> Double | `dx`: the x offset to `device`'s position where the drag nominally started
-> Double | `dy`: the y offset to `device`'s position where the drag nominally started
-> m (Maybe Drag) | Returns: a newly created `GdkDrag`

Starts a drag and creates a new drag context for it.

This function is called by the drag source. After this call, you probably want to set up the drag icon using the surface returned by `dragGetDragSurface`.

This function returns a reference to the `Drag` object, but GTK keeps its own reference as well, as long as the DND operation is going on.

Note: if `actions` include `DragActionMove`, you need to listen for the Drag::dndFinished signal and delete the data at the source if `dragGetSelectedAction` returns `DragActionMove`.

## dropDone

dragDropDone Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> Bool | `success`: whether the drag was ultimatively successful
-> m () |

Informs GDK that the drop ended.

Passing `False` for `success` may trigger a drag cancellation animation.

This function is called by the drag source, and should be the last call before dropping the reference to the `drag`.

The `GdkDrag` will only take the first `dragDropDone` call as effective, if this function is called multiple times, all subsequent calls will be ignored.

## getActions

dragGetActions Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m [DragAction] | Returns: the `GdkDragAction` flags

Determines the bitmask of possible actions proposed by the source.

## getContent

dragGetContent Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m ContentProvider | Returns: The `GdkContentProvider` associated to `drag`.

Returns the `GdkContentProvider` associated to the `GdkDrag` object.

## getDevice

dragGetDevice Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m Device | Returns: The `GdkDevice` associated to `drag`.

Returns the `GdkDevice` associated to the `GdkDrag` object.

## getDisplay

dragGetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m Display | Returns: a `GdkDisplay`

Gets the `GdkDisplay` that the drag object was created for.

## getDragSurface

dragGetDragSurface Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m (Maybe Surface) | Returns: the drag surface

Returns the surface on which the drag icon should be rendered during the drag operation.

Note that the surface may not be available until the drag operation has begun. GDK will move the surface in accordance with the ongoing drag operation. The surface is owned by `drag` and will be destroyed when the drag operation is over.

## getFormats

dragGetFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m ContentFormats | Returns: a `GdkContentFormats`

Retrieves the formats supported by this `GdkDrag` object.

## getSelectedAction

dragGetSelectedAction Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m [DragAction] | Returns: a `GdkDragAction` value

Determines the action chosen by the drag destination.

## getSurface

dragGetSurface Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> m Surface | Returns: The `GdkSurface` where the drag originates

Returns the `GdkSurface` where the drag originates.

## setHotspot

dragSetHotspot Source #

Arguments

:: (HasCallStack, MonadIO m, IsDrag a) |
=> a | `drag`: a `GdkDrag`
-> Int32 | `hotX`: x coordinate of the drag surface hotspot
-> Int32 | `hotY`: y coordinate of the drag surface hotspot
-> m () |

Sets the position of the drag surface that will be kept under the cursor hotspot.

Initially, the hotspot is at the top left corner of the drag surface.

# Properties

## actions

The possible actions of this drag.

constructDragActions :: (IsDrag 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`.

getDragActions :: (MonadIO m, IsDrag o) => o -> m [DragAction] Source #

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

    get drag #actions

setDragActions :: (MonadIO m, IsDrag o) => o -> [DragAction] -> m () Source #

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

    set drag [ #actions := value ]

## content

The `GdkContentProvider`.

constructDragContent :: (IsDrag 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`.

getDragContent :: (MonadIO m, IsDrag o) => o -> m ContentProvider Source #

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

    get drag #content

## device

The `GdkDevice` that is performing the drag.

constructDragDevice :: (IsDrag o, MonadIO m, IsDevice a) => a -> m (GValueConstruct o) Source #

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

getDragDevice :: (MonadIO m, IsDrag o) => o -> m Device Source #

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

    get drag #device

## display

The `GdkDisplay` that the drag belongs to.

getDragDisplay :: (MonadIO m, IsDrag o) => o -> m Display Source #

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

    get drag #display

## formats

The possible formats that the drag can provide its data in.

constructDragFormats :: (IsDrag 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`.

getDragFormats :: (MonadIO m, IsDrag o) => o -> m ContentFormats Source #

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

    get drag #formats

## selectedAction

The currently selected action of the drag.

constructDragSelectedAction :: (IsDrag o, MonadIO m) => [DragAction] -> m (GValueConstruct o) Source #

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

getDragSelectedAction :: (MonadIO m, IsDrag o) => o -> m [DragAction] Source #

Get the value of the “`selected-action`” property. When overloading is enabled, this is equivalent to

    get drag #selectedAction

setDragSelectedAction :: (MonadIO m, IsDrag o) => o -> [DragAction] -> m () Source #

Set the value of the “`selected-action`” property. When overloading is enabled, this is equivalent to

    set drag [ #selectedAction := value ]

## surface

The surface where the drag originates.

constructDragSurface :: (IsDrag o, MonadIO m, IsSurface a) => a -> m (GValueConstruct o) Source #

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

getDragSurface :: (MonadIO m, IsDrag o) => o -> m Surface Source #

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

    get drag #surface

# Signals

## cancel

type DragCancelCallback Source #

Arguments

= DragCancelReason | `reason`: The reason the drag was cancelled
-> IO () |

Emitted when the drag operation is cancelled.

afterDragCancel :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragCancelCallback) -> m SignalHandlerId Source #

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

    after drag #cancel 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.

onDragCancel :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragCancelCallback) -> m SignalHandlerId Source #

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

    on drag #cancel callback

## dndFinished

type DragDndFinishedCallback = IO () Source #

Emitted when the destination side has finished reading all data.

The drag object can now free all miscellaneous data.

afterDragDndFinished :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDndFinishedCallback) -> m SignalHandlerId Source #

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

    after drag #dndFinished 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.

onDragDndFinished :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDndFinishedCallback) -> m SignalHandlerId Source #

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

    on drag #dndFinished callback

## dropPerformed

type DragDropPerformedCallback = IO () Source #

Emitted when the drop operation is performed on an accepting client.

afterDragDropPerformed :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDropPerformedCallback) -> m SignalHandlerId Source #

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

    after drag #dropPerformed 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.

onDragDropPerformed :: (IsDrag a, MonadIO m) => a -> ((?self :: a) => DragDropPerformedCallback) -> m SignalHandlerId Source #

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

    on drag #dropPerformed callback