Add spinner for fetching SGDB covers

This commit is contained in:
kramo
2023-10-21 13:46:29 +02:00
parent 684f457713
commit 69394d01ec
2 changed files with 16 additions and 3 deletions

View File

@@ -107,6 +107,8 @@ class PreferencesWindow(Adw.PreferencesWindow):
sgdb_prefer_switch = Gtk.Template.Child()
sgdb_animated_switch = Gtk.Template.Child()
sgdb_fetch_button = Gtk.Template.Child()
sgdb_stack = Gtk.Template.Child()
sgdb_spinner = Gtk.Template.Child()
danger_zone_group = Gtk.Template.Child()
reset_action_row = Gtk.Template.Child()
@@ -181,6 +183,9 @@ class PreferencesWindow(Adw.PreferencesWindow):
sgdb_manager = shared.store.managers[SgdbManager]
sgdb_manager.reset_cancellable()
self.sgdb_spinner.set_spinning(True)
self.sgdb_stack.set_visible_child(self.sgdb_spinner)
self.add_toast(download_toast := Adw.Toast.new(_("Downloading covers…")))
def update_cover_callback(manager: SgdbManager) -> None:
@@ -205,6 +210,9 @@ class PreferencesWindow(Adw.PreferencesWindow):
download_toast.dismiss()
self.add_toast(toast)
self.sgdb_spinner.set_spinning(False)
self.sgdb_stack.set_visible_child(self.sgdb_fetch_button)
for game in shared.store:
sgdb_manager.process_game(game, {}, update_cover_callback)

View File

@@ -297,9 +297,14 @@ template $PreferencesWindow : Adw.PreferencesWindow {
subtitle: _("Fetch covers for games already in your library");
sensitive: bind sgdb_switch.active;
Button sgdb_fetch_button {
label: _("Update");
valign: center;
Stack sgdb_stack {
Button sgdb_fetch_button {
label: _("Update");
valign: center;
}
Spinner sgdb_spinner {
valign: center;
}
}
}
}