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 742865 - feature: Add support for files drag and drop
feature: Add support for files drag and drop
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: editor
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-13 15:24 UTC by Dimitris Zenios
Modified: 2015-01-19 01:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Implement dnd support (14.99 KB, patch)
2015-01-17 13:26 UTC, Dimitris Zenios
committed Details | Review

Description Dimitris Zenios 2015-01-13 15:24:44 UTC
We should allow drag and drop of files onto the editor
Comment 1 Christian Hergert 2015-01-13 21:50:08 UTC
This sounds like a good idea.

So that we can drop a file on an empty workspace, I think we'll want the DnD target to be on GbEditorWorkspace. It is also convenient to put it there since that is where the "open" action lives.
Comment 2 Paolo Borelli 2015-01-13 23:01:55 UTC
Disclaimer: I may be wrong since I am talking about code written a decade ago and because so much changed in gtk

If I recall correctly this is trickier than it looks, because the TextView will eat the drop and decide to insert the filename as a string in the textview: if I am right, then beside handling the drop in GbEditorWorkspace you will also need to override the behavior of GbSourceView.

The corresponding code in gedit is around https://git.gnome.org/browse/gedit/tree/gedit/gedit-view.c#n346

(It also implements the directsave support, which is not a bad thing to have)
Comment 3 Christian Hergert 2015-01-14 00:06:48 UTC
We had some work around code for it when we were doing drag-n-drop tabs, but I ripped that out. The gedit code does in fact look more resilient.
Comment 4 Dimitris Zenios 2015-01-15 00:27:21 UTC
This is more difficult that I thought.Adding drag and drop support on GbEditorWorkspace was easy but we also need a drag_data_received handler on GbSourceView.

By looking gedit code, gedit-view catches the drag_data_received and emits a drop_uri which is then caught by gedit_tab which transmits another drop_uri which is then caught from gedit-window and finally open the files

This approach does not look good and also in gnome-builder we have a much longer abstraction.I cannot assume that every GbDocument will have a DROP_URI that I can connect to it from GbEditorWorkspace

Is there any way I can let the drag_data_received event to propagate from GbSourceView up to GbEditorWorkspace (other than catch and re-fire)
Comment 5 Dimitris Zenios 2015-01-17 13:26:42 UTC
Created attachment 294735 [details] [review]
Implement dnd support

This patch adds support for "text/uri-list" drop type on GbEditorWorkspace and GbSourceView.

This patch does not:
-support dnd on GbDevhelpView
-support dnd on GbHtmlView
-support XdndDirectSave0 drop type
Comment 6 Dimitris Zenios 2015-01-17 13:27:12 UTC
Please review tha patch and if everything is ok I will continue on to implementing the missing staff as well.
Comment 7 Christian Hergert 2015-01-19 01:51:01 UTC
Looks good. Pushed with a follow up commit for style and to use gb_widget_activate_action() (which I just added as well). Should simplify resolving GActions in the future.

Thanks again!