Show spinner while remote game libraries are loading

This commit is contained in:
Mathieu Comandon 2020-01-22 20:04:03 -08:00
parent 77a299ba37
commit 7a0ee5b953

View file

@ -28,6 +28,7 @@ class ServiceSyncBox(Gtk.Box):
self.service = service
self.identifier = service.__name__.split(".")[-1]
self.icon_name = service.ICON
self.is_connnecting = False
self.name = service.NAME
self.games = []
self.store = None
@ -86,22 +87,22 @@ class ServiceSyncBox(Gtk.Box):
def get_content_widget(self):
center_alignment = Gtk.Alignment()
center_alignment.set(0.5, 0.5, 0.1, 0.1)
if self.service.ONLINE:
gog_logo = self.get_icon(size=(64, 64))
if self.service.ONLINE and not self.is_connnecting:
service_logo = self.get_icon(size=(64, 64))
gog_label = Gtk.Label(
"Connect to GOG to automatically \ndownload games during installations"
service_label = Gtk.Label(
"Connect to %s to import your library." % self.name
)
gog_label.set_justify(Gtk.Justification.CENTER)
service_label.set_justify(Gtk.Justification.CENTER)
gog_button = Gtk.Button("Connect your account")
gog_button.connect("clicked", self.on_connect_clicked)
service_button = Gtk.Button("Connect your account")
service_button.connect("clicked", self.on_connect_clicked)
gog_box = Gtk.VBox()
gog_box.add(gog_logo)
gog_box.add(gog_label)
gog_box.add(gog_button)
center_alignment.add(gog_box)
service_box = Gtk.VBox()
service_box.add(service_logo)
service_box.add(service_label)
service_box.add(service_button)
center_alignment.add(service_box)
else:
spinner = Gtk.Spinner()
spinner.start()
@ -141,6 +142,7 @@ class ServiceSyncBox(Gtk.Box):
return False
def _connect_button_toggle(self):
self.is_connnecting = False
if self.service.is_connected():
icon_name = "system-log-out-symbolic"
label = "Disconnect"
@ -289,6 +291,9 @@ class ServiceSyncBox(Gtk.Box):
syncer = self.service.SYNCER()
if force_reload:
self.service.SERVICE.wipe_game_cache()
self.is_connnecting = True
self.swap_content(self.get_content_widget())
AsyncCall(syncer.load, self.on_games_loaded)
def on_games_loaded(self, result, _error):