Skip to content
Merged
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
20 changes: 17 additions & 3 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -565,9 +567,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);
Expand All @@ -581,6 +580,17 @@ namespace Scratch {

hook_func ();

// Allow secondary windows to have a different pane state
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);
} 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 ();
});

Expand Down Expand Up @@ -842,6 +852,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);
Expand Down