Skip to content

Commit fd48d92

Browse files
authored
Merge branch 'master' into jeremypw/v8.1.2-metainfo
2 parents 52d46b7 + a296348 commit fd48d92

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

src/MainWindow.vala

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ namespace Scratch {
7676
public const string ACTION_FIND_GLOBAL = "action-find-global";
7777
public const string ACTION_OPEN = "action-open";
7878
public const string ACTION_OPEN_FOLDER = "action-open-folder";
79+
public const string ACTION_OPEN_PROJECT = "action-open-project";
7980
public const string ACTION_COLLAPSE_ALL_FOLDERS = "action-collapse-all-folders";
8081
public const string ACTION_ORDER_FOLDERS = "action-order-folders";
8182
public const string ACTION_GO_TO = "action-go-to";
@@ -138,6 +139,7 @@ namespace Scratch {
138139
{ ACTION_FIND_GLOBAL, action_find_global, "s" },
139140
{ ACTION_OPEN, action_open },
140141
{ ACTION_OPEN_FOLDER, action_open_folder, "s" },
142+
{ ACTION_OPEN_PROJECT, action_open_project },
141143
{ ACTION_COLLAPSE_ALL_FOLDERS, action_collapse_all_folders },
142144
{ ACTION_ORDER_FOLDERS, action_order_folders },
143145
{ ACTION_PREFERENCES, action_preferences },
@@ -207,8 +209,8 @@ namespace Scratch {
207209
action_accelerators.set (ACTION_FIND_PREVIOUS, "<Control><shift>g");
208210
action_accelerators.set (ACTION_FIND_GLOBAL + "::", "<Control><shift>f");
209211
action_accelerators.set (ACTION_OPEN, "<Control>o");
210-
action_accelerators.set (ACTION_OPEN_FOLDER, "<Control><Shift>o");
211-
action_accelerators.set (ACTION_REVERT, "<Control><shift>o");
212+
action_accelerators.set (ACTION_OPEN_PROJECT, "<Control><Shift>o");
213+
action_accelerators.set (ACTION_REVERT, "<Control><shift>r");
212214
action_accelerators.set (ACTION_SAVE, "<Control>s");
213215
action_accelerators.set (ACTION_SAVE_AS, "<Control><shift>s");
214216
action_accelerators.set (ACTION_GO_TO, "<Control>i");
@@ -1019,25 +1021,34 @@ namespace Scratch {
10191021
new_window.open_document.begin (doc, true);
10201022
}
10211023

1022-
private void action_open_folder (SimpleAction action, Variant? param) {
1023-
var path = param.get_string ();
1024-
if (path == "") {
1025-
var chooser = new Gtk.FileChooserNative (
1026-
"Select a folder.", this, Gtk.FileChooserAction.SELECT_FOLDER,
1027-
_("_Open"),
1028-
_("_Cancel")
1029-
);
10301024

1031-
chooser.select_multiple = true;
1025+
private void action_open_project (SimpleAction action) {
1026+
choose_folder ();
1027+
}
10321028

1033-
if (chooser.run () == Gtk.ResponseType.ACCEPT) {
1034-
chooser.get_files ().foreach ((glib_file) => {
1035-
var foldermanager_file = new FolderManager.File (glib_file.get_path ());
1036-
folder_manager_view.open_folder (foldermanager_file);
1037-
});
1038-
}
1029+
private void choose_folder () {
1030+
var chooser = new Gtk.FileChooserNative (
1031+
"Select a folder.", this, Gtk.FileChooserAction.SELECT_FOLDER,
1032+
_("_Open"),
1033+
_("_Cancel")
1034+
);
1035+
1036+
chooser.select_multiple = true;
10391037

1040-
chooser.destroy ();
1038+
if (chooser.run () == Gtk.ResponseType.ACCEPT) {
1039+
chooser.get_files ().foreach ((glib_file) => {
1040+
var foldermanager_file = new FolderManager.File (glib_file.get_path ());
1041+
folder_manager_view.open_folder (foldermanager_file);
1042+
});
1043+
}
1044+
1045+
chooser.destroy ();
1046+
}
1047+
1048+
private void action_open_folder (SimpleAction action, Variant? param) {
1049+
var path = param.get_string ();
1050+
if (path == "") {
1051+
choose_folder ();
10411052
} else {
10421053
folder_manager_view.open_folder (new FolderManager.File (path));
10431054
}

src/Widgets/ChooseProjectButton.vala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
8282
project_scrolled.add (project_listbox);
8383

8484
var add_folder_button = new PopoverMenuItem (_("Open Folder…")) {
85-
action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER,
86-
action_target = new Variant.string (""),
85+
action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_PROJECT,
8786
icon_name = "folder-open-symbolic",
8887
};
8988

src/Widgets/WelcomeView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Code.WelcomeView : Granite.Widgets.Welcome {
4040
} else if (i == 1) {
4141
Scratch.Utils.action_from_group (Scratch.MainWindow.ACTION_OPEN, window.actions).activate (null);
4242
} else if (i == 2) {
43-
Scratch.Utils.action_from_group (Scratch.MainWindow.ACTION_OPEN_FOLDER, window.actions).activate ("");
43+
Scratch.Utils.action_from_group (Scratch.MainWindow.ACTION_OPEN_PROJECT, window.actions).activate (null);
4444
}
4545
});
4646
}

0 commit comments

Comments
 (0)