Add spinner for loading game covers
This commit is contained in:
@@ -70,15 +70,23 @@ template CartridgesWindow : Adw.ApplicationWindow {
|
|||||||
|
|
||||||
Adw.Clamp {
|
Adw.Clamp {
|
||||||
maximum-size: 200;
|
maximum-size: 200;
|
||||||
Picture overview_cover {
|
Overlay {
|
||||||
halign: end;
|
[overlay]
|
||||||
valign: start;
|
Spinner overview_spinner {
|
||||||
width-request: 200;
|
margin-start: 72;
|
||||||
height-request: 300;
|
margin-end: 72;
|
||||||
|
}
|
||||||
|
|
||||||
styles [
|
Picture overview_cover {
|
||||||
"card",
|
halign: end;
|
||||||
]
|
valign: start;
|
||||||
|
width-request: 200;
|
||||||
|
height-request: 300;
|
||||||
|
|
||||||
|
styles [
|
||||||
|
"card",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ def create_details_window(parent_widget, game_id=None):
|
|||||||
cover_button_delete_revealer = Gtk.Revealer(
|
cover_button_delete_revealer = Gtk.Revealer(
|
||||||
child=cover_button_delete,
|
child=cover_button_delete,
|
||||||
transition_type=Gtk.RevealerTransitionType.CROSSFADE,
|
transition_type=Gtk.RevealerTransitionType.CROSSFADE,
|
||||||
margin_end=42,
|
margin_end=40,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not game_id:
|
if not game_id:
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ class SGDBSave:
|
|||||||
/ f"{game[0]}.tiff"
|
/ f"{game[0]}.tiff"
|
||||||
).is_file()
|
).is_file()
|
||||||
):
|
):
|
||||||
|
if not self.importer:
|
||||||
|
self.parent_widget.loading = game[0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
search_result = self.sgdb.search_game(game[1])
|
search_result = self.sgdb.search_game(game[1])
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
@@ -70,20 +73,24 @@ class SGDBSave:
|
|||||||
task.return_value(game[0])
|
task.return_value(game[0])
|
||||||
|
|
||||||
def task_done(self, _task, result):
|
def task_done(self, _task, result):
|
||||||
game_id = result.propagate_value()[1]
|
|
||||||
self.parent_widget.update_games([game_id])
|
|
||||||
if self.importer:
|
if self.importer:
|
||||||
self.importer.queue -= 1
|
self.importer.queue -= 1
|
||||||
self.importer.done()
|
self.importer.done()
|
||||||
self.importer.sgdb_exception = self.exception
|
self.importer.sgdb_exception = self.exception
|
||||||
elif self.exception:
|
else:
|
||||||
create_dialog(
|
self.parent_widget.loading = None
|
||||||
self.parent_widget,
|
|
||||||
_("Couldn't Connect to SteamGridDB"),
|
if self.exception:
|
||||||
self.exception,
|
create_dialog(
|
||||||
"open_preferences",
|
self.parent_widget,
|
||||||
_("Preferences"),
|
_("Couldn't Connect to SteamGridDB"),
|
||||||
).connect("response", self.response)
|
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):
|
def response(self, _widget, response):
|
||||||
if response == "open_preferences":
|
if response == "open_preferences":
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
|
|
||||||
overview_box = Gtk.Template.Child()
|
overview_box = Gtk.Template.Child()
|
||||||
overview_cover = Gtk.Template.Child()
|
overview_cover = Gtk.Template.Child()
|
||||||
|
overview_spinner = Gtk.Template.Child()
|
||||||
overview_title = Gtk.Template.Child()
|
overview_title = Gtk.Template.Child()
|
||||||
overview_header_bar_title = Gtk.Template.Child()
|
overview_header_bar_title = Gtk.Template.Child()
|
||||||
overview_launch = Gtk.Template.Child()
|
overview_launch = Gtk.Template.Child()
|
||||||
@@ -94,6 +95,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
self.toasts = {}
|
self.toasts = {}
|
||||||
self.pixbufs = {}
|
self.pixbufs = {}
|
||||||
self.active_game_id = None
|
self.active_game_id = None
|
||||||
|
self.loading = None
|
||||||
|
|
||||||
self.overview.set_measure_overlay(self.overview_box, True)
|
self.overview.set_measure_overlay(self.overview_box, True)
|
||||||
self.overview.set_clip_overlay(self.overview_box, False)
|
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")
|
return GLib.DateTime.new_from_unix_utc(timestamp).format("%x")
|
||||||
|
|
||||||
def show_overview(self, _widget, game_id):
|
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]
|
current_game = self.games[game_id]
|
||||||
|
|
||||||
if current_game.developer:
|
if current_game.developer:
|
||||||
|
|||||||
Reference in New Issue
Block a user