DragAndDrop

GTK+ has a rich set of functions for doing inter-process communication via the drag-and-drop metaphor.

As well as the functions listed here, applications may need to use some facilities provided for Selections. Also, the Drag and Drop API makes use of signals in the GtkWidget class.

class DragAndDrop {}

Constructors

this
this(GdkDragContext* gdkDragContext)

Sets our main struct and passes it to the parent class

Members

Functions

finish
void finish(int success, int del, uint time)

Informs the drag source that the drop is finished, and that the data of the drag will no longer be required.

getDragAndDropStruct
GdkDragContext* getDragAndDropStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getSourceWidget
Widget getSourceWidget()

Determines the source widget for a drag.

getStruct
void* getStruct()

the main Gtk struct as a void*

setIconDefault
void setIconDefault()

Sets the icon for a particular drag to the default icon.

setIconGicon
void setIconGicon(IconIF icon, int hotX, int hotY)

Sets the icon for a given drag from the given icon. See the documentation for gtk_drag_set_icon_name() for more details about using icons in drag and drop.

setIconName
void setIconName(string iconName, int hotX, int hotY)

Sets the icon for a given drag from a named themed icon. See the docs for GtkIconTheme for more details. Note that the size of the icon depends on the icon theme (the icon is loaded at the symbolic size GTK_ICON_SIZE_DND), thus hot_x and hot_y have to be used with care. Since 2.8

setIconPixbuf
void setIconPixbuf(Pixbuf pixbuf, int hotX, int hotY)

Sets pixbuf as the icon for a given drag.

setIconStock
void setIconStock(string stockId, int hotX, int hotY)

Warning gtk_drag_set_icon_stock has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_drag_set_icon_name() instead. Sets the icon for a given drag from a stock ID.

setIconSurface
void setIconSurface(Surface surface)

Sets surface as the icon for a given drag. GTK+ retains references for the arguments, and will release them when they are no longer needed. To position the surface relative to the mouse, use cairo_surface_set_device_offset() on surface. The mouse cursor will be positioned at the (0,0) coordinate of the surface.

setIconWidget
void setIconWidget(Widget widget, int hotX, int hotY)

Changes the icon for a widget to a given widget. GTK+ will not destroy the icon, so if you don't want it to persist, you should connect to the "drag-end" signal and destroy it yourself.

Static functions

begin
DragContext begin(Widget widget, TargetList targets, GdkDragAction actions, int button, Event event)

Warning gtk_drag_begin has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_drag_begin_with_coordinates() instead. This is equivalent to gtk_drag_begin_with_coordinates(), passing -1, -1 as coordinates.

checkThreshold
int checkThreshold(Widget widget, int startX, int startY, int currentX, int currentY)

Checks to see if a mouse drag starting at (start_x, start_y) and ending at (current_x, current_y) has passed the GTK+ drag threshold, and thus should trigger the beginning of a drag-and-drop operation.

destAddImageTargets
void destAddImageTargets(Widget widget)

Add the image targets supported by GtkSelection to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_image_targets() and gtk_drag_dest_set_target_list(). Since 2.6

destAddTextTargets
void destAddTextTargets(Widget widget)

Add the text targets supported by GtkSelection to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_text_targets() and gtk_drag_dest_set_target_list(). Since 2.6

destAddUriTargets
void destAddUriTargets(Widget widget)

Add the URI targets supported by GtkSelection to the target list of the drag destination. The targets are added with info = 0. If you need another value, use gtk_target_list_add_uri_targets() and gtk_drag_dest_set_target_list(). Since 2.6

destFindTarget
GdkAtom destFindTarget(Widget widget, DragContext context, TargetList targetList)

Looks for a match between the supported targets of context and the dest_target_list, returning the first matching target, otherwise returning GDK_NONE. dest_target_list should usually be the return value from gtk_drag_dest_get_target_list(), but some widgets may have different valid targets for different parts of the widget; in that case, they will have to implement a drag_motion handler that passes the correct target list to this function.

destGetTargetList
TargetList destGetTargetList(Widget widget)

Returns the list of targets this widget can accept from drag-and-drop.

destGetTrackMotion
int destGetTrackMotion(Widget widget)

Returns whether the widget has been configured to always emit "drag-motion" signals. Since 2.10

destSet
void destSet(Widget widget, GtkDestDefaults flags, GtkTargetEntry[] targets, GdkDragAction actions)

