Skip to content

Commit

Permalink
Window: remember size
Browse files Browse the repository at this point in the history
GSettings now stores two schemas that'll remember the window width and
height.

Closes #634
  • Loading branch information
ARAKHNID committed Apr 30, 2024
1 parent 13581ad commit dcb1da0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions data/com.github.maoschanz.drawing.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,20 @@
</key>

<!-- Remembered state of the window -->
<key type="i" name="window-width">
<default>1000</default>
<summary>Width of the window</summary>
<description>The width of the last closed window.</description>
</key>
<key type="i" name="window-height">
<default>600</default>
<summary>Height of the window</summary>
<description>The height of the last closed window.</description>
</key>
<key type="b" name="maximized">
<default>false</default>
<summary>State of the window</summary>
<description>The state of the last closed window.</description>
<summary>Maximization of the window</summary>
<description>The maximization state of the last closed window.</description>
</key>
<key type="b" name="show-labels">
<default>false</default>
Expand Down
3 changes: 3 additions & 0 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, **kwargs):
self.devel_mode = False
self.should_track_framerate = False

self.resize(self.gsettings.get_int("window-width"), self.gsettings.get_int("window-height"))
if self.gsettings.get_boolean('maximized'):
self.maximize()

Expand Down Expand Up @@ -384,6 +385,8 @@ def on_close(self, *args):
self._decorations.remove_from_ui()
self.options_manager.persist_tools_options()
self.gsettings.set_string('last-active-tool', self.active_tool_id)
self.gsettings.set_int("window-width", self.get_size().width)
self.gsettings.set_int("window-height", self.get_size().height)
self.gsettings.set_boolean('maximized', self.is_maximized())
return False

Expand Down

0 comments on commit dcb1da0

Please sign in to comment.