Skip to content

Draft: fix d&d from project tree to editor view

So, when d&d-ing a file from nautilus to the editor view, the file is correctly opened like so:


But when d&d-ing a file from the project tree to the editor view, it doesn't open:


So I figured out the d&d from the project tree files/folders happens in src/plugins/project-tree/gbp-project-tree-addin.c, and the panes tiling + d&d animation happens in src/libide/gui/ide-grid.c .

With a stock Builder, if you add a breakpoint in ide_grid_drag_data_received, it'll break on this breakpoint only when the file is drag-and-dropped from an external app like Files. So the grid seems to listen only for URIs d&d targets, so I believe Files provides an URIs d&d target too, and the project tree dragged row must not provide correctly an URIs target because it doesn't trigger the ide_grid_drag_data_received signal. But both the grid and the project tree declare the text/uri-list target exactly the same way :/ But if I add the other target entry of the project tree to the grid (GTK_TREE_MODEL_ROW), as done with the WIP commit of this MR (that you can try), then the ide_grid_drag_data_received is triggered, though it doesn't go far since it doesn't have the URIs. It seems that although the GTK_TREE_MODEL_ROW source drag data is set automatically for the project tree with gtk_tree_view_enable_model_drag_source in gbp_project_tree_addin_load, the text/uri-list target entry isn't set anywhere.

I haven't done any GTK d&d work before, so from here I'm not sure how to go forward. It seems that when it wants the uris it probably runs this function on the dragged row, so what do I need to do so that when it tries running this function on the source row it gets the project's file file:/// URI of the row ?

If I'm unclear about all this, please say so, as it isn't fully clear in my mind either :/ since it is the result of my researches through the code and after testing a few thing.

Merge request reports