Skip to content

Commit

Permalink
Restore selected tag from config on startup
Browse files Browse the repository at this point in the history
closes #551
  • Loading branch information
diegogangl committed Jun 3, 2024
1 parent db63923 commit c501ff8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions GTG/gtk/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
16 changes: 16 additions & 0 deletions GTG/gtk/browser/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c501ff8

Please sign in to comment.