mirror of
https://github.com/lutris/lutris
synced 2024-10-14 19:53:53 +00:00
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:
parent
45d3a53d37
commit
cb55b4ee8e
|
@ -260,7 +260,7 @@ class LutrisWindow(Gtk.ApplicationWindow,
|
||||||
"""Grab the initial focus after the sidebar is initialized - so the view is ready."""
|
"""Grab the initial focus after the sidebar is initialized - so the view is ready."""
|
||||||
self.current_view.grab_focus()
|
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"""
|
"""Handler for drop event"""
|
||||||
file_paths = [unquote(urlparse(uri).path) for uri in data.get_uris()]
|
file_paths = [unquote(urlparse(uri).path) for uri in data.get_uris()]
|
||||||
dialog = ImportGameDialog(file_paths, parent=self)
|
dialog = ImportGameDialog(file_paths, parent=self)
|
||||||
|
@ -599,12 +599,26 @@ class LutrisWindow(Gtk.ApplicationWindow,
|
||||||
self._game_store_generation += 1
|
self._game_store_generation += 1
|
||||||
generation = self._game_store_generation
|
generation = self._game_store_generation
|
||||||
|
|
||||||
def make_game_store():
|
def make_game_store(games):
|
||||||
games = self.get_games_from_filters()
|
|
||||||
game_store = GameStore(service, service_media)
|
game_store = GameStore(service, service_media)
|
||||||
game_store.add_preloaded_games(games, service_id)
|
game_store.add_preloaded_games(games, service_id)
|
||||||
return games, game_store
|
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):
|
def apply_store(result, error):
|
||||||
if generation != self._game_store_generation:
|
if generation != self._game_store_generation:
|
||||||
return # no longer applicable, we got switched again!
|
return # no longer applicable, we got switched again!
|
||||||
|
@ -640,8 +654,8 @@ class LutrisWindow(Gtk.ApplicationWindow,
|
||||||
self.show_empty_label()
|
self.show_empty_label()
|
||||||
|
|
||||||
self.search_timer_id = None
|
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
|
return False
|
||||||
|
|
||||||
def _bind_zoom_adjustment(self):
|
def _bind_zoom_adjustment(self):
|
||||||
|
|
Loading…
Reference in a new issue