From 5121ccc6d9ea1b835b166f7814f80e561f144696 Mon Sep 17 00:00:00 2001 From: Diego Garcia Gangl Date: Mon, 27 May 2024 18:22:35 -0300 Subject: [PATCH] Restore selected tag from config on startup closes #551 --- GTG/gtk/application.py | 1 + GTG/gtk/browser/main_window.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/GTG/gtk/application.py b/GTG/gtk/application.py index f08af6f7b..46f0ef152 100644 --- a/GTG/gtk/application.py +++ b/GTG/gtk/application.py @@ -237,6 +237,7 @@ def init_browser(self): # Browser (still hidden) if not self.browser: self.browser = MainWindow(self) + self.browser.restore_tag_selection() if self.props.application_id == 'org.gnome.GTG.Devel': self.browser.add_css_class('devel') diff --git a/GTG/gtk/browser/main_window.py b/GTG/gtk/browser/main_window.py index 3f27091ce..57b5cf79b 100644 --- a/GTG/gtk/browser/main_window.py +++ b/GTG/gtk/browser/main_window.py @@ -547,6 +547,21 @@ def restore_collapsed_tasks(self, tasks=None): except IndexError: print(f"Invalid liblarch path {path}") + + def restore_tag_selection(self) -> None: + """Restore tag selection from config.""" + + # NOTE: This needs to run after MainWindow has been initialized + # otherwise tag filtering will throw an error + + selected_tag = self.config.get('selected_tag') + + if not selected_tag: + return + + self.sidebar.select_tag(selected_tag) + + def restore_state_from_conf(self): # NOTE: for the window state to be restored, this must # be called **before** the window is realized. The size @@ -582,6 +597,7 @@ def restore_state_from_conf(self): self.set_sorter(sort_mode.capitalize()) + # Callbacks for sorting and restoring previous state # model = self.vtree_panes['active'].get_model() # model.connect('sort-column-changed', self.on_sort_column_changed)