GNOME Bugzilla – Bug 439547
No way to select default action with gtk+ DnD API
Last modified: 2009-11-08 00:41:12 UTC
gtk_drag_dest_set() allows to select multiple GdkDragActions, but doesn't allow to set one as the default, or for the developer to select which modifiers to use for each. For example, in Totem, I would want: - default drop action on the main video widget to be GDK_ACTION_MOVE, and GDK_ACTION_COPY to be used when Ctrl is pressed (replace the current playlist with the drop by default, append to it with Ctrl) - default drop action on the playlist widget to be GDK_ACTION_COPY, and GDK_ACTION_MOVE to be used when Shift is pressed (append to the playlist by default, replace it when Shift is pressed) The current gtk+ API doesn't allow for that.
Was discussed on the GTK+ mailing list at: http://thread.gmane.org/gmane.comp.gnome.gtk+.devel.general/12592
The "default to copy" is codified in xdnd: "The default is XdndActionCopy," Anyway, you should be able to call gdk_drag_status() on the destination side to indicate which action is wanted.
So the right way to do this is to: - connect to the ::drag-motion signal - check the status of the modifiers being used - call gdk_drag_status() with the appropriate GdkDragAction The only thing I'm unsure about is how to get status of the modifiers, or whether we should use the ->suggested_action. If the latter, I'll implement this in Totem and update the gtk_drag_dest_set() docs to include an example of how to override the default action.
Created attachment 123881 [details] [review] add example to gtk_drag_dest_set for selecting action with drag-motion It's now implemented in Totem as described in Bastien's comment. So this patch adds an example of how to do it to gtk_drag_dest_set's documentation.
Created attachment 146758 [details] [review] add example to gtk_drag_dest_set for selecting action with drag-motion (updated)
Comment on attachment 146758 [details] [review] add example to gtk_drag_dest_set for selecting action with drag-motion (updated) Looks good, please commit.
Comment on attachment 146758 [details] [review] add example to gtk_drag_dest_set for selecting action with drag-motion (updated) Committed with a slight change in wording and using gtk_widget_get_window instead of widget->window in the example.
commit 26e2c7f398e9376df4e67ca2d712b38a220b88f5 Author: Robin Stocker <robin@nibor.org> Date: Sun Nov 8 01:27:05 2009 +0100 Example for setting default action in gtk_drag_dest_set