Commit 36ebe467 authored by Jean Felder's avatar Jean Felder Committed by Marinus Schraal

songwidget: Add support for artist and album names

parent 922fcea6
......@@ -67,7 +67,7 @@
</object>
</child>
<child>
<object class="GtkBox" id="box2">
<object class="GtkBox" id="title_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
......@@ -87,6 +87,52 @@
<property name="margin_start">9</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="artist_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="_artist_label">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="valign">start</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">90</property>
<property name="justify">fill</property>
<property name="margin_start">9</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="album_duration_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="_album_label">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="valign">start</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">90</property>
<property name="justify">fill</property>
<property name="margin_start">9</property>
</object>
</child>
<child>
<object class="GtkLabel" id="_duration_label">
<property name="visible">True</property>
......@@ -94,6 +140,7 @@
<property name="no_show_all">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="single_line_mode">True</property>
</object>
</child>
......@@ -126,4 +173,12 @@
</object>
</child>
</template>
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widgets>
<widget name="title_box"/>
<widget name="artist_box"/>
<widget name="album_duration_box"/>
</widgets>
</object>
</interface>
......@@ -246,7 +246,7 @@ class PlaylistsView(BaseView):
def _create_song_widget(self, coresong, playlist):
can_dnd = not playlist.props.is_smart
song_widget = SongWidget(coresong, can_dnd)
song_widget = SongWidget(coresong, can_dnd, True)
song_widget.props.show_song_number = False
song_widget.connect('button-release-event', self._song_activated)
......
......@@ -64,6 +64,8 @@ class SongWidget(Gtk.EventBox):
_playlists = Playlists.get_default()
_album_label = Gtk.Template.Child()
_artist_label = Gtk.Template.Child()
_dnd_eventbox = Gtk.Template.Child()
_select_button = Gtk.Template.Child()
_number_label = Gtk.Template.Child()
......@@ -84,11 +86,12 @@ class SongWidget(Gtk.EventBox):
return '<SongWidget>'
@log
def __init__(self, coresong, can_dnd=False):
def __init__(self, coresong, can_dnd=False, show_artist_and_album=False):
"""Instanciates a SongWidget
:param Corsong coresong: song associated with the widget
:param bool can_dnd: allow drag and drop operations
:param bool show_artist_and_album: display artist and album
"""
super().__init__()
......@@ -110,6 +113,14 @@ class SongWidget(Gtk.EventBox):
time = utils.seconds_to_string(self.props.coresong.props.duration)
self._duration_label.props.label = time
if show_artist_and_album is True:
album = self.props.coresong.props.album
self._album_label.props.label = album
self._album_label.props.visible = True
artist = self.props.coresong.props.artist
self._artist_label.props.label = artist
self._artist_label.props.visible = True
self._select_button.set_visible(False)
self._play_icon.set_from_icon_name(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment