[gnome-music/wip/jfelder/new-album-design-v3: 7/8] albumwidget: Add a play button
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/new-album-design-v3: 7/8] albumwidget: Add a play button
- Date: Tue, 3 Aug 2021 22:49:42 +0000 (UTC)
commit dc48d0eea3510d94a994f1e226ee6491f16025f0
Author: Jean Felder <jfelder src gnome org>
Date: Fri Jul 30 15:08:49 2021 +0200
albumwidget: Add a play button
Closes: https://gitlab.gnome.org/GNOME/gnome-music/-/issues/433
data/ui/AlbumWidget.ui | 24 ++++++++++++++++++++++++
gnomemusic/widgets/albumwidget.py | 28 +++++++++++++++++++---------
po/POTFILES.in | 1 +
3 files changed, 44 insertions(+), 9 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 6c3d62d4a..0886cd53f 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -98,6 +98,23 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkButton" id="_play_button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">_play_image</property>
+ <property name="always_show_image">True</property>
+ <property name="tooltip-text" translatable="yes">Play</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="margin-top">12</property>
+ <signal name="clicked" handler="_on_play_button_clicked" swapped="no"/>
+ <style>
+ <class name="circular"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -115,4 +132,11 @@
</object>
</child>
</template>
+ <object class="GtkImage" id="_play_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin-top">1</property>
+ <property name="icon_name">media-playback-start-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
</interface>
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 26f02a0ee..cd5962cf3 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -36,6 +36,7 @@ from gnomemusic.widgets.disclistboxwidget import DiscListBox # noqa: F401
if typing.TYPE_CHECKING:
from gnomemusic.application import Application
from gnomemusic.coredisc import CoreDisc
+ from gnomemusic.coresong import CoreSong
from gnomemusic.widgets.songwidget import SongWidget
@@ -53,6 +54,7 @@ class AlbumWidget(Gtk.ScrolledWindow):
_composer_label = Gtk.Template.Child()
_art_stack = Gtk.Template.Child()
_disc_list_box = Gtk.Template.Child()
+ _play_button = Gtk.Template.Child()
_released_label = Gtk.Template.Child()
_title_label = Gtk.Template.Child()
@@ -141,6 +143,9 @@ class AlbumWidget(Gtk.ScrolledWindow):
discbox = self._disc_list_box.get_row_at_index(i)
discbox.props.show_disc_label = True
+ empty_album = (n_items == 0)
+ self._play_button.props.sensitive = not empty_album
+
def _set_composer_label(self, corealbum: CoreAlbum) -> None:
composer = corealbum.props.composer
show = False
@@ -165,23 +170,24 @@ class AlbumWidget(Gtk.ScrolledWindow):
"{}, {} minute", "{}, {} minutes", mins).format(year, mins)
self._released_label.props.label = release_info_label
- def _song_activated(
- self, widget: Gtk.Widget, song_widget: SongWidget) -> None:
- if self.props.selection_mode:
- song_widget.props.selected = not song_widget.props.selected
- return
-
- signal_id = None
+ def _play(self, coresong: Optional[CoreSong] = None) -> None:
+ signal_id = 0
def _on_playlist_loaded(klass, playlist_type):
- self._player.play(song_widget.props.coresong)
+ self._player.play(coresong)
self._coremodel.disconnect(signal_id)
signal_id = self._coremodel.connect(
"playlist-loaded", _on_playlist_loaded)
self._coremodel.props.active_core_object = self._corealbum
- return
+ def _song_activated(
+ self, widget: Gtk.Widget, song_widget: SongWidget) -> None:
+ if self.props.selection_mode:
+ song_widget.props.selected = not song_widget.props.selected
+ return
+
+ self._play(song_widget.props.coresong)
def select_all(self) -> None:
self._disc_list_box.select_all()
@@ -203,3 +209,7 @@ class AlbumWidget(Gtk.ScrolledWindow):
:rtype: CoreAlbum
"""
return self._corealbum
+
+ @Gtk.Template.Callback()
+ def _on_play_button_clicked(self, button: Gtk.Button) -> None:
+ self._play()
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 084766770..c88c5b2cc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/org.gnome.Music.appdata.xml.in.in
data/org.gnome.Music.desktop.in.in
data/org.gnome.Music.gschema.xml
data/ui/AboutDialog.ui.in
+data/ui/AlbumWidget.ui
data/ui/AppMenu.ui
data/ui/HeaderBar.ui
data/ui/help-overlay.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]