[gnome-music/wip/mschraal/core: 53/92] albumwidget2: Add back duration calculation



commit 6f22d6f79fff9618c419069ebfce0bbdd0ce7241
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu May 9 22:33:32 2019 +0200

    albumwidget2: Add back duration calculation

 gnomemusic/coresong.py             | 1 +
 gnomemusic/widgets/albumwidget2.py | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index a0ef381c..4807f35a 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -56,6 +56,7 @@ class CoreSong(GObject.GObject):
         self.props.album = utils.get_album_title(media)
         self.props.album_disc_number = media.get_album_disc_number()
         self.props.artist = utils.get_artist_name(media)
+        self.props.duration = media.get_duration()
         self.props.favorite = media.get_favourite()
         self.props.play_count = media.get_play_count()
         self.props.title = utils.get_media_title(media)
diff --git a/gnomemusic/widgets/albumwidget2.py b/gnomemusic/widgets/albumwidget2.py
index 3043ceb0..1319a6fc 100644
--- a/gnomemusic/widgets/albumwidget2.py
+++ b/gnomemusic/widgets/albumwidget2.py
@@ -105,6 +105,8 @@ class AlbumWidget2(Gtk.EventBox):
 
         song.connect("notify::selected", self._on_selection_changed)
 
+        self._set_duration_label()
+
         return song_widget
 
     @log
@@ -123,7 +125,11 @@ class AlbumWidget2(Gtk.EventBox):
 
     @log
     def _set_duration_label(self):
-        mins = (self._duration // 60) + 1
+        total_duration = 0
+        for song in self._model:
+            total_duration += song.props.duration
+
+        mins = (total_duration // 60) + 1
         self._running_info_label.props.label = ngettext(
             "{} minute", "{} minutes", mins).format(mins)
 


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