Skip to content

Commit 7f488a5

Browse files
list: Split update bottles list and show page
This also gets rid of all the weird callbacks with `GLib.idle_add()` and other methods.
1 parent 70cd0ff commit 7f488a5

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

bottles/frontend/views/list.py

+5-22
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(self, window, arg_bottle=None, **kwargs):
155155

156156
# backend signals
157157
SignalManager.connect(
158-
Signals.ManagerLocalBottlesLoaded, self.backend_local_bottle_loaded
158+
Signals.ManagerLocalBottlesLoaded, self.update_bottles_list
159159
)
160160

161161
self.bottle_status.set_icon_name(APP_ID)
@@ -176,7 +176,7 @@ def __filter_bottles(row, terms=None):
176176
text = row.get_title().lower()
177177
return terms.lower() in text
178178

179-
def idle_update_bottles_list(self, show=False):
179+
def update_bottles_list(self, *args) -> None:
180180
self.__bottles = {}
181181
while self.list_bottles.get_first_child():
182182
self.list_bottles.remove(self.list_bottles.get_first_child())
@@ -206,26 +206,9 @@ def idle_update_bottles_list(self, show=False):
206206
self.group_steam.set_visible(True)
207207
self.group_bottles.set_title(_("Your Bottles"))
208208

209-
if (
210-
self.arg_bottle is not None and self.arg_bottle in local_bottles.keys()
211-
) or (show is not None and show in local_bottles.keys()):
212-
_config = None
213-
if self.arg_bottle:
214-
_config = local_bottles[self.arg_bottle]
215-
if show:
216-
_config = local_bottles[show]
217-
if not _config:
218-
raise NotImplementedError("neither 'arg_bottle' nor 'show' are set")
219-
220-
self.window.page_details.view_preferences.update_combo_components()
221-
self.window.show_details_view(config=_config)
222-
self.arg_bottle = None
223-
224-
def backend_local_bottle_loaded(self, _: Result):
225-
self.update_bottles_list()
226-
227-
def update_bottles_list(self, show=False):
228-
GLib.idle_add(self.idle_update_bottles_list, show)
209+
def show_page(self, page: str) -> None:
210+
if config := self.window.manager.local_bottles.get(page):
211+
self.window.show_details_view(config=config)
229212

230213
def disable_bottle(self, config):
231214
self.__bottles[config.Path].disable()

bottles/frontend/views/new.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,8 @@ def send_notification(notification: Gio.Notification) -> None:
243243
# Ask the manager to check for new bottles,
244244
# then update the user bottles' list.
245245
self.manager.check_bottles()
246-
self.window.page_list.update_bottles_list(
247-
show=result.data.get("config").get("Path")
248-
)
246+
self.window.page_list.update_bottles_list()
247+
self.window.page_list.show_page(self.new_bottle_config.get("Path"))
249248

250249
def __radio_get_active(self) -> str:
251250
# TODO: Remove this ugly zig zag and find a better way to set the environment

0 commit comments

Comments
 (0)