From d292a99791f3346667cf24a6e1cf5c1720ef245c Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 7 Oct 2023 17:19:14 -0500 Subject: [PATCH] Persisting window state; fixed onload widgets seen bug; changed toggler keymap --- src/core/editors_container.py | 9 +++---- .../widgets/base/notebook/editor_notebook.py | 2 ++ src/core/window.py | 24 +++++++++++++++++-- src/utils/settings_manager/manager.py | 12 +++++----- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/core/editors_container.py b/src/core/editors_container.py index 710b2a1..a92f033 100644 --- a/src/core/editors_container.py +++ b/src/core/editors_container.py @@ -20,13 +20,11 @@ class EditorsPaned(Gtk.Paned): self._subscribe_to_events() self._load_widgets() - self.show_all() + self.show() def _setup_styling(self): self.set_wide_handle(True) - self.set_vexpand(True) - self.set_hexpand(True) def _setup_signals(self): ... @@ -50,12 +48,11 @@ class EditorsContainer(Gtk.Box): self._subscribe_to_events() self._load_widgets() - self.show_all() + self.show() def _setup_styling(self): - self.set_vexpand(True) - self.set_hexpand(True) + ... def _setup_signals(self): ... diff --git a/src/core/widgets/base/notebook/editor_notebook.py b/src/core/widgets/base/notebook/editor_notebook.py index d6385ef..f408ef4 100644 --- a/src/core/widgets/base/notebook/editor_notebook.py +++ b/src/core/widgets/base/notebook/editor_notebook.py @@ -52,6 +52,8 @@ class EditorNotebook(EditorEventsMixin, EditorControllerMixin, Gtk.Notebook): def _setup_styling(self): self.set_scrollable(True) + self.set_vexpand(True) + self.set_hexpand(True) def _setup_signals(self): self.connect("switch-page", self._switch_page_update) diff --git a/src/core/window.py b/src/core/window.py index d428947..d9c0ead 100644 --- a/src/core/window.py +++ b/src/core/window.py @@ -36,13 +36,12 @@ class Window(Gtk.ApplicationWindow): settings_manager.set_main_window(self) self._load_widgets(args, unknownargs) + self._set_size_constraints() self.show() def _setup_styling(self): - self.set_default_size(settings.config.main_window_width, - settings.config.main_window_height) self.set_title(f"{app_name}") self.set_icon_from_file( settings_manager.get_window_icon() ) self.set_gravity(5) # 5 = CENTER @@ -65,6 +64,18 @@ class Window(Gtk.ApplicationWindow): self.add( self._controller.get_core_widget() ) + def _set_size_constraints(self): + _window_x = settings.config.main_window_x + _window_y = settings.config.main_window_y + _min_width = settings.config.main_window_min_width + _min_height = settings.config.main_window_min_height + _width = settings.config.main_window_width + _height = settings.config.main_window_height + + self.move(_window_x, _window_y - 28) + self.set_size_request(_min_width, _min_height) + self.set_default_size(_width, _height) + def _set_window_data(self) -> None: screen = self.get_screen() visual = screen.get_rgba_visual() @@ -89,6 +100,15 @@ class Window(Gtk.ApplicationWindow): def _tear_down(self, widget=None, eve=None): + size = self.get_size() + pos = self.get_position() + + settings_manager.set_main_window_width(size.width) + settings_manager.set_main_window_height(size.height) + settings_manager.set_main_window_x(pos.root_x) + settings_manager.set_main_window_y(pos.root_y) + settings_manager.save_settings() + settings_manager.clear_pid() time.sleep(event_sleep_time) Gtk.main_quit() diff --git a/src/utils/settings_manager/manager.py b/src/utils/settings_manager/manager.py index dd512c7..f76d58b 100644 --- a/src/utils/settings_manager/manager.py +++ b/src/utils/settings_manager/manager.py @@ -146,12 +146,12 @@ class SettingsManager(StartCheckMixin, Singleton): method = getattr(target_class, method_name, lambda data: f"No valid key passed...\nkey={method_name}\nargs={data}") return method(data) if data else method() - def set_main_window_x(self, x = 0): self.settings.config.window_x = x - def set_main_window_y(self, y = 0): self.settings.config.window_y = y - def set_main_window_width(self, width = 800): self.settings.config.window_width = width - def set_main_window_height(self, height = 600): self.settings.config.window_height = height - def set_main_window_min_width(self, width = 720): self.settings.config.window_min_width = width - def set_main_window_min_height(self, height = 480): self.settings.config.window_min_height = height + def set_main_window_x(self, x = 0): self.settings.config.main_window_x = x + def set_main_window_y(self, y = 0): self.settings.config.main_window_y = y + def set_main_window_width(self, width = 800): self.settings.config.main_window_width = width + def set_main_window_height(self, height = 600): self.settings.config.main_window_height = height + def set_main_window_min_width(self, width = 720): self.settings.config.main_window_min_width = width + def set_main_window_min_height(self, height = 480): self.settings.config.main_window_min_height = height def set_trace_debug(self, trace_debug): self._trace_debug = trace_debug