[gnome-music/wip/jfelder/playlist-improvements: 25/26] playlistcontrols: Add a play button
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/playlist-improvements: 25/26] playlistcontrols: Add a play button
- Date: Sat, 22 May 2021 22:39:02 +0000 (UTC)
commit e7443860a58735a09b2b7c9a291eb31be128385e
Author: Jean Felder <jfelder src gnome org>
Date: Thu Jan 28 02:58:57 2021 +0100
playlistcontrols: Add a play button
Related: #446
data/ui/PlaylistControls.ui | 59 +++++++++++++++++++++++++---------
gnomemusic/widgets/playlistcontrols.py | 9 +++++-
2 files changed, 52 insertions(+), 16 deletions(-)
---
diff --git a/data/ui/PlaylistControls.ui b/data/ui/PlaylistControls.ui
index cec431c05..52352ffd1 100644
--- a/data/ui/PlaylistControls.ui
+++ b/data/ui/PlaylistControls.ui
@@ -22,6 +22,13 @@
<property name="icon_name">view-more-symbolic</property>
<property name="icon_size">1</property>
</object>
+ <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>
<template class="PlaylistControls" parent="GtkBox">
<property name="orientation">vertical</property>
<property name="visible">True</property>
@@ -100,23 +107,45 @@
</object>
</child>
<child>
- <object class="GtkMenuButton" id="_menubutton">
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="halign">start</property>
- <property name="valign">center</property>
- <property name="focus_on_click">False</property>
- <property name="menu-model">playlistMenu</property>
- <property name="direction">none</property>
- <property name="use_popover">True</property>
- <property name="image">_view_more_image</property>
- <property name="margin-bottom">8</property>
+ <property name="spacing">12</property>
<property name="margin-top">18</property>
- <style>
- <class name="image-button"/>
- <class name="circular"/>
- </style>
+ <property name="margin-bottom">8</property>
+ <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="valign">center</property>
+ <signal name="clicked" handler="_on_play_button_clicked" swapped="no"/>
+ <style>
+ <class name="circular"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="_menubutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="focus_on_click">False</property>
+ <property name="menu-model">playlistMenu</property>
+ <property name="direction">none</property>
+ <property name="use_popover">True</property>
+ <property name="image">_view_more_image</property>
+ <style>
+ <class name="image-button"/>
+ <class name="circular"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/gnomemusic/widgets/playlistcontrols.py b/gnomemusic/widgets/playlistcontrols.py
index 3935edec4..c231bff44 100644
--- a/gnomemusic/widgets/playlistcontrols.py
+++ b/gnomemusic/widgets/playlistcontrols.py
@@ -38,6 +38,7 @@ class PlaylistControls(Gtk.Box):
_name_stack = Gtk.Template.Child()
_name_label = Gtk.Template.Child()
+ _play_button = Gtk.Template.Child()
_rename_controller = Gtk.Template.Child()
_rename_entry = Gtk.Template.Child()
_rename_done_button = Gtk.Template.Child()
@@ -102,6 +103,10 @@ class PlaylistControls(Gtk.Box):
self._window.notifications_popup, self._application,
PlaylistNotification.Type.PLAYLIST, self.props.playlist)
+ @Gtk.Template.Callback()
+ def _on_play_button_clicked(self, button: Gtk.Button) -> None:
+ self._play_action.activate()
+
@Gtk.Template.Callback()
def _on_rename_entry_changed(self, selection):
selection_length = selection.props.text_length
@@ -127,7 +132,9 @@ class PlaylistControls(Gtk.Box):
"{} Song", "{} Songs", self.props.playlist.count).format(
self.props.playlist.count)
- self._play_action.props.enabled = self.props.playlist.props.count > 0
+ not_empty_pl = (self.props.playlist.props.count > 0)
+ self._play_button.props.sensitive = not_empty_pl
+ self._play_action.props.enabled = not_empty_pl
def _enable_rename_playlist(self, menuitem, data=None):
self._name_stack.props.visible_child_name = "renaming_dialog"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]