W Wrapl, The Programming Language

Libraries:Gtk:Gtk:Drag

Functions

Begin(widget @ Gtk.Gtk.Widget.T, targets @ Gtk.Gtk.TargetList.T, actions @ Std.Integer.SmallT, button @ Std.Integer.SmallT, event @ Gtk.Gdk.Event.T) : Gtk.Gdk.DragContext.T

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 SourceSet 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 this function:

1. During a button-press-event handler, if you want to start a drag immediately when the user presses the mouse button. Pass the event that you have in your button-press-event handler.

2. During a motion-notify-event handler, if you want to start a drag when the mouse moves past a certain threshold distance after a button-press. Pass the event that you have in your motion-notify-event handler.

3. During a timeout handler, if you want to start a drag after the mouse button is held down for some time. Try to save the last event that you got from the mouse, using Gtk.Gdk.Event.Copy, and pass it to this function (remember to free the event with Gtk.Gdk.Event.Free when you are done). If you can really not pass a real event, pass NULL instead.

widget the source widget.
targets The targets (data formats) in which the source can provide the data.
actions A bitmask of the allowed drag actions for this drag.
button The button the user clicked to start the drag.
event The event that triggered the start of the drag.
Returns the context for this drag. [transfer none]


CheckThreshold(widget @ Gtk.Gtk.Widget.T, start_x @ Std.Integer.SmallT, start_y @ Std.Integer.SmallT, current_x @ Std.Integer.SmallT, current_y @ Std.Integer.SmallT) : Std.Symbol.T

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.

widget a Gtk.Gtk.Widget.T
start_x X coordinate of start of drag
start_y Y coordinate of start of drag
current_x current X coordinate
current_y current Y coordinate
Returns TRUE if the drag threshold has been passed.


