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 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 DROP
causes invokations of drag_status in the context of
drag_motion, and invokations of drag_finish in
drag_data_received. Especially the later is dramatic, when your own
drag_motion handler calls
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 the action to use depending on whether the control key is pressed or not:
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);
}
this |
a Widget |
flags |
which types of default drag behavior to use |
targets |
a pointer to an array of TargetEntrys indicating the drop types that this this will accept, or null. Later you can access the list with drag_dest_get_target_list and drag_dest_find_target. |
actions |
a bitmask of possible actions for a drop onto this this. |
n_targets |
the number of entries in |