Add spinner for loading game covers

This commit is contained in:
kramo
2023-04-05 09:57:31 +02:00
parent ee0c07befc
commit 41f7ce3d5f
4 changed files with 40 additions and 19 deletions

View File

@@ -70,15 +70,23 @@ template CartridgesWindow : Adw.ApplicationWindow {
Adw.Clamp {
maximum-size: 200;
Picture overview_cover {
halign: end;
valign: start;
width-request: 200;
height-request: 300;
Overlay {
[overlay]
Spinner overview_spinner {
margin-start: 72;
margin-end: 72;
}
styles [
"card",
]
Picture overview_cover {
halign: end;
valign: start;
width-request: 200;
height-request: 300;
styles [
"card",
]
}
}
}

View File

@@ -71,7 +71,7 @@ def create_details_window(parent_widget, game_id=None):
cover_button_delete_revealer = Gtk.Revealer(
child=cover_button_delete,
transition_type=Gtk.RevealerTransitionType.CROSSFADE,
margin_end=42,
margin_end=40,
)
if not game_id:

View File

@@ -38,6 +38,9 @@ class SGDBSave:
/ f"{game[0]}.tiff"
).is_file()
):
if not self.importer:
self.parent_widget.loading = game[0]
try:
search_result = self.sgdb.search_game(game[1])
except requests.exceptions.RequestException:
@@ -70,20 +73,24 @@ class SGDBSave:
task.return_value(game[0])
def task_done(self, _task, result):
game_id = result.propagate_value()[1]
self.parent_widget.update_games([game_id])
if self.importer:
self.importer.queue -= 1
self.importer.done()
self.importer.sgdb_exception = self.exception
elif self.exception:
create_dialog(
self.parent_widget,
_("Couldn't Connect to SteamGridDB"),
self.exception,
"open_preferences",
_("Preferences"),
).connect("response", self.response)
else:
self.parent_widget.loading = None
if self.exception:
create_dialog(
self.parent_widget,
_("Couldn't Connect to SteamGridDB"),
self.exception,
"open_preferences",
_("Preferences"),
).connect("response", self.response)
game_id = result.propagate_value()[1]
self.parent_widget.update_games([game_id])
def response(self, _widget, response):
if response == "open_preferences":

View File

@@ -48,6 +48,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
overview_box = Gtk.Template.Child()
overview_cover = Gtk.Template.Child()
overview_spinner = Gtk.Template.Child()
overview_title = Gtk.Template.Child()
overview_header_bar_title = Gtk.Template.Child()
overview_launch = Gtk.Template.Child()
@@ -94,6 +95,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
self.toasts = {}
self.pixbufs = {}
self.active_game_id = None
self.loading = None
self.overview.set_measure_overlay(self.overview_box, True)
self.overview.set_clip_overlay(self.overview_box, False)
@@ -244,6 +246,10 @@ class CartridgesWindow(Adw.ApplicationWindow):
return GLib.DateTime.new_from_unix_utc(timestamp).format("%x")
def show_overview(self, _widget, game_id):
loading = game_id == self.loading
self.overview_cover.set_visible(not loading)
self.overview_spinner.set_spinning(loading)
current_game = self.games[game_id]
if current_game.developer: