From dd90185ce29fc32f77b39bc8e073e3d47b97c022 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 23 Jan 2025 17:46:17 +0000 Subject: [PATCH 1/3] Move Open in Terminal option for FolderItem; remove from FileItem --- src/FolderManager/FileItem.vala | 11 ----------- src/FolderManager/FolderItem.vala | 19 +++++++++---------- src/FolderManager/ProjectFolderItem.vala | 19 ------------------- 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/src/FolderManager/FileItem.vala b/src/FolderManager/FileItem.vala index 03d7289275..6b5f3092a3 100644 --- a/src/FolderManager/FileItem.vala +++ b/src/FolderManager/FileItem.vala @@ -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 ( diff --git a/src/FolderManager/FolderItem.vala b/src/FolderManager/FolderItem.vala index 33f8e130de..51907faeec 100644 --- a/src/FolderManager/FolderItem.vala +++ b/src/FolderManager/FolderItem.vala @@ -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) { @@ -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); @@ -158,6 +148,14 @@ namespace Scratch.FolderManager { } protected GLib.MenuItem create_submenu_for_open_in (string? file_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.path) + ) + ); + var other_menu_item = new GLib.MenuItem ( _("Other Application…"), GLib.Action.print_detailed_name ( @@ -168,6 +166,7 @@ namespace Scratch.FolderManager { var extra_section = new GLib.Menu (); extra_section.append_item (other_menu_item); + extra_section.append_item (open_in_terminal_pane_item); file_type = file_type ?? "inode/directory"; diff --git a/src/FolderManager/ProjectFolderItem.vala b/src/FolderManager/ProjectFolderItem.vala index 9998db6be3..0de16e093b 100644 --- a/src/FolderManager/ProjectFolderItem.vala +++ b/src/FolderManager/ProjectFolderItem.vala @@ -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 (); From 19eb54c1948fb038426f73fe1130fc0ea0ff84b6 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 23 Jan 2025 18:01:49 +0000 Subject: [PATCH 2/3] Move to top of submenu and rename --- src/FolderManager/FolderItem.vala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FolderManager/FolderItem.vala b/src/FolderManager/FolderItem.vala index 51907faeec..40869993c5 100644 --- a/src/FolderManager/FolderItem.vala +++ b/src/FolderManager/FolderItem.vala @@ -149,7 +149,7 @@ namespace Scratch.FolderManager { protected GLib.MenuItem create_submenu_for_open_in (string? file_type) { var open_in_terminal_pane_item = new GLib.MenuItem ( - (_("Open in Terminal Pane")), + (_("Terminal Pane")), GLib.Action.print_detailed_name ( MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN_IN_TERMINAL, new Variant.string (file.path) @@ -166,11 +166,14 @@ namespace Scratch.FolderManager { var extra_section = new GLib.Menu (); extra_section.append_item (other_menu_item); - extra_section.append_item (open_in_terminal_pane_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); From 01878fed71c5877abdb06c6f383cfafe318bfdd2 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 23 Jan 2025 18:07:51 +0000 Subject: [PATCH 3/3] Add an icon --- src/FolderManager/FolderItem.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FolderManager/FolderItem.vala b/src/FolderManager/FolderItem.vala index 40869993c5..4484b74a33 100644 --- a/src/FolderManager/FolderItem.vala +++ b/src/FolderManager/FolderItem.vala @@ -155,6 +155,7 @@ namespace Scratch.FolderManager { 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…"),