[gnome-music/wip/carlosg/tracker3: 23/29] songsview: Add renderer for title, album and artist
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/carlosg/tracker3: 23/29] songsview: Add renderer for title, album and artist
- Date: Thu, 20 Aug 2020 15:06:36 +0000 (UTC)
commit d5f056ea01e88f99b7267ed3239e579b7deaa202
Author: Sumaid Syed <sumaidsyed gmail com>
Date: Sun Aug 4 23:27:18 2019 +0530
songsview: Add renderer for title, album and artist
Add renderers for title album and artist so that even if
those tags are modified in the tag editor they will updated in
songsview.
https://gitlab.gnome.org/GNOME/gnome-music/issues/293
data/ui/SongsView.ui | 6 +++---
gnomemusic/views/songsview.py | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/SongsView.ui b/data/ui/SongsView.ui
index 223df375..50b35b8e 100644
--- a/data/ui/SongsView.ui
+++ b/data/ui/SongsView.ui
@@ -51,7 +51,7 @@
<property name="expand">True</property>
<property name="visible">True</property>
<child>
- <object class="GtkCellRendererText">
+ <object class="GtkCellRendererText" id="_title_cell">
<property name="ellipsize">end</property>
<property name="height">48</property>
<property name="xalign">0</property>
@@ -69,7 +69,7 @@
<property name="expand">True</property>
<property name="visible">True</property>
<child>
- <object class="GtkCellRendererText">
+ <object class="GtkCellRendererText" id="_artist_cell">
<property name="ellipsize">end</property>
<property name="xpad">32</property>
</object>
@@ -84,7 +84,7 @@
<property name="expand">True</property>
<property name="visible">True</property>
<child>
- <object class="GtkCellRendererText">
+ <object class="GtkCellRendererText" id="_album_cell">
<property name="ellipsize">end</property>
<property name="xpad">32</property>
</object>
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index 9eea53c0..0ebc3974 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -29,6 +29,8 @@ 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")
class SongsView(Gtk.ScrolledWindow):
@@ -43,12 +45,18 @@ class SongsView(Gtk.ScrolledWindow):
title = GObject.Property(
type=str, default=_("Songs"), flags=GObject.ParamFlags.READABLE)
+ _album_cell = Gtk.Template.Child()
+ _album_column = Gtk.Template.Child()
+ _artist_cell = Gtk.Template.Child()
+ _artist_column = Gtk.Template.Child()
_duration_renderer = Gtk.Template.Child()
_now_playing_column = Gtk.Template.Child()
_now_playing_cell = Gtk.Template.Child()
_songs_ctrlr = Gtk.Template.Child()
_songs_view = Gtk.Template.Child()
_star_column = Gtk.Template.Child()
+ _title_cell = Gtk.Template.Child()
+ _title_column = Gtk.Template.Child()
def __init__(self, application):
"""Initialize
@@ -82,6 +90,15 @@ class SongsView(Gtk.ScrolledWindow):
self._now_playing_column.set_cell_data_func(
self._now_playing_cell, self._on_list_widget_icon_render, None)
+ self._title_column.set_cell_data_func(
+ self._title_cell, self._on_list_widget_title_render, None)
+
+ self._artist_column.set_cell_data_func(
+ self._artist_cell, self._on_list_widget_artist_render, None)
+
+ self._album_column.set_cell_data_func(
+ self._album_cell, self._on_list_widget_album_render, None)
+
self._star_handler = StarHandlerWidget(self, 6)
self._star_handler.add_star_renderers(self._star_column)
@@ -89,6 +106,30 @@ class SongsView(Gtk.ScrolledWindow):
attrs.insert(Pango.AttrFontFeatures.new("tnum=1"))
self._duration_renderer.props.attributes = attrs
+ def _on_list_widget_album_render(self, coll, cell, model, itr, data):
+ if not model.iter_is_valid(itr):
+ return
+
+ item = model[itr][7]
+ if item:
+ cell.props.text = utils.get_album_title(item.props.media)
+
+ def _on_list_widget_artist_render(self, coll, cell, model, itr, data):
+ if not model.iter_is_valid(itr):
+ return
+
+ item = model[itr][7]
+ if item:
+ cell.props.text = utils.get_artist_name(item.props.media)
+
+ def _on_list_widget_title_render(self, coll, cell, model, itr, data):
+ if not model.iter_is_valid(itr):
+ return
+
+ item = model[itr][7]
+ if item:
+ cell.props.text = utils.get_media_title(item.props.media)
+
def _on_list_widget_icon_render(self, col, cell, model, itr, data):
current_song = self._player.props.current_song
if current_song is None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]