[gnome-music/wip/mschraal/tageditor-13feb2020: 18/25] coregrilo: Add a callback function to writeback
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/tageditor-13feb2020: 18/25] coregrilo: Add a callback function to writeback
- Date: Thu, 13 Feb 2020 22:14:40 +0000 (UTC)
commit fd344fc896231be919c9e06f82b86f511b4f8f40
Author: Jean Felder <jfelder src gnome org>
Date: Sun Nov 24 15:09:11 2019 +0100
coregrilo: Add a callback function to writeback
gnomemusic/coregrilo.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 75c15527..ec7b3597 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -180,7 +180,7 @@ class CoreGrilo(GObject.GObject):
for wrapper in self._wrappers.values():
wrapper.populate_album_disc_songs(media, discnr, callback)
- def _store_metadata(self, source, media, keys):
+ def _store_metadata(self, source, media, data):
"""Convenience function to store metadata
Wrap the metadata store call in a idle_add compatible form.
@@ -189,6 +189,7 @@ class CoreGrilo(GObject.GObject):
:param list keys: A list of Grilo metadata keys
"""
# FIXME: Doing this async crashes.
+ keys, callback = data
try:
source.store_metadata_sync(
media, keys, Grl.WriteFlags.NORMAL)
@@ -196,18 +197,22 @@ class CoreGrilo(GObject.GObject):
self._log.warning(
"Error {}: {}".format(error.domain, error.message))
+ if callback is not None:
+ callback()
return GLib.SOURCE_REMOVE
- def writeback(self, media, keys):
+ def writeback(self, media, keys, callback=None):
"""Store the values associated with the keys.
:param Grl.Media media: A Grilo media item
:param list keys: A list of Grilo metadata keys
+ :param function callback: callback function
"""
+ data = [keys, callback]
for wrapper in self._wrappers.values():
if media.get_source() == wrapper.source.props.source_id:
GLib.idle_add(
- self._store_metadata, wrapper.props.source, media, keys)
+ self._store_metadata, wrapper.props.source, media, data)
break
def search(self, text):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]