From 72184ba447a299495fcb2a51489471d01ad10326 Mon Sep 17 00:00:00 2001 From: Colin Kiama Date: Tue, 21 Nov 2023 02:45:51 +0000 Subject: [PATCH 1/2] Launching app with no command line args will open a new window by default --- src/Application.vala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 2c02f652e..75dffacba 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -99,7 +99,7 @@ namespace Scratch { create_new_tab = true; } - if (options.contains ("new-window")) { + if (options.contains ("new-window") || has_no_command_line_args (options)) { create_new_window = true; } @@ -165,5 +165,10 @@ namespace Scratch { public static int main (string[] args) { return new Application ().run (args); } + + private bool has_no_command_line_args (GLib.VariantDict options) { + return options.contains ("new-tab") == false + && options.contains (GLib.OPTION_REMAINING) == false; + } } } From 00013558ea13f94b3730b48b655d68f70e32e655 Mon Sep 17 00:00:00 2001 From: Colin Kiama Date: Tue, 21 Nov 2023 02:46:14 +0000 Subject: [PATCH 2/2] Fix new tab command line option --- src/Application.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 75dffacba..c3bf18ea9 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -137,7 +137,8 @@ namespace Scratch { // Create a new document if requested if (create_new_tab) { create_new_tab = false; - activate_action (MainWindow.ACTION_PREFIX + MainWindow.ACTION_NEW_TAB, null); + var active_window_action_group = active_window.get_action_group (MainWindow.ACTION_GROUP); + active_window_action_group.activate_action (MainWindow.ACTION_NEW_TAB, null); } }