DestAddImageTargets(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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.Gtk.TargetList.AddImageTargets and DestSetTargetList.

widget a Gtk.Gtk.Widget.T that's a drag destination


DestAddTextTargets(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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.Gtk.TargetList.AddTextTargets and DestSetTargetList.

widget a Gtk.Gtk.Widget.T that's a drag destination


DestAddUriTargets(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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.Gtk.TargetList.AddUriTargets and DestSetTargetList.

widget a Gtk.Gtk.Widget.T that's a drag destination


DestFindTarget(widget @ Gtk.Gtk.Widget.T, context @ Gtk.Gdk.DragContext.T, target_list @ Gtk.Gtk.TargetList.T) : Gtk.Gdk.Atom.T

widget drag destination widget
context drag context
target_list list of droppable targets, or NULL to use gtk_drag_dest_get_target_list (widget). 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 DestGetTargetList, 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. [allow-none]
Returns first target that the source offers and the dest can accept, or GDK_NONE. [transfer none]


DestGetTargetList(widget @ Gtk.Gtk.Widget.T) : Gtk.Gtk.TargetList.T

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

widget a Gtk.Gtk.Widget.T
Returns the Gtk.Gtk.TargetList.T, or NULL if none. [transfer none]


DestGetTrackMotion(widget @ Gtk.Gtk.Widget.T) : Std.Symbol.T

Returns whether the widget has been configured to always emit ::drag-motion signals.

widget a Gtk.Gtk.Widget.T that's a drag destination
Returns TRUE if the widget always emits ::drag-motion events


DestSet(widget @ Gtk.Gtk.Widget.T, flags @ Std.Integer.SmallT, targets @ Agg.List.T, actions @ Std.Integer.SmallT) : Std.Object.T

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.Gtk.DestDefaults.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.Gtk.DestDefaults.Drop causes invokations of Gtk.Gdk.Drag.Status in the context of "drag-motion", and invokations of Finish in "drag-data-received". Especially the later is dramatic, when your own "drag-motion" handler calls GetData 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 the action to use depending on whether the control key is pressed or not:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
static void
drag_motion (GtkWidget *widget,
             GdkDragContext *context,
             gint x,
             gint y,
             guint time)
{
  GdkModifierType mask;

  gdk_window_get_pointer (gtk_widget_get_window (widget),
                          NULL, NULL, &mask);
  if (mask & GDK_CONTROL_MASK)
    gdk_drag_status (context, GDK_ACTION_COPY, time);
  else
    gdk_drag_status (context, GDK_ACTION_MOVE, time);
}


DestSetProxy(widget @ Gtk.Gtk.Widget.T, proxy_window @ Gtk.Gdk.Window.T, protocol @ Gtk.Gdk.DragProtocol.T, use_coordinates @ Std.Symbol.T) : Std.Object.T

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

widget a Gtk.Gtk.Widget.T
proxy_window the window to which to forward drag events
protocol the drag protocol which the proxy_window accepts (You can use Gtk.Gdk.Drag.GetProtocol to determine this)
use_coordinates If TRUE, send the same coordinates to the destination, because it is an embedded subwindow.


DestSetTargetList(widget @ Gtk.Gtk.Widget.T, target_list @ Gtk.Gtk.TargetList.T) : Std.Object.T

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

widget a Gtk.Gtk.Widget.T that's a drag destination
target_list list of droppable targets, or NULL for none. [allow-none]


DestSetTrackMotion(widget @ Gtk.Gtk.Widget.T, track_motion @ Std.Symbol.T) : Std.Object.T

Tells the widget to emit ::drag-motion and ::drag-leave events regardless of the targets and the Gtk.Gtk.DestDefaults.Motion flag.

This may be used when a widget wants to do generic actions regardless of the targets that the source offers.

widget a Gtk.Gtk.Widget.T that's a drag destination
track_motion whether to accept all targets


DestUnset(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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

widget a Gtk.Gtk.Widget.T


Finish(context @ Gtk.Gdk.DragContext.T, success @ Std.Symbol.T, del @ Std.Symbol.T, time_ @ Std.Integer.SmallT) : Std.Object.T

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

context the drag context.
success a flag indicating whether the drop was successful
del a flag indicating whether the source should delete the original data. (This should be TRUE for a move)
time_ the timestamp from the "drag_data_drop" signal.


GetData(widget @ Gtk.Gtk.Widget.T, context @ Gtk.Gdk.DragContext.T, target @ Gtk.Gdk.Atom.T, time_ @ Std.Integer.SmallT) : Std.Object.T

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 GetData is called implicitely because the Gtk.Gtk.DestDefaults.Drop was set, then the widget will not receive notification of failed drops.

widget the widget that will receive the "drag_data_received" signal.
context the drag context
target the target (form of the data) to retrieve.
time_ a timestamp for retrieving the data. This will generally be the time received in a "drag_data_motion" or "drag_data_drop" signal.


GetSourceWidget(context @ Gtk.Gdk.DragContext.T) : Gtk.Gtk.Widget.T

Determines the source widget for a drag.

Determines the source widget for a drag.

context a (destination side) drag context
Returns if the drag is occurring within a single application, a pointer to the source widget. Otherwise, NULL. [transfer none]


Highlight(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

Draws a highlight around a widget. This will attach handlers to "expose_event" and "draw", so the highlight will continue to be displayed until Unhighlight is called.

widget a widget to highlight


SetDefaultIcon(colormap @ Gtk.Gdk.Colormap.T, pixmap @ Gtk.Gdk.Pixmap.T, mask @ Gtk.Gdk.Bitmap.T, hot_x @ Std.Integer.SmallT, hot_y @ Std.Integer.SmallT) : Std.Object.T

Warning

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



SetIconDefault(context @ Gtk.Gdk.DragContext.T) : Std.Object.T

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

context the context for a drag. (This must be called with a context for the source side of a drag)


SetIconName(context @ Gtk.Gdk.DragContext.T, icon_name @ Std.String.T, hot_x @ Std.Integer.SmallT, hot_y @ Std.Integer.SmallT) : Std.Object.T

Sets the icon for a given drag from a named themed icon. See the docs for Gtk.Gtk.IconTheme.T 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.

context the context for a drag. (This must be called with a context for the source side of a drag)
icon_name name of icon to use
hot_x the X offset of the hotspot within the icon
hot_y the Y offset of the hotspot within the icon


SetIconPixbuf(context @ Gtk.Gdk.DragContext.T, pixbuf @ Gtk.Gdk.Pixbuf.T, hot_x @ Std.Integer.SmallT, hot_y @ Std.Integer.SmallT) : Std.Object.T

Sets pixbuf as the icon for a given drag.

context the context for a drag. (This must be called with a context for the source side of a drag)
pixbuf the Gtk.Gdk.Pixbuf.T to use as the drag icon.
hot_x the X offset within widget of the hotspot.
hot_y the Y offset within widget of the hotspot.


SetIconPixmap(context @ Gtk.Gdk.DragContext.T, colormap @ Gtk.Gdk.Colormap.T, pixmap @ Gtk.Gdk.Pixmap.T, mask @ Gtk.Gdk.Bitmap.T, hot_x @ Std.Integer.SmallT, hot_y @ Std.Integer.SmallT) : Std.Object.T

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, SetIconPixbuf will be more convenient to use.

context the context for a drag. (This must be called with a context for the source side of a drag)
colormap the colormap of the icon
pixmap the image data for the icon
mask the transparency mask for the icon or NULL for none. [allow-none]
hot_x the X offset within pixmap of the hotspot.
hot_y the Y offset within pixmap of the hotspot.


SetIconStock(context @ Gtk.Gdk.DragContext.T, stock_id @ Std.String.T, hot_x @ Std.Integer.SmallT, hot_y @ Std.Integer.SmallT) : Std.Object.T

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

context the context for a drag. (This must be called with a context for the source side of a drag)
stock_id the ID of the stock icon to use for the drag.
hot_x the X offset within the icon of the hotspot.
hot_y the Y offset within the icon of the hotspot.


SetIconWidget(context @ Gtk.Gdk.DragContext.T, widget @ Gtk.Gtk.Widget.T, hot_x @ Std.Integer.SmallT, hot_y @ Std.Integer.SmallT) : Std.Object.T

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.

context the context for a drag. (This must be called with a context for the source side of a drag)
widget a toplevel window to use as an icon.
hot_x the X offset within widget of the hotspot.
hot_y the Y offset within widget of the hotspot.


SourceAddImageTargets(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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.Gtk.TargetList.AddImageTargets and SourceSetTargetList.

widget a Gtk.Gtk.Widget.T that's is a drag source


SourceAddTextTargets(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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.Gtk.TargetList.AddTextTargets and SourceSetTargetList.

widget a Gtk.Gtk.Widget.T that's is a drag source


SourceAddUriTargets(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

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.Gtk.TargetList.AddUriTargets and SourceSetTargetList.

widget a Gtk.Gtk.Widget.T that's is a drag source


SourceGetTargetList(widget @ Gtk.Gtk.Widget.T) : Gtk.Gtk.TargetList.T

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

widget a Gtk.Gtk.Widget.T
Returns the Gtk.Gtk.TargetList.T, or NULL if none. [transfer none]


SourceSet(widget @ Gtk.Gtk.Widget.T, start_button_mask @ Std.Integer.SmallT, targets @ Agg.List.T, actions @ Std.Integer.SmallT) : Std.Object.T

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.

widget a Gtk.Gtk.Widget.T
start_button_mask the bitmask of buttons that can start the drag
targets the table of targets that the drag will support, may be NULL. [allow-none][array length=n_targets]
n_targets the number of items in targets
actions the bitmask of possible actions for a drag from this widget


SourceSetIcon(widget @ Gtk.Gtk.Widget.T, colormap @ Gtk.Gdk.Colormap.T, pixmap @ Gtk.Gdk.Pixmap.T, mask @ Gtk.Gdk.Bitmap.T) : Std.Object.T

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 SourceSetIconPixbuf instead.

widget a Gtk.Gtk.Widget.T
colormap the colormap of the icon
pixmap the image data for the icon
mask the transparency mask for an image. [allow-none]


SourceSetIconName(widget @ Gtk.Gtk.Widget.T, icon_name @ Std.String.T) : Std.Object.T

Sets the icon that will be used for drags from a particular source to a themed icon. See the docs for Gtk.Gtk.IconTheme.T for more details.

widget a Gtk.Gtk.Widget.T
icon_name name of icon to use


SourceSetIconPixbuf(widget @ Gtk.Gtk.Widget.T, pixbuf @ Gtk.Gdk.Pixbuf.T) : Std.Object.T

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

widget a Gtk.Gtk.Widget.T
pixbuf the Gtk.Gdk.Pixbuf.T for the drag icon


SourceSetIconStock(widget @ Gtk.Gtk.Widget.T, stock_id @ Std.String.T) : Std.Object.T

Sets the icon that will be used for drags from a particular source to a stock icon.

widget a Gtk.Gtk.Widget.T
stock_id the ID of the stock icon to use


SourceSetTargetList(widget @ Gtk.Gtk.Widget.T, target_list @ Gtk.Gtk.TargetList.T) : Std.Object.T

Changes the target types that this widget offers for drag-and-drop. The widget must first be made into a drag source with SourceSet.

widget a Gtk.Gtk.Widget.T that's a drag source
target_list list of draggable targets, or NULL for none. [allow-none]


SourceUnset(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

Undoes the effects of SourceSet.

widget a Gtk.Gtk.Widget.T


Unhighlight(widget @ Gtk.Gtk.Widget.T) : Std.Object.T

Removes a highlight set by Highlight from a widget.

widget a widget to remove the highlight from.