Properly remember window size and state

The previous commit's way of doing it worked but was not adviseable
This commit is contained in:
heliguy4599
2023-10-04 17:33:18 -04:00
parent 932e17672b
commit cf1146741a
2 changed files with 16 additions and 11 deletions

View File

@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="warehouse">
<schema id="io.github.flattool.Warehouse" path="/io/github/flattool/Warehouse/">
<key name="window-width" type="i">
<default>800</default>
<summary>Window Width</summary>
<description>The width of the main window</description>
</key>
<key name="window-height" type="i">
<default>500</default>
<summary>Window Height</summary>
<description>The height of the main window</description>
</key>
<key name="window-width" type="i">
<default>640</default>
</key>
<key name="window-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>
</schemalist>

View File

@@ -526,7 +526,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.host_flatpaks = self.my_utils.getHostFlatpaks()
self.set_size_request(0, 230)
self.settings = Gio.Settings.new("io.github.flattool.Warehouse")
self.loadSettings()
self.settings.bind("window-width", self, "default-width", Gio.SettingsBindFlags.DEFAULT)
self.settings.bind("window-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)
if self.host_flatpaks == [['']]:
self.windowSetEmpty(True)