From e14d325c2045dc1a2ad0876157eaf89cbcec78aa Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Mon, 22 Jun 2026 14:13:45 +0100 Subject: [PATCH 1/3] Allow secondary windows to have different pane state --- src/MainWindow.vala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 78b9b1d1ec..9f236dcdd2 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -575,9 +575,6 @@ namespace Scratch { size_group.add_widget (toolbar); realize.connect (() => { - Scratch.saved_state.bind ("sidebar-visible", sidebar, "visible", SettingsBindFlags.DEFAULT); - Scratch.saved_state.bind ("outline-visible", document_view , "outline_visible", SettingsBindFlags.DEFAULT); - Scratch.saved_state.bind ("terminal-visible", terminal, "visible", SettingsBindFlags.DEFAULT); // Plugins hook HookFunc hook_func = () => { plugins.hook_window (this); @@ -591,7 +588,14 @@ namespace Scratch { hook_func (); - restore (); + // Allow secondary windows to have a different pane state + if (application.get_windows ().length () <= 1) { + Scratch.saved_state.bind ("sidebar-visible", sidebar, "visible", SettingsBindFlags.DEFAULT); + Scratch.saved_state.bind ("outline-visible", document_view , "outline_visible", SettingsBindFlags.DEFAULT); + Scratch.saved_state.bind ("terminal-visible", terminal, "visible", SettingsBindFlags.DEFAULT); + + restore (); + } }); document_view.realize.connect (() => { From 54ebad1c03a08256bbef7ab9a2299dafe2f0b193 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sun, 28 Jun 2026 10:17:53 +0100 Subject: [PATCH 2/3] Initialize pane visibilities of secondary windows --- src/MainWindow.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index dc8b9ff94a..b3f498481e 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -587,9 +587,13 @@ namespace Scratch { Scratch.saved_state.bind ("sidebar-visible", sidebar, "visible", SettingsBindFlags.DEFAULT); Scratch.saved_state.bind ("outline-visible", document_view , "outline_visible", SettingsBindFlags.DEFAULT); Scratch.saved_state.bind ("terminal-visible", terminal, "visible", SettingsBindFlags.DEFAULT); - - restore (); + } else { + sidebar.visible = Scratch.saved_state.get_boolean ("sidebar-visible"); + document_view.outline_visible = Scratch.saved_state.get_boolean ("outline-visible"); + terminal.visible = Scratch.saved_state.get_boolean ("terminal-visible"); } + + restore (); }); document_view.realize.connect (() => { From e149165f02f3f3cc6c9e55fb30b6b5515b1eba8a Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sun, 28 Jun 2026 10:31:19 +0100 Subject: [PATCH 3/3] Only save window state and pane size for primary window --- src/MainWindow.vala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b3f498481e..fec43a4b39 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -131,6 +131,7 @@ namespace Scratch { private ulong color_scheme_listener_handler_id = 0; private Services.GitManager git_manager; + private bool is_first_window; private const ActionEntry[] ACTION_ENTRIES = { { ACTION_CLONE_REPO, action_clone_repo }, @@ -277,6 +278,7 @@ namespace Scratch { construct { application = ((Gtk.Application)(GLib.Application.get_default ())); app = (Scratch.Application)application; + is_first_window = application.get_windows ().length () == 1; title = base_title; weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_default (); @@ -583,7 +585,7 @@ namespace Scratch { hook_func (); // Allow secondary windows to have a different pane state - if (application.get_windows ().length () <= 1) { + if (is_first_window) { Scratch.saved_state.bind ("sidebar-visible", sidebar, "visible", SettingsBindFlags.DEFAULT); Scratch.saved_state.bind ("outline-visible", document_view , "outline_visible", SettingsBindFlags.DEFAULT); Scratch.saved_state.bind ("terminal-visible", terminal, "visible", SettingsBindFlags.DEFAULT); @@ -854,6 +856,10 @@ namespace Scratch { private void update_window_state_setting () { // Save window state + if (!is_first_window) { + return; + } + var state = get_window ().get_state (); if (Gdk.WindowState.MAXIMIZED in state) { Scratch.saved_state.set_enum ("window-state", ScratchWindowState.MAXIMIZED);