From 7d7db456c68036cbdcd08140b9ba60a89cc94896 Mon Sep 17 00:00:00 2001 From: 0xMRTT <0xMRTT@proton.me> Date: Wed, 3 May 2023 14:36:50 +0200 Subject: [PATCH] src: add restoring window state --- data/page.codeberg.Imaginer.Imaginer.gschema.xml | 14 +++++++++++++- src/window.py | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/data/page.codeberg.Imaginer.Imaginer.gschema.xml b/data/page.codeberg.Imaginer.Imaginer.gschema.xml index 1527955..0e4c334 100644 --- a/data/page.codeberg.Imaginer.Imaginer.gschema.xml +++ b/data/page.codeberg.Imaginer.Imaginer.gschema.xml @@ -1,5 +1,17 @@ - + + + 640 + + + 480 + + + false + + + false + diff --git a/src/window.py b/src/window.py index 577b1a8..23a37da 100644 --- a/src/window.py +++ b/src/window.py @@ -18,10 +18,10 @@ # SPDX-License-Identifier: GPL-3.0-or-later from gi.repository import Adw -from gi.repository import Gtk +from gi.repository import Gtk, Gio -@Gtk.Template(resource_path="/io/github/ImaginerApp/Imaginer/window.ui") +@Gtk.Template(resource_path="/page/codeberg/Imaginer/Imaginer/window.ui") class ImaginerWindow(Adw.ApplicationWindow): __gtype_name__ = "ImaginerWindow" @@ -39,3 +39,14 @@ class ImaginerWindow(Adw.ApplicationWindow): def __init__(self, **kwargs): super().__init__(**kwargs) + + self.settings = Gio.Settings(schema_id="page.codeberg.Imaginer.Imaginer") + + self.settings.bind("width", self, "default-width", + Gio.SettingsBindFlags.DEFAULT) + self.settings.bind("height", self, "default-height", + Gio.SettingsBindFlags.DEFAULT) + self.settings.bind("is-maximized", self, "maximized", + Gio.SettingsBindFlags.DEFAULT) + self.settings.bind("is-fullscreen", self, "fullscreened", + Gio.SettingsBindFlags.DEFAULT) \ No newline at end of file