Defer the spinner until we have the filtered game list- then we know how big the game store will be.

We can then show the spinner only if there are 'many' games- I find the GameStore construction is by far the slower part of this, so we can avoid UI flicker this way.

The GameStore is built on a thread regardless, to minimize the chance of the infamous Death Waggle bug. It just looks smoother not to flash the spinner.
This commit is contained in:
Daniel Johnson 2024-01-14 13:55:07 -05:00
parent 45d3a53d37
commit cb55b4ee8e

View file

@ -260,7 +260,7 @@ class LutrisWindow(Gtk.ApplicationWindow,
"""Grab the initial focus after the sidebar is initialized - so the view is ready."""
self.current_view.grab_focus()
def on_drag_data_received(self, widget, drag_context, x, y, data, info, time):
def on_drag_data_received(self, _widget, _drag_context, _x, _y, data, _info, _time):
"""Handler for drop event"""
file_paths = [unquote(urlparse(uri).path) for uri in data.get_uris()]
dialog = ImportGameDialog(file_paths, parent=self)
@ -599,12 +599,26 @@ class LutrisWindow(Gtk.ApplicationWindow,
self._game_store_generation += 1
generation = self._game_store_generation
def make_game_store():
games = self.get_games_from_filters()
def make_game_store(games):
game_store = GameStore(service, service_media)
game_store.add_preloaded_games(games, service_id)
return games, game_store
def on_games_ready(games, error):
if generation != self._game_store_generation:
return # no longer applicable, we got switched again!
if error:
raise error # bounce any error against the backstop
# Since get_games_from_filters() seems to be much faster than making a GameStore,
# we defer the spinner to here, when we know how many games we will show. If there
# are "many" we show a spinner while the store is built.
if len(games) > 64:
self.show_spinner()
AsyncCall(make_game_store, apply_store, games)
def apply_store(result, error):
if generation != self._game_store_generation:
return # no longer applicable, we got switched again!
@ -640,8 +654,8 @@ class LutrisWindow(Gtk.ApplicationWindow,
self.show_empty_label()
self.search_timer_id = None
self.show_spinner()
AsyncCall(make_game_store, apply_store)
AsyncCall(self.get_games_from_filters, on_games_ready)
return False
def _bind_zoom_adjustment(self):