You've already forked gnatstudio
mirror of
https://github.com/AdaCore/gnatstudio.git
synced 2026-02-12 12:42:33 -08:00
Fix DnD not opening files on windows
Use LSP.URIs API and avoid Glib.Convert. eng/ide/gnatstudio#155
This commit is contained in:
committed by
Adrien Boulanger
parent
4741f765b3
commit
edee8a72b3
@@ -8,6 +8,7 @@ with "../refactoring/core/refactoring_core";
|
||||
with "../toolchains_editor/core/toolchains_core";
|
||||
with "xmlada";
|
||||
with "spawn_glib";
|
||||
with "lsp";
|
||||
|
||||
project Kernel is
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ with DOM.Core.Nodes; use DOM.Core, DOM.Core.Nodes;
|
||||
with DOM.Core.Documents; use DOM.Core.Documents;
|
||||
with DOM.Core.Elements; use DOM.Core.Elements;
|
||||
|
||||
with URIs;
|
||||
with UTF8_Utils; use UTF8_Utils;
|
||||
|
||||
package body GPS.Kernel.Modules.UI is
|
||||
@@ -2432,7 +2433,8 @@ package body GPS.Kernel.Modules.UI is
|
||||
for Url of Uris loop
|
||||
declare
|
||||
File : constant Virtual_File :=
|
||||
Create (+Filename_From_URI (Url.all, null));
|
||||
Create
|
||||
(+Standard.URIs.Conversions.To_File (Url.all, True));
|
||||
begin
|
||||
if File_Extension (File) = Project_File_Extension then
|
||||
Load_Project (Kernel, File);
|
||||
|
||||
@@ -57,6 +57,7 @@ with Gtkada.Style; use Gtkada.Style;
|
||||
with Pango.Layout; use Pango.Layout;
|
||||
with Pango.Attributes; use Pango.Attributes;
|
||||
with Pango.Tabs; use Pango.Tabs;
|
||||
with URIs;
|
||||
|
||||
with VSS.Characters.Latin;
|
||||
|
||||
@@ -92,7 +93,6 @@ with Gtk.Dnd; use Gtk.Dnd;
|
||||
with Gdk.Dnd;
|
||||
with Gtk.Target_List; use Gtk.Target_List;
|
||||
with Gdk.Property; use Gdk.Property;
|
||||
with Glib.Convert; use Glib.Convert;
|
||||
with Gtkada.Types; use Gtkada.Types;
|
||||
|
||||
with GUI_Utils; use GUI_Utils;
|
||||
@@ -1330,30 +1330,35 @@ package body Src_Editor_View is
|
||||
Ignore : Src_Editor_Box.Source_Editor_Box;
|
||||
begin
|
||||
for Url of Uris loop
|
||||
File := Create (+Filename_From_URI (Url.all, null));
|
||||
-- Reset the data
|
||||
Is_Opened := False;
|
||||
In_Notebook := False;
|
||||
Found_Child := null;
|
||||
For_All_Views (View.Kernel, File, Is_In_Notebook'Access);
|
||||
if Is_Opened and then not In_Notebook then
|
||||
-- We don't have File in the current notebook thus create
|
||||
-- a new file view for notebook.
|
||||
Ignore := New_View
|
||||
(View.Kernel,
|
||||
Get_Source_Box_From_MDI (Found_Child),
|
||||
No_Project);
|
||||
else
|
||||
-- Only the last DnD file should steal the focus when DnD
|
||||
-- on Source_View "A". Otherwise, if one of the DnD file
|
||||
-- is already opened in Source_View "B" then all the
|
||||
-- files opened after it will also be opened in "B".
|
||||
Open_File_Action_Hook.Run
|
||||
(View.Kernel,
|
||||
File,
|
||||
Project => No_Project, -- will choose one at random
|
||||
New_File => False,
|
||||
Focus => Uris (Uris'Last) = Url);
|
||||
if Url /= null then
|
||||
-- Filename_From_URI is crashing on windows so avoid it
|
||||
File :=
|
||||
Create
|
||||
(+Standard.URIs.Conversions.To_File (Url.all, True));
|
||||
-- Reset the data
|
||||
Is_Opened := False;
|
||||
In_Notebook := False;
|
||||
Found_Child := null;
|
||||
For_All_Views (View.Kernel, File, Is_In_Notebook'Access);
|
||||
if Is_Opened and then not In_Notebook then
|
||||
-- We don't have File in the current notebook thus create
|
||||
-- a new file view for notebook.
|
||||
Ignore := New_View
|
||||
(View.Kernel,
|
||||
Get_Source_Box_From_MDI (Found_Child),
|
||||
No_Project);
|
||||
else
|
||||
-- Only the last DnD file should steal the focus when DnD
|
||||
-- on Source_View "A". Otherwise, if one of the DnD file
|
||||
-- is already opened in Source_View "B" then all the
|
||||
-- files opened after it will also be opened in "B".
|
||||
Open_File_Action_Hook.Run
|
||||
(View.Kernel,
|
||||
File,
|
||||
Project => No_Project, -- will choose one at random
|
||||
New_File => False,
|
||||
Focus => Uris (Uris'Last) = Url);
|
||||
end if;
|
||||
end if;
|
||||
end loop;
|
||||
Gtk.Dnd.Finish
|
||||
|
||||
Reference in New Issue
Block a user