[gnome-music/wip/mschraal/tracker-unstink-removals] add/removals in Tracker smells
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/tracker-unstink-removals] add/removals in Tracker smells
- Date: Thu, 10 Oct 2019 13:01:38 +0000 (UTC)
commit af0ec7823761228b5e8f20e050a059a17bd6d3fa
Author: Marinus Schraal <mschraal gnome org>
Date: Thu Oct 10 14:05:19 2019 +0200
add/removals in Tracker smells
gnomemusic/corealbum.py | 6 +++++
gnomemusic/coredisc.py | 8 ++++--
gnomemusic/grilowrappers/grltrackerwrapper.py | 36 +++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index 70bce7fc..26896e8e 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -112,3 +112,9 @@ class CoreAlbum(GObject.GObject):
# well.
if self._selected is True:
self.props.model.items_changed(0, 0, 0)
+
+ def update2(self):
+ print("update of", self.props.title, "by", self.props.artist)
+
+ for coredisc in self.props.model:
+ coredisc.update2()
diff --git a/gnomemusic/coredisc.py b/gnomemusic/coredisc.py
index ea4939ad..42e16425 100644
--- a/gnomemusic/coredisc.py
+++ b/gnomemusic/coredisc.py
@@ -57,8 +57,8 @@ class CoreDisc(GObject.GObject):
self._model.set_sort_func(
self._wrap_sort_func(self._disc_sort))
- self._coremodel.props.songs.connect(
- "items-changed", self._on_core_changed)
+ # self._coremodel.props.songs.connect(
+ # "items-changed", self._on_core_changed)
self._model.connect("items-changed", self._on_disc_changed)
self._get_album_disc(
@@ -70,6 +70,10 @@ class CoreDisc(GObject.GObject):
self._get_album_disc(
self.props.media, self.props.disc_nr, self._filter_model)
+ def update2(self):
+ self._get_album_disc(
+ self.props.media, self.props.disc_nr, self._filter_model)
+
def _on_disc_changed(self, model, position, removed, added):
with self.freeze_notify():
duration = 0
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index fe5d5e63..ac0021b4 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -325,12 +325,48 @@ class GrlTrackerWrapper(GObject.GObject):
else:
self._hash[media.get_id()].update(media)
+ self._check_album_change2(media.get_id())
+
options = self._fast_options.copy()
self._source.query(
self._song_media_query(media_ids), self.METADATA_KEYS,
options, _update_changed_media)
+ def _check_album_change2(self, song_id):
+ query = """
+ SELECT
+ tracker:id(?album) AS ?id
+ WHERE {
+ ?album a nmm:MusicAlbum .
+ ?song a nmm:MusicPiece ;
+ nmm:musicAlbum ?album .
+ FILTER ( tracker:id(?song) = %(song_id)s )
+ }
+ """.replace('\n', ' ').strip() % {
+ 'song_id': song_id
+ }
+
+ def _changed_album_id_cb(source, op_id, media, user_data, error):
+ if error:
+ print("ERROR", error)
+ return
+
+ if not media:
+ return
+
+ corealbum = self._album_ids.get(media.get_id(), None)
+
+ if corealbum is not None:
+ corealbum.update2()
+ else:
+ print("corealbum none", media.get_id())
+
+ options = self._fast_options.copy()
+
+ self._source.query(
+ query, [Grl.METADATA_KEY_ID], options, _changed_album_id_cb)
+
def _initial_songs_fill(self, source):
self._window.notifications_popup.push_loading()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]