Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Open in Terminal option #1518

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 0 additions & 11 deletions src/FolderManager/FileItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,8 @@ namespace Scratch.FolderManager {
}

var file_type = info.get_attribute_string (GLib.FileAttribute.STANDARD_CONTENT_TYPE);

var open_in_terminal_pane_item = new GLib.MenuItem (
_("Open in Terminal Pane"),
GLib.Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN_IN_TERMINAL,
new Variant.string (file.file.get_parent ().get_path ())
)
);

var contractor_items = Utils.create_contract_items_for_file (file.file);

var external_actions_section = new GLib.Menu ();
external_actions_section.append_item (open_in_terminal_pane_item);
external_actions_section.append_item (create_submenu_for_open_in (file_type));
if (contractor_items.get_n_items () > 0) {
external_actions_section.append_submenu (
Expand Down
23 changes: 13 additions & 10 deletions src/FolderManager/FolderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,7 @@ namespace Scratch.FolderManager {
}

public override Gtk.Menu? get_context_menu () {
var open_in_terminal_pane_item = new GLib.MenuItem (
(_("Open in Terminal Pane")),
GLib.Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN_IN_TERMINAL,
new Variant.string (file.path)
)
);

GLib.FileInfo info = null;

try {
info = file.file.query_info (GLib.FileAttribute.STANDARD_CONTENT_TYPE, GLib.FileQueryInfoFlags.NONE);
} catch (Error e) {
Expand Down Expand Up @@ -133,7 +124,6 @@ namespace Scratch.FolderManager {
);

var external_actions_section = new GLib.Menu ();
external_actions_section.append_item (open_in_terminal_pane_item);
external_actions_section.append_item (create_submenu_for_open_in (file_type));
if (contractor_items.get_n_items () > 0) {
external_actions_section.append_submenu (_("Other Actions"), contractor_items);
Expand All @@ -158,6 +148,15 @@ namespace Scratch.FolderManager {
}

protected GLib.MenuItem create_submenu_for_open_in (string? file_type) {
var open_in_terminal_pane_item = new GLib.MenuItem (
(_("Terminal Pane")),
GLib.Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN_IN_TERMINAL,
new Variant.string (file.path)
)
);
open_in_terminal_pane_item.set_icon (new ThemedIcon ("panel-bottom-symbolic"));

var other_menu_item = new GLib.MenuItem (
_("Other Application…"),
GLib.Action.print_detailed_name (
Expand All @@ -169,9 +168,13 @@ namespace Scratch.FolderManager {
var extra_section = new GLib.Menu ();
extra_section.append_item (other_menu_item);

var terminal_pane_section = new Menu ();
terminal_pane_section.append_item (open_in_terminal_pane_item);

file_type = file_type ?? "inode/directory";

var open_in_menu = new GLib.Menu ();
open_in_menu.append_section (null, terminal_pane_section);
open_in_menu.append_section (null, Utils.create_executable_app_items_for_file (file.file, file_type));
open_in_menu.append_section (null, extra_section);

Expand Down
19 changes: 0 additions & 19 deletions src/FolderManager/ProjectFolderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,8 @@ namespace Scratch.FolderManager {
warning (e.message);
}

var open_in_terminal_pane_item = new GLib.MenuItem (
_("Open in Terminal Pane"),
GLib.Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN_IN_TERMINAL,
new Variant.string (
Services.GitManager.get_instance ().get_default_build_dir (path)
)
)
);
open_in_terminal_pane_item.set_attribute_value (
"accel",
Utils.get_accel_for_action (
GLib.Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN_IN_TERMINAL,
""
)
)
);

var external_actions_section = new GLib.Menu ();
external_actions_section.append_item (open_in_terminal_pane_item);
external_actions_section.append_item (create_submenu_for_open_in (file_type));

var folder_actions_section = new GLib.Menu ();
Expand Down
Loading