Skip to content

Commit

Permalink
Save window size on close
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawstorant committed Nov 13, 2024
1 parent 80caa99 commit 2430818
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
26 changes: 25 additions & 1 deletion boxflat/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class MainWindow(Adw.ApplicationWindow):
def __init__(self, navigation: Adw.NavigationSplitView):
super().__init__()
self.set_default_size(0, 850)
self.set_title("Boxflat")
self.set_content(navigation)
self._data_path = None
Expand Down Expand Up @@ -206,12 +205,37 @@ def on_activate(self, app):
if self.navigation.get_root() != None:
return


win = MainWindow(self.navigation)
win.set_application(app)
win.connect("close-request", lambda *_: Thread(target=self._show_bg_notification, daemon=True).start())
win.connect("close-request", self._save_window_info)

win.present()
win.check_udev(self._data_path)

saved_state = self._settings.read_setting("window_state")

if not saved_state:
win.set_default_size(0, 850)
return

win.set_default_size(saved_state["width"], saved_state["height"])
if saved_state["maximized"]:
win.maximize()

if saved_state["fullscreen"]:
win.fullscreen()


def _save_window_info(self, window: Adw.ApplicationWindow) -> None:
self._settings.write_setting({
"width" : window.get_default_size().width,
"height" : window.get_default_size().height,
"maximized" : window.is_maximized(),
"fullscreen" : window.is_fullscreen()
}, "window_state")


def _show_bg_notification(self, *_) -> None:
if self._settings.read_setting("background-notified") == 1:
Expand Down
2 changes: 1 addition & 1 deletion data/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.25.1
v1.25.2
5 changes: 5 additions & 0 deletions io.github.lawstorant.boxflat.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
<update_contact>[email protected]</update_contact>

<releases>
<release version="v1.25.2" date="2024-11-13">
<description>
<p>Save window size when closed</p>
</description>
</release>
<release version="v1.25.1" date="2024-11-13">
<description>
<p>Keep the linked process while overwriting a preset</p>
Expand Down

0 comments on commit 2430818

Please sign in to comment.