[gnome-music/wip/mschraal/core] songwidget: Use CoreSong as init arg



commit a1833d7a4c79868bf735afb045c26362fdb03ca6
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Jul 1 23:20:12 2019 +0200

    songwidget: Use CoreSong as init arg
    
    This broke artists in SearchView, as it was hackily using SongWidget.

 gnomemusic/views/searchview.py          | 12 ++++++------
 gnomemusic/widgets/disclistboxwidget.py | 10 +++++-----
 gnomemusic/widgets/songwidget.py        | 15 ++++++++-------
 3 files changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 9e1de8ce..f62c4c55 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -104,8 +104,7 @@ class SearchView(BaseView):
         self._box.show_all()
 
     def _create_song_widget(self, coresong):
-        song_widget = SongWidget(coresong.props.media)
-        song_widget.props.coresong = coresong
+        song_widget = SongWidget(coresong)
 
         coresong.bind_property(
             "favorite", song_widget, "favorite",
@@ -148,14 +147,15 @@ class SearchView(BaseView):
 
         return album_widget
 
-    def _create_artist_widget(self, coresong):
+    def _create_artist_widget(self, coreartist):
+        return
         # FIXME: Hacky quick 'artist' widget. Needs its own tile.
-        song_widget = SongWidget(coresong.props.media)
-        song_widget._title_label.props.label = coresong.props.artist
+        song_widget = SongWidget(coreartist)
+        song_widget._title_label.props.label = coreartist.props.artist
         song_widget.props.show_duration = False
         song_widget.props.show_favorite = False
         song_widget.props.show_song_number = False
-        song_widget.coreartist = coresong
+        song_widget.coreartist = coreartist
 
         coresong.bind_property(
             "selected", song_widget, "selected",
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 627bab89..3c9f8f25 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -149,19 +149,19 @@ class DiscBox(Gtk.Box):
 
         self._list_box.foreach(child_select_none)
 
-    def _create_widget(self, song):
-        song_widget = SongWidget(song.props.media)
+    def _create_widget(self, coresong):
+        song_widget = SongWidget(coresong)
         self._songs.append(song_widget)
 
-        song.bind_property(
+        coresong.bind_property(
             "favorite", song_widget, "favorite",
             GObject.BindingFlags.BIDIRECTIONAL
             | GObject.BindingFlags.SYNC_CREATE)
-        song.bind_property(
+        coresong.bind_property(
             "selected", song_widget, "selected",
             GObject.BindingFlags.BIDIRECTIONAL
             | GObject.BindingFlags.SYNC_CREATE)
-        song.bind_property(
+        coresong.bind_property(
             "state", song_widget, "state",
             GObject.BindingFlags.BIDIRECTIONAL
             | GObject.BindingFlags.SYNC_CREATE)
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 0c7bc767..52680e1a 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -84,26 +84,27 @@ class SongWidget(Gtk.EventBox):
         return '<SongWidget>'
 
     @log
-    def __init__(self, media):
+    def __init__(self, coresong):
         super().__init__()
 
-        self._media = media
+        self.props.coresong = coresong
+        self.props.favorite = self.props.coresong.props.favorite
+        self._media = self.props.coresong.props.media
         self._selection_mode = False
         self._state = SongWidget.State.UNPLAYED
 
-        song_number = media.get_track_number()
+        song_number = self.props.coresong.props.track_number
         if song_number == 0:
             song_number = ""
         self._number_label.set_text(str(song_number))
 
-        title = utils.get_media_title(media)
+        title = self.props.coresong.props.title
         self._title_label.set_max_width_chars(50)
         self._title_label.set_text(title)
         self._title_label.props.tooltip_text = title
 
-        time = utils.seconds_to_string(media.get_duration())
-        self._duration_label.set_text(time)
-        # self._star_image.props.favorite = media.get_favourite()
+        time = utils.seconds_to_string(self.props.coresong.props.duration)
+        self._duration_label.props.label = time
 
         self._select_button.set_visible(False)
 


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