src: add restoring window state

This commit is contained in:
0xMRTT 2023-05-03 14:36:50 +02:00
parent 3bd6ab886e
commit 7d7db456c6
Signed by: 0xMRTT
GPG Key ID: 19C1449A774028BD
2 changed files with 26 additions and 3 deletions

View File

@ -1,5 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="imaginer"> <schemalist gettext-domain="imaginer">
<schema id="page.codeberg.Imaginer.Imaginer" path="/io/github/ImaginerApp/Imaginer/"> <schema id="page.codeberg.Imaginer.Imaginer" path="/page/codeberg/Imaginer/Imaginer/">
<key name="width" type="i">
<default>640</default>
</key>
<key name="height" type="i">
<default>480</default>
</key>
<key name="is-maximized" type="b">
<default>false</default>
</key>
<key name="is-fullscreen" type="b">
<default>false</default>
</key>
</schema> </schema>
</schemalist> </schemalist>

View File

@ -18,10 +18,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from gi.repository import Adw 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): class ImaginerWindow(Adw.ApplicationWindow):
__gtype_name__ = "ImaginerWindow" __gtype_name__ = "ImaginerWindow"
@ -39,3 +39,14 @@ class ImaginerWindow(Adw.ApplicationWindow):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**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)