From 2a37108ccb2698e3dddc5029224f7ef464055ed0 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Tue, 24 Dec 2024 09:32:33 -0500 Subject: [PATCH] list: Split update bottles list and show page This also gets rid of all the weird callbacks with `GLib.idle_add()` and other methods. --- bottles/frontend/views/list.py | 27 +++++---------------------- bottles/frontend/views/new.py | 5 ++--- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/bottles/frontend/views/list.py b/bottles/frontend/views/list.py index a1e2a4522b..59cbc4b2fe 100644 --- a/bottles/frontend/views/list.py +++ b/bottles/frontend/views/list.py @@ -155,7 +155,7 @@ def __init__(self, window, arg_bottle=None, **kwargs): # backend signals SignalManager.connect( - Signals.ManagerLocalBottlesLoaded, self.backend_local_bottle_loaded + Signals.ManagerLocalBottlesLoaded, self.update_bottles_list ) self.bottle_status.set_icon_name(APP_ID) @@ -176,7 +176,7 @@ def __filter_bottles(row, terms=None): text = row.get_title().lower() return terms.lower() in text - def idle_update_bottles_list(self, show=False): + def update_bottles_list(self, *args) -> None: self.__bottles = {} while self.list_bottles.get_first_child(): self.list_bottles.remove(self.list_bottles.get_first_child()) @@ -206,26 +206,9 @@ def idle_update_bottles_list(self, show=False): self.group_steam.set_visible(True) self.group_bottles.set_title(_("Your Bottles")) - if ( - self.arg_bottle is not None and self.arg_bottle in local_bottles.keys() - ) or (show is not None and show in local_bottles.keys()): - _config = None - if self.arg_bottle: - _config = local_bottles[self.arg_bottle] - if show: - _config = local_bottles[show] - if not _config: - raise NotImplementedError("neither 'arg_bottle' nor 'show' are set") - - self.window.page_details.view_preferences.update_combo_components() - self.window.show_details_view(config=_config) - self.arg_bottle = None - - def backend_local_bottle_loaded(self, _: Result): - self.update_bottles_list() - - def update_bottles_list(self, show=False): - GLib.idle_add(self.idle_update_bottles_list, show) + def show_page(self, page: str) -> None: + if config := self.window.manager.local_bottles.get(page): + self.window.show_details_view(config=config) def disable_bottle(self, config): self.__bottles[config.Path].disable() diff --git a/bottles/frontend/views/new.py b/bottles/frontend/views/new.py index 1755e76d16..8c5678fed4 100644 --- a/bottles/frontend/views/new.py +++ b/bottles/frontend/views/new.py @@ -243,9 +243,8 @@ def send_notification(notification: Gio.Notification) -> None: # Ask the manager to check for new bottles, # then update the user bottles' list. self.manager.check_bottles() - self.window.page_list.update_bottles_list( - show=result.data.get("config").get("Path") - ) + self.window.page_list.update_bottles_list() + self.window.page_list.show_page(self.new_bottle_config.get("Path")) def __radio_get_active(self) -> str: # TODO: Remove this ugly zig zag and find a better way to set the environment