[gnome-music/wip/jfelder/gtk4-v3] songsview: Add duration field



commit 788225fff626418ee8fe5bb5eabead2b6e4fa22e
Author: Marinus Schraal <mschraal gnome org>
Date:   Fri Feb 11 23:05:06 2022 +0100

    songsview: Add duration field

 data/ui/SongListItem.ui       | 11 +++++++++++
 gnomemusic/views/songsview.py |  7 ++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/SongListItem.ui b/data/ui/SongListItem.ui
index 42b32b03e..40ff3d65c 100644
--- a/data/ui/SongListItem.ui
+++ b/data/ui/SongListItem.ui
@@ -33,6 +33,17 @@
           </child>
       </object>
     </child>
+    <child>
+      <object class="GtkLabel" id="_duration_label">
+        <property name="halign">start</property>
+        <property name="single_line_mode">True</property>
+        <property name="width_chars">5</property>
+        <property name="xalign">1.0</property>
+        <attributes>
+          <attribute name="font-features" value="tnum=1"/>
+        </attributes>
+      </object>
+    </child>
     <child>
       <object class="GtkBox" id="_star_box">
         <property name="focusable">0</property>
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index acee0d06e..bc4010361 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -28,6 +28,7 @@ from gi.repository import Adw, GObject, Gdk, Gtk
 from gnomemusic.coresong import CoreSong
 from gnomemusic.utils import SongStateIcon
 from gnomemusic.widgets.starhandlerwidget import StarHandlerWidget
+import gnomemusic.utils as utils
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/SongsView.ui")
@@ -111,7 +112,8 @@ class SongsView(Gtk.Box):
 
         check = list_row.get_first_child()
         info_box = check.get_next_sibling()
-        star_image = info_box.get_next_sibling().get_first_child()
+        duration_label = info_box.get_next_sibling()
+        star_image = duration_label.get_next_sibling().get_first_child()
         title_label = info_box.get_first_child()
         album_label = title_label.get_next_sibling()
         artist_label = album_label.get_next_sibling()
@@ -154,6 +156,9 @@ class SongsView(Gtk.Box):
         coresong.bind_property(
             "favorite", star_image, "favorite")
 
+        duration_label.props.label = utils.seconds_to_string(
+            coresong.props.duration)
+
         list_item.bind_property(
             "selected", coresong, "selected",
             GObject.BindingFlags.SYNC_CREATE)


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