DragAndDrop

Description GTK+ has a rich set of functions for doing inter-process communication via the drag-and-drop metaphor. GTK+ can do drag-and-drop (DND) via multiple protocols. The currently supported protocols are the Xdnd and Motif protocols. 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. 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.

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.

setIconPixmap
void setIconPixmap(Colormap colormap, Pixmap pixmap, Bitmap mask, int hotX, int hotY)

Sets pixmap as the icon for a given drag. GTK+ retains references for the arguments, and will release them when they are no longer needed. In general, gtk_drag_set_icon_pixbuf() will be more convenient to use.

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

Sets the icon for a given drag from a stock ID.

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)

Initiates a drag on the source side. The function only needs to be used when the application is starting drags itself, and is not needed when gtk_drag_source_set() is used. The event is used to retrieve the timestamp that will be used internally to grab the pointer. If event is NULL, then GDK_CURRENT_TIME will be used. However, you should try to pass a real event in all cases, since that can be used by GTK+ to get information about the start position of the drag, for example if the event is a GDK_MOTION_NOTIFY. Generally there are three cases when you want to start a drag by hand by calling

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)
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, int nTargets, 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 "expose_event" and "draw", so the highlight will continue to be displayed until gtk_drag_unhighlight() is called.

setDefaultIcon
void setDefaultIcon(Colormap colormap, Pixmap pixmap, Bitmap mask, int hotX, int hotY)

Warning gtk_drag_set_default_icon is deprecated and should not be used in newly-written code. Change the default drag icon via the stock system by changing the stock pixbuf for GTK_STOCK_DND instead. Changes the default drag icon. GTK+ retains references for the arguments, and will release them when they are no longer needed.

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, int nTargets, 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.

sourceSetIcon
void sourceSetIcon(Widget widget, Colormap colormap, Pixmap pixmap, Bitmap mask)

Sets the icon that will be used for drags from a particular widget from a pixmap/mask. GTK+ retains references for the arguments, and will release them when they are no longer needed. Use gtk_drag_source_set_icon_pixbuf() instead.

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)

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