Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -207,8 +209,8 @@ namespace Scratch {
action_accelerators.set (ACTION_FIND_PREVIOUS, "<Control><shift>g");
action_accelerators.set (ACTION_FIND_GLOBAL + "::", "<Control><shift>f");
action_accelerators.set (ACTION_OPEN, "<Control>o");
action_accelerators.set (ACTION_OPEN_FOLDER, "<Control><Shift>o");
action_accelerators.set (ACTION_REVERT, "<Control><shift>o");
action_accelerators.set (ACTION_OPEN_PROJECT, "<Control><Shift>o");
action_accelerators.set (ACTION_REVERT, "<Control><shift>r");
action_accelerators.set (ACTION_SAVE, "<Control>s");
action_accelerators.set (ACTION_SAVE_AS, "<Control><shift>s");
action_accelerators.set (ACTION_GO_TO, "<Control>i");
Expand Down Expand Up @@ -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));
}
Expand Down
3 changes: 1 addition & 2 deletions src/Widgets/ChooseProjectButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/WelcomeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down