Save window geometry
This commit is contained in:
@@ -22,7 +22,18 @@
|
|||||||
<key name="bottles-location" type="s">
|
<key name="bottles-location" type="s">
|
||||||
<default>"~/.var/app/com.usebottles.bottles/data/bottles/"</default>
|
<default>"~/.var/app/com.usebottles.bottles/data/bottles/"</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="sort-mode" type="s">
|
</schema>
|
||||||
|
<schema id="hu.kramo.Cartridge.State" path="/hu/kramo/Cartridges/State/">
|
||||||
|
<key name="width" type="i">
|
||||||
|
<default>1110</default>
|
||||||
|
</key>
|
||||||
|
<key name="height" type="i">
|
||||||
|
<default>820</default>
|
||||||
|
</key>
|
||||||
|
<key name="is-maximized" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
</key>
|
||||||
|
<key name="sort-mode" type="s">
|
||||||
<choices>
|
<choices>
|
||||||
<choice value="a-z"/>
|
<choice value="a-z"/>
|
||||||
<choice value="z-a"/>
|
<choice value="z-a"/>
|
||||||
@@ -32,5 +43,5 @@
|
|||||||
</choices>
|
</choices>
|
||||||
<default>"a-z"</default>
|
<default>"a-z"</default>
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ class CartridgesApplication(Adw.Application):
|
|||||||
if not self.win:
|
if not self.win:
|
||||||
self.win = CartridgesWindow(application=self)
|
self.win = CartridgesWindow(application=self)
|
||||||
|
|
||||||
|
# Save window geometry
|
||||||
|
state_settings = Gio.Settings(schema_id="hu.kramo.Cartridge.State")
|
||||||
|
state_settings.bind("width", self.win, "default-width", Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
state_settings.bind("height", self.win, "default-height", Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
state_settings.bind("is-maximized", self.win, "maximized", Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
|
||||||
self.win.present()
|
self.win.present()
|
||||||
|
|
||||||
# Create actions for the main window
|
# Create actions for the main window
|
||||||
@@ -68,7 +74,7 @@ class CartridgesApplication(Adw.Application):
|
|||||||
self.win.sort = Gio.SimpleAction.new_stateful("sort_by", GLib.VariantType.new("s"), GLib.Variant("s", "a-z"))
|
self.win.sort = Gio.SimpleAction.new_stateful("sort_by", GLib.VariantType.new("s"), GLib.Variant("s", "a-z"))
|
||||||
self.win.add_action(self.win.sort)
|
self.win.add_action(self.win.sort)
|
||||||
self.win.sort.connect("activate", self.win.on_sort_action)
|
self.win.sort.connect("activate", self.win.on_sort_action)
|
||||||
self.win.on_sort_action(self.win.sort, self.win.schema.get_value("sort-mode"))
|
self.win.on_sort_action(self.win.sort, state_settings.get_value("sort-mode"))
|
||||||
|
|
||||||
def on_about_action(self, widget, callback=None):
|
def on_about_action(self, widget, callback=None):
|
||||||
about = Adw.AboutWindow(transient_for=self.win,
|
about = Adw.AboutWindow(transient_for=self.win,
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ Adw.StatusPage hidden_notice_empty {
|
|||||||
|
|
||||||
template CartridgesWindow : Adw.ApplicationWindow {
|
template CartridgesWindow : Adw.ApplicationWindow {
|
||||||
title: _("Cartridges");
|
title: _("Cartridges");
|
||||||
default-width: 1110;
|
|
||||||
default-height: 820;
|
|
||||||
|
|
||||||
Adw.ToastOverlay toast_overlay {
|
Adw.ToastOverlay toast_overlay {
|
||||||
Stack stack {
|
Stack stack {
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
elif state == "last_played":
|
elif state == "last_played":
|
||||||
sort_func = self.last_played_sort
|
sort_func = self.last_played_sort
|
||||||
|
|
||||||
self.schema.set_string("sort-mode", state)
|
Gio.Settings(schema_id="hu.kramo.Cartridge.State").set_string("sort-mode", state)
|
||||||
self.library.set_sort_func(sort_func)
|
self.library.set_sort_func(sort_func)
|
||||||
self.hidden_library.set_sort_func(sort_func)
|
self.hidden_library.set_sort_func(sort_func)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user