diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 2c77c8764..bcf37aeb6 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -76,6 +76,7 @@ namespace Scratch { public const string ACTION_FIND_GLOBAL = "action-find-global"; public const string ACTION_OPEN = "action-open"; public const string ACTION_OPEN_FOLDER = "action-open-folder"; + public const string ACTION_OPEN_PROJECT = "action-open-project"; public const string ACTION_COLLAPSE_ALL_FOLDERS = "action-collapse-all-folders"; public const string ACTION_ORDER_FOLDERS = "action-order-folders"; public const string ACTION_GO_TO = "action-go-to"; @@ -138,6 +139,7 @@ namespace Scratch { { ACTION_FIND_GLOBAL, action_find_global, "s" }, { ACTION_OPEN, action_open }, { ACTION_OPEN_FOLDER, action_open_folder, "s" }, + { ACTION_OPEN_PROJECT, action_open_project }, { ACTION_COLLAPSE_ALL_FOLDERS, action_collapse_all_folders }, { ACTION_ORDER_FOLDERS, action_order_folders }, { ACTION_PREFERENCES, action_preferences }, @@ -207,8 +209,8 @@ namespace Scratch { action_accelerators.set (ACTION_FIND_PREVIOUS, "g"); action_accelerators.set (ACTION_FIND_GLOBAL + "::", "f"); action_accelerators.set (ACTION_OPEN, "o"); - action_accelerators.set (ACTION_OPEN_FOLDER, "o"); - action_accelerators.set (ACTION_REVERT, "o"); + action_accelerators.set (ACTION_OPEN_PROJECT, "o"); + action_accelerators.set (ACTION_REVERT, "r"); action_accelerators.set (ACTION_SAVE, "s"); action_accelerators.set (ACTION_SAVE_AS, "s"); action_accelerators.set (ACTION_GO_TO, "i"); @@ -1019,25 +1021,34 @@ namespace Scratch { new_window.open_document.begin (doc, true); } - private void action_open_folder (SimpleAction action, Variant? param) { - var path = param.get_string (); - if (path == "") { - var chooser = new Gtk.FileChooserNative ( - "Select a folder.", this, Gtk.FileChooserAction.SELECT_FOLDER, - _("_Open"), - _("_Cancel") - ); - chooser.select_multiple = true; + private void action_open_project (SimpleAction action) { + choose_folder (); + } - if (chooser.run () == Gtk.ResponseType.ACCEPT) { - chooser.get_files ().foreach ((glib_file) => { - var foldermanager_file = new FolderManager.File (glib_file.get_path ()); - folder_manager_view.open_folder (foldermanager_file); - }); - } + private void choose_folder () { + var chooser = new Gtk.FileChooserNative ( + "Select a folder.", this, Gtk.FileChooserAction.SELECT_FOLDER, + _("_Open"), + _("_Cancel") + ); + + chooser.select_multiple = true; - chooser.destroy (); + if (chooser.run () == Gtk.ResponseType.ACCEPT) { + chooser.get_files ().foreach ((glib_file) => { + var foldermanager_file = new FolderManager.File (glib_file.get_path ()); + folder_manager_view.open_folder (foldermanager_file); + }); + } + + chooser.destroy (); + } + + private void action_open_folder (SimpleAction action, Variant? param) { + var path = param.get_string (); + if (path == "") { + choose_folder (); } else { folder_manager_view.open_folder (new FolderManager.File (path)); } diff --git a/src/Widgets/ChooseProjectButton.vala b/src/Widgets/ChooseProjectButton.vala index 7c6c658bb..84b0a03cc 100644 --- a/src/Widgets/ChooseProjectButton.vala +++ b/src/Widgets/ChooseProjectButton.vala @@ -82,8 +82,7 @@ public class Code.ChooseProjectButton : Gtk.MenuButton { project_scrolled.add (project_listbox); var add_folder_button = new PopoverMenuItem (_("Open Folder…")) { - action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER, - action_target = new Variant.string (""), + action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_PROJECT, icon_name = "folder-open-symbolic", }; diff --git a/src/Widgets/WelcomeView.vala b/src/Widgets/WelcomeView.vala index 707365213..de06651ec 100644 --- a/src/Widgets/WelcomeView.vala +++ b/src/Widgets/WelcomeView.vala @@ -40,7 +40,7 @@ public class Code.WelcomeView : Granite.Widgets.Welcome { } else if (i == 1) { Scratch.Utils.action_from_group (Scratch.MainWindow.ACTION_OPEN, window.actions).activate (null); } else if (i == 2) { - Scratch.Utils.action_from_group (Scratch.MainWindow.ACTION_OPEN_FOLDER, window.actions).activate (""); + Scratch.Utils.action_from_group (Scratch.MainWindow.ACTION_OPEN_PROJECT, window.actions).activate (null); } }); }