fix: add back save_state() when shuting down
This commit is contained in:
parent
f8f0b0618c
commit
feb557d99b
|
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Some signals weren't properly renamed from the previous GTK3 migration (@MightyCreak)
|
||||
- The syntax menu wasn't working anymore (@MightyCreak)
|
||||
- Properly handles SIGINT (i.e. Ctrl+C) now (@MightyCreak)
|
||||
- Add back `save_state()` to remember window's width and height (@MightyCreak)
|
||||
|
||||
## 0.8.1 - 2023-04-07
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ class DiffuseApplication(Gtk.Application):
|
|||
self.window = None
|
||||
self.sysconfigdir = sysconfigdir
|
||||
|
||||
self.connect('shutdown', self.on_shutdown)
|
||||
|
||||
self.add_main_option(
|
||||
'version',
|
||||
ord('v'),
|
||||
|
@ -249,7 +251,7 @@ also retrieve revisions of files from several VCSs for comparison and merging.''
|
|||
|
||||
# load state
|
||||
self.statepath = os.path.join(data_dir, 'state')
|
||||
diff_window.loadState(self.statepath)
|
||||
diff_window.load_state(self.statepath)
|
||||
|
||||
# process remaining command line arguments
|
||||
encoding = None
|
||||
|
@ -366,6 +368,9 @@ also retrieve revisions of files from several VCSs for comparison and merging.''
|
|||
self.activate()
|
||||
return 0
|
||||
|
||||
def on_shutdown(self, application: Gio.Application) -> None:
|
||||
self.window.save_state(self.statepath)
|
||||
|
||||
|
||||
def main(version: str, sysconfigdir: str) -> int:
|
||||
"""The application's entry point."""
|
||||
|
|
|
@ -985,7 +985,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
|
|||
page.open_file(f, True)
|
||||
|
||||
# record the window's position and size
|
||||
def configure_cb(self, widget, event):
|
||||
def configure_cb(self, widget: Gtk.Widget, event: Gdk.EventConfigure) -> None:
|
||||
# read the state directly instead of using window_maximized as the order
|
||||
# of configure/window_state events is undefined
|
||||
if (widget.get_window().get_state() & Gdk.WindowState.MAXIMIZED) == 0:
|
||||
|
@ -1000,7 +1000,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
|
|||
)
|
||||
|
||||
# load state information that should persist across sessions
|
||||
def loadState(self, statepath: str) -> None:
|
||||
def load_state(self, statepath: str) -> None:
|
||||
if os.path.isfile(statepath):
|
||||
try:
|
||||
f = open(statepath, 'r')
|
||||
|
@ -1030,7 +1030,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
|
|||
self.maximize()
|
||||
|
||||
# save state information that should persist across sessions
|
||||
def saveState(self, statepath: str) -> None:
|
||||
def save_state(self, statepath: str) -> None:
|
||||
try:
|
||||
ss = []
|
||||
for k, v in self.bool_state.items():
|
||||
|
|
Loading…
Reference in New Issue