Sets a widget as a potential drop destination, and adds default behaviors. The default behaviors listed in flags have an effect similar to installing default handlers for the widget's drag-and-drop signals ("drag-motion", "drag-drop", ...). They all exist for convenience. When passing GTK_DEST_DEFAULT_ALL for instance it is sufficient to connect to the widget's "drag-data-received" signal to get primitive, but consistent drag-and-drop support. Things become more complicated when you try to preview the dragged data, as described in the documentation for "drag-motion". The default behaviors described by flags make some assumptions, that can conflict with your own signal handlers. For instance GTK_DEST_DEFAULT_DROP causes invokations of gdk_drag_status() in the context of "drag-motion", and invokations of gtk_drag_finish() in "drag-data-received". Especially the later is dramatic, when your own "drag-motion" handler calls gtk_drag_get_data() to inspect the dragged data. There's no way to set a default action here, you can use the "drag-motion" callback for that. Here's an example which selects

destSetProxy
void destSetProxy(Widget widget, Window proxyWindow, GdkDragProtocol protocol, int useCoordinates)

Sets this widget as a proxy for drops to another window.

destSetTargetList
void destSetTargetList(Widget widget, TargetList targetList)

Sets the target types that this widget can accept from drag-and-drop. The widget must first be made into a drag destination with gtk_drag_dest_set().

destSetTrackMotion
void destSetTrackMotion(Widget widget, int trackMotion)

Tells the widget to emit "drag-motion" and "drag-leave" events regardless of the targets and the GTK_DEST_DEFAULT_MOTION flag. This may be used when a widget wants to do generic actions regardless of the targets that the source offers. Since 2.10

destUnset
void destUnset(Widget widget)

Clears information about a drop destination set with gtk_drag_dest_set(). The widget will no longer receive notification of drags.

getData
void getData(Widget widget, DragContext context, GdkAtom target, uint time)

Gets the data associated with a drag. When the data is received or the retrieval fails, GTK+ will emit a "drag-data-received" signal. Failure of the retrieval is indicated by the length field of the selection_data signal parameter being negative. However, when gtk_drag_get_data() is called implicitely because the GTK_DEST_DEFAULT_DROP was set, then the widget will not receive notification of failed drops.

highlight
void highlight(Widget widget)

Draws a highlight around a widget. This will attach handlers to "draw", so the highlight will continue to be displayed until gtk_drag_unhighlight() is called.

sourceAddImageTargets
void sourceAddImageTargets(Widget widget)

Add the writable image targets supported by GtkSelection to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_image_targets() and gtk_drag_source_set_target_list(). Since 2.6

sourceAddTextTargets
void sourceAddTextTargets(Widget widget)

Add the text targets supported by GtkSelection to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_text_targets() and gtk_drag_source_set_target_list(). Since 2.6

sourceAddUriTargets
void sourceAddUriTargets(Widget widget)

Add the URI targets supported by GtkSelection to the target list of the drag source. The targets are added with info = 0. If you need another value, use gtk_target_list_add_uri_targets() and gtk_drag_source_set_target_list(). Since 2.6

sourceGetTargetList
TargetList sourceGetTargetList(Widget widget)

Gets the list of targets this widget can provide for drag-and-drop. Since 2.4

sourceSet
void sourceSet(Widget widget, GdkModifierType startButtonMask, GtkTargetEntry[] targets, GdkDragAction actions)

Sets up a widget so that GTK+ will start a drag operation when the user clicks and drags on the widget. The widget must have a window.

sourceSetIconGicon
void sourceSetIconGicon(Widget widget, IconIF icon)

Sets the icon that will be used for drags from a particular source to icon. See the docs for GtkIconTheme for more details.

sourceSetIconName
void sourceSetIconName(Widget widget, string iconName)

Sets the icon that will be used for drags from a particular source to a themed icon. See the docs for GtkIconTheme for more details. Since 2.8

sourceSetIconPixbuf
void sourceSetIconPixbuf(Widget widget, Pixbuf pixbuf)

Sets the icon that will be used for drags from a particular widget from a GdkPixbuf. GTK+ retains a reference for pixbuf and will release it when it is no longer needed.

sourceSetIconStock
void sourceSetIconStock(Widget widget, string stockId)

Warning gtk_drag_source_set_icon_stock has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_drag_source_set_icon_name() instead. Sets the icon that will be used for drags from a particular source to a stock icon.

sourceSetTargetList
void sourceSetTargetList(Widget widget, TargetList targetList)

Changes the target types that this widget offers for drag-and-drop. The widget must first be made into a drag source with gtk_drag_source_set(). Since 2.4

sourceUnset
void sourceUnset(Widget widget)

Undoes the effects of gtk_drag_source_set().

unhighlight
void unhighlight(Widget widget)

Removes a highlight set by gtk_drag_highlight() from a widget.

Variables

gdkDragContext
GdkDragContext* gdkDragContext;

the main Gtk struct

Meta