diff --git a/src/FolderManager/FileItem.vala b/src/FolderManager/FileItem.vala index 0b936a41e..03d728927 100644 --- a/src/FolderManager/FileItem.vala +++ b/src/FolderManager/FileItem.vala @@ -27,6 +27,10 @@ namespace Scratch.FolderManager { Object (file: file, view: view); } + public override void activated () { + view.activate (file.path); + } + public override Gtk.Menu? get_context_menu () { GLib.FileInfo info = null; diff --git a/src/FolderManager/FileView.vala b/src/FolderManager/FileView.vala index 684074922..ec0767889 100644 --- a/src/FolderManager/FileView.vala +++ b/src/FolderManager/FileView.vala @@ -53,12 +53,11 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane private Scratch.Services.GitManager git_manager; private Scratch.Services.PluginsManager plugins; - public signal void select (string file); + public new signal void activate (string file); public signal bool rename_request (File file); public SimpleActionGroup actions { get; private set; } public ActionGroup toplevel_action_group { get; private set; } - public bool ignore_next_select { get; set; default = false; } public string icon_name { get; set; } public string title { get; set; } public string active_project_path { @@ -72,11 +71,10 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane } construct { + activate_on_single_click = true; icon_name = "folder-symbolic"; title = _("Folders"); - item_selected.connect (on_item_selected); - settings = new GLib.Settings ("io.elementary.code.folder-manager"); git_manager = Scratch.Services.GitManager.get_instance (); @@ -128,19 +126,6 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane write_settings (); } - private void on_item_selected (Code.Widgets.SourceList.Item? item) { - // This is a workaround for SourceList silliness: you cannot remove an item - // without it automatically selecting another one. - if (ignore_next_select) { - ignore_next_select = false; - return; - } - - if (item is FileItem) { - select (((FileItem) item).file.path); - } - } - public void restore_saved_state () { foreach (unowned string path in settings.get_strv ("opened-folders")) { add_folder (new File (path), false); @@ -184,9 +169,7 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane } public void select_path (string path) { - item_selected.disconnect (on_item_selected); selected = find_path (root, path); - item_selected.connect (on_item_selected); } public void unselect_all () { @@ -322,7 +305,7 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane selected.disconnect (once); var new_path = Path.get_dirname (path) + Path.DIR_SEPARATOR_S + new_name; this.toplevel_action_group.activate_action (MainWindow.ACTION_CLOSE_TAB, new Variant.string (path)); - this.select (new_path); + activate (new_path); }); } diff --git a/src/FolderManager/FolderItem.vala b/src/FolderManager/FolderItem.vala index 2c7687ab2..33f8e130d 100644 --- a/src/FolderManager/FolderItem.vala +++ b/src/FolderManager/FolderItem.vala @@ -237,7 +237,6 @@ namespace Scratch.FolderManager { } } - view.ignore_next_select = true; ((Code.Widgets.SourceList.ExpandableItem)this).remove (item); // Add back dummy if empty if (!(has_dummy || n_children > 0)) { @@ -384,7 +383,7 @@ namespace Scratch.FolderManager { gfile.make_directory (); } else { gfile.create (FileCreateFlags.NONE); - view.select (gfile.get_path ()); + view.activate (gfile.get_path ()); } } catch (Error e) { warning (e.message); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 431eeef82..34fe7d93d 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -481,7 +481,7 @@ namespace Scratch { sidebar.add_tab (folder_manager_view); folder_manager_view.show_all (); - folder_manager_view.select.connect ((a) => { + folder_manager_view.activate.connect ((a) => { var file = new Scratch.FolderManager.File (a); var doc = new Scratch.Services.Document (actions, file.file); diff --git a/src/Widgets/SourceList/SourceList.vala b/src/Widgets/SourceList/SourceList.vala index ee3e5af50..0ecff6dae 100644 --- a/src/Widgets/SourceList/SourceList.vala +++ b/src/Widgets/SourceList/SourceList.vala @@ -2646,6 +2646,12 @@ public class SourceList : Gtk.ScrolledWindow { get { return tree.editing; } } + public bool activate_on_single_click { + set { + tree.activate_on_single_click = value; + } + } + private Tree tree; private DataModel data_model = new DataModel ();