After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 439547 - No way to select default action with gtk+ DnD API
No way to select default action with gtk+ DnD API
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 372220
 
 
Reported: 2007-05-18 23:13 UTC by Bastien Nocera
Modified: 2009-11-08 00:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add example to gtk_drag_dest_set for selecting action with drag-motion (1.10 KB, patch)
2008-12-03 16:53 UTC, Robin Stocker
none Details | Review
add example to gtk_drag_dest_set for selecting action with drag-motion (updated) (1.05 KB, patch)
2009-11-02 16:03 UTC, Robin Stocker
committed Details | Review

Description Bastien Nocera 2007-05-18 23:13:35 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.
Comment 1 Bastien Nocera 2007-05-18 23:15:05 UTC
Was discussed on the GTK+ mailing list at:
http://thread.gmane.org/gmane.comp.gnome.gtk+.devel.general/12592
Comment 2 Matthias Clasen 2007-05-25 03:19:24 UTC
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.
Comment 3 Bastien Nocera 2007-08-26 20:54:52 UTC
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.
Comment 4 Robin Stocker 2008-12-03 16:53:31 UTC
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.
Comment 5 Robin Stocker 2009-11-02 16:03:45 UTC
Created attachment 146758 [details] [review]
add example to gtk_drag_dest_set for selecting action with drag-motion (updated)
Comment 6 Matthias Clasen 2009-11-05 22:55:21 UTC
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 7 Robin Stocker 2009-11-08 00:39:46 UTC
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.
Comment 8 Robin Stocker 2009-11-08 00:41:12 UTC
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