Gdk.Drag

g GObject.Object GObject.Object Gdk.Drag Gdk.Drag GObject.Object->Gdk.Drag

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

begin (surface, device, content, actions, dx, dy)

drop_done (success)

get_actions ()

get_content ()

get_device ()

get_display ()

get_drag_surface ()

get_formats ()

get_selected_action ()

get_surface ()

set_hotspot (hot_x, hot_y)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

actions

Gdk.DragAction

r/w/en

content

Gdk.ContentProvider

r/w/co/en

device

Gdk.Device

r/w/co/en

display

Gdk.Display

r/en

formats

Gdk.ContentFormats

r/w/co/en

selected-action

Gdk.DragAction

r/w/en

surface

Gdk.Surface

r/w/co/en

Signals

Inherited:

GObject.Object (1)

Name

Short Description

cancel

Emitted when the drag operation is cancelled.

dnd-finished

Emitted when the destination side has finished reading all data.

drop-performed

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

Fields

Inherited:

GObject.Object (1)

Class Details

class Gdk.Drag(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

The GdkDrag object 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 [func`Gdk`.Drag.begin], 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.

classmethod begin(surface, device, content, actions, dx, dy)[source]
Parameters:
  • surface (Gdk.Surface) – the source surface for this drag

  • device (Gdk.Device) – the device that controls this drag

  • content (Gdk.ContentProvider) – the offered content

  • actions (Gdk.DragAction) – the actions supported by this drag

  • dx (float) – the x offset to device's position where the drag nominally started

  • dy (float) – the y offset to device's position where the drag nominally started

Returns:

a newly created GdkDrag

Return type:

Gdk.Drag or None

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 [method`Gdk`.Drag.get_drag_surface].

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

Note: if actions include Gdk.DragAction.MOVE, you need to listen for the [signal`Gdk`.Drag::dnd-finished] signal and delete the data at the source if [method`Gdk`.Drag.get_selected_action] returns Gdk.DragAction.MOVE.

drop_done(success)[source]
Parameters:

success (bool) – whether the drag was ultimatively successful

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

The GdkDrag will only take the first [method`Gdk`.Drag.drop_done] call as effective, if this function is called multiple times, all subsequent calls will be ignored.

get_actions()[source]
Returns:

the GdkDragAction flags

Return type:

Gdk.DragAction

Determines the bitmask of possible actions proposed by the source.

get_content()[source]
Returns:

The GdkContentProvider associated to self.

Return type:

Gdk.ContentProvider

Returns the GdkContentProvider associated to the GdkDrag object.

get_device()[source]
Returns:

The GdkDevice associated to self.

Return type:

Gdk.Device

Returns the GdkDevice associated to the GdkDrag object.

get_display()[source]
Returns:

a GdkDisplay

Return type:

Gdk.Display

Gets the GdkDisplay that the drag object was created for.

get_drag_surface()[source]
Returns:

the drag surface

Return type:

Gdk.Surface or None

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 self and will be destroyed when the drag operation is over.

get_formats()[source]
Returns:

a GdkContentFormats

Return type:

Gdk.ContentFormats

Retrieves the formats supported by this GdkDrag object.

get_selected_action()[source]
Returns:

a GdkDragAction value

Return type:

Gdk.DragAction

Determines the action chosen by the drag destination.

get_surface()[source]
Returns:

The GdkSurface where the drag originates

Return type:

Gdk.Surface

Returns the GdkSurface where the drag originates.

set_hotspot(hot_x, hot_y)[source]
Parameters:
  • hot_x (int) – x coordinate of the drag surface hotspot

  • hot_y (int) – y coordinate of the drag surface hotspot

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.

Signal Details

Gdk.Drag.signals.cancel(drag, reason)
Signal Name:

cancel

Flags:

RUN_LAST

Parameters:

Emitted when the drag operation is cancelled.

Gdk.Drag.signals.dnd_finished(drag)
Signal Name:

dnd-finished

Flags:

RUN_LAST

Parameters:

drag (Gdk.Drag) – The object which received the signal

Emitted when the destination side has finished reading all data.

The drag object can now free all miscellaneous data.

Gdk.Drag.signals.drop_performed(drag)
Signal Name:

drop-performed

Flags:

RUN_LAST

Parameters:

drag (Gdk.Drag) – The object which received the signal

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

Property Details

Gdk.Drag.props.actions
Name:

actions

Type:

Gdk.DragAction

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The possible actions of this drag.

Gdk.Drag.props.content
Name:

content

Type:

Gdk.ContentProvider

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The GdkContentProvider.

Gdk.Drag.props.device
Name:

device

Type:

Gdk.Device

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The GdkDevice that is performing the drag.

Gdk.Drag.props.display
Name:

display

Type:

Gdk.Display

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

The GdkDisplay that the drag belongs to.

Gdk.Drag.props.formats
Name:

formats

Type:

Gdk.ContentFormats

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

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

Gdk.Drag.props.selected_action
Name:

selected-action

Type:

Gdk.DragAction

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The currently selected action of the drag.

Gdk.Drag.props.surface
Name:

surface

Type:

Gdk.Surface

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The surface where the drag originates.