[gnome-music/wip/jfelder/songwidget-menu-v3: 1/5] songwidget: Introduce an optional menu button
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/songwidget-menu-v3: 1/5] songwidget: Introduce an optional menu button
- Date: Thu, 29 Jul 2021 15:23:05 +0000 (UTC)
commit 62f54f24bad6c4a409a726e72727b5b74871fa62
Author: Jean Felder <jfelder src gnome org>
Date: Wed Nov 11 21:22:18 2020 +0100
songwidget: Introduce an optional menu button
This button is only visible when an associated menu is set. This menu
will be introduced in the next commit.
data/ui/SongWidget.ui | 19 +++++++++++++++++++
gnomemusic/widgets/songwidget.py | 22 ++++++++++++++++++++++
2 files changed, 41 insertions(+)
---
diff --git a/data/ui/SongWidget.ui b/data/ui/SongWidget.ui
index 1bb14f17a..f3a1a16b3 100644
--- a/data/ui/SongWidget.ui
+++ b/data/ui/SongWidget.ui
@@ -72,6 +72,7 @@
<property name="margin-bottom">1</property>
<property name="margin-top">1</property>
<property name="hexpand">True</property>
+ <property name="valign">center</property>
<child>
<object class="DzlBoldingLabel" id="_title_label">
<property name="visible">True</property>
@@ -95,6 +96,7 @@
<property name="margin-bottom">1</property>
<property name="margin-top">1</property>
<property name="hexpand">True</property>
+ <property name="valign">center</property>
<child>
<object class="GtkLabel" id="_artist_label">
<property name="visible">True</property>
@@ -118,6 +120,7 @@
<property name="margin-bottom">1</property>
<property name="margin-top">1</property>
<property name="hexpand">True</property>
+ <property name="valign">center</property>
<child>
<object class="GtkLabel" id="_album_label">
<property name="visible">False</property>
@@ -184,6 +187,22 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkMenuButton" id="_menu_button">
+ <property name="visible">False</property>
+ <property name="can-focus">True</property>
+ <style>
+ <class name="flat"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">view-more-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 31e67849a..3649a12db 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -23,6 +23,7 @@
# delete this exception statement from your version.
from enum import IntEnum
+from typing import Optional
import gi
gi.require_version('Dazzle', '1.0')
@@ -65,6 +66,7 @@ class SongWidget(Gtk.ListBoxRow):
_artist_label = Gtk.Template.Child()
_controller_motion = Gtk.Template.Child()
_dnd_eventbox = Gtk.Template.Child()
+ _menu_button = Gtk.Template.Child()
_select_button = Gtk.Template.Child()
_number_label = Gtk.Template.Child()
_title_label = Gtk.Template.Child()
@@ -317,3 +319,23 @@ class SongWidget(Gtk.ListBoxRow):
new_nr = ""
self._number_label.props.label = str(new_nr)
+
+ @GObject.Property(type=Gtk.Popover, default=None)
+ def menu(self) -> Optional[Gtk.Popover]:
+ """Get the song menu.
+
+ If no menu is set, the menu button is not displayed.
+
+ :returns: song menu
+ :rtype: Gtk.PopoverMenu
+ """
+ return self._menu_button.props.popover
+
+ @menu.setter # type: ignore
+ def menu(self, menu: Optional[Gtk.PopoverMenu]) -> None:
+ """Set song menu.
+
+ :param Gtk.PopoverMenu menu: new song menu
+ """
+ self._menu_button.props.popover = menu
+ self._menu_button.props.visible = (menu is not None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]