[gnome-music/wip/mschraal/core: 7/93] Add CoreSong



commit b4b9ff2466b7c4d6f5fa28b53d6ed614008b5d4d
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed May 8 16:35:08 2019 +0200

    Add CoreSong

 gnomemusic/coregrilo.py |  9 ++++++---
 gnomemusic/coresong.py  | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index c7b1ed50..003a5acc 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -2,6 +2,8 @@ import gi
 gi.require_version('Grl', '0.3')
 from gi.repository import Grl, GObject
 
+from gnomemusic.coresong import CoreSong
+
 
 class CoreGrilo(GObject.GObject):
 
@@ -89,7 +91,8 @@ class CoreGrilo(GObject.GObject):
             print("NO MEDIA", source, op_id, media, error)
             return
 
-        self._model.append(media)
-        self._table[media.get_id()] = media
+        song = CoreSong(media)
+        self._model.append(song)
+        self._table[media.get_id()] = song
 
-        # print(media.get_url(), media.get_title())
+        # print(song.props.title, song.props.url)
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
new file mode 100644
index 00000000..244a93e4
--- /dev/null
+++ b/gnomemusic/coresong.py
@@ -0,0 +1,20 @@
+import gi
+gi.require_version('Grl', '0.3')
+from gi.repository import Grl, GObject
+
+import gnomemusic.utils as utils
+
+class CoreSong(GObject.GObject):
+    """Exposes a Grl.Media with relevant data as properties
+    """
+
+    url = GObject.Property(type=str)
+    title = GObject.Property(type=str)
+
+    def __init__(self, media):
+        super().__init__()
+
+        self._media = media
+
+        self.props.url = self._media.get_url()
+        self.props.title = utils.get_media_title(self._media)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]