[gnome-music/wip/mschraal/artisttile-delayed-retrieval-fix: 1/2] artistart: Make file exists check async
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/artisttile-delayed-retrieval-fix: 1/2] artistart: Make file exists check async
- Date: Sun, 15 Aug 2021 17:51:46 +0000 (UTC)
commit 86a5376274874d4c84d485ed7647c442120f3034
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Aug 15 12:05:36 2021 +0200
artistart: Make file exists check async
gnomemusic/artistart.py | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/artistart.py b/gnomemusic/artistart.py
index 7461bd823..ba6b5ff39 100644
--- a/gnomemusic/artistart.py
+++ b/gnomemusic/artistart.py
@@ -24,7 +24,7 @@
import gi
gi.require_version("MediaArt", "2.0")
-from gi.repository import GObject, MediaArt
+from gi.repository import GLib, GObject, Gio, MediaArt
class ArtistArt(GObject.GObject):
@@ -40,21 +40,27 @@ class ArtistArt(GObject.GObject):
super().__init__()
self._coreartist = coreartist
+ self._coregrilo = application.props.coregrilo
self._artist = self._coreartist.props.artist
- if self._in_cache():
- return
-
- application.props.coregrilo.get_artist_art(self._coreartist)
+ self._in_cache()
def _in_cache(self):
- success, thumb_file = MediaArt.get_file(
- self._artist, None, "artist")
- if (not success
- or not thumb_file.query_exists()):
+ success, thumb_file = MediaArt.get_file(self._artist, None, "artist")
+
+ if not success:
self._coreartist.props.thumbnail = "generic"
- return False
+ return
+
+ def on_query_info_finished(obj, res):
+ try:
+ result = obj.query_info_finish(res)
+ except GLib.Error as error:
+ self._coregrilo.get_artist_art(self._coreartist)
+ return
- self._coreartist.props.thumbnail = thumb_file.get_uri()
+ self._coreartist.props.thumbnail = thumb_file.get_uri()
- return True
+ thumb_file.query_info_async(
+ Gio.FILE_ATTRIBUTE_STANDARD_TYPE, Gio.FileQueryInfoFlags.NONE,
+ GLib.PRIORITY_LOW, None, on_query_info_finished)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]