[gnome-music/wip/jfelder/gtk4-v3: 71/127] menu




commit d57e3f744196ce312e7a34fe38f808c9f0554564
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Jan 10 16:03:35 2022 +0100

    menu

 data/ui/SongListItem.ui              | 20 ++++++++++++++++++++
 data/ui/SongWidgetMenu.ui            |  2 +-
 gnomemusic/songlistscope.py          | 10 +++++++++-
 gnomemusic/widgets/discbox.py        |  2 +-
 gnomemusic/widgets/songwidgetmenu.py |  2 +-
 5 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/SongListItem.ui b/data/ui/SongListItem.ui
index d8daeb1a3..1781d5082 100644
--- a/data/ui/SongListItem.ui
+++ b/data/ui/SongListItem.ui
@@ -69,6 +69,26 @@
             <!-- </binding> -->
           </object>
         </child>
+        <child>
+          <object class="GtkMenuButton" id="_menu_button">
+            <property name="can-focus">True</property>
+            <style>
+              <class name="flat"/>
+            </style>
+            <binding name="popover">
+              <closure type="GtkPopover" function="menu">
+                <lookup name="item">GtkListItem</lookup>
+              </closure>
+            </binding>
+            <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>
     </property>
   </template>
diff --git a/data/ui/SongWidgetMenu.ui b/data/ui/SongWidgetMenu.ui
index c8ac0cd4b..504d745e2 100644
--- a/data/ui/SongWidgetMenu.ui
+++ b/data/ui/SongWidgetMenu.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="SongWidgetMenu" parent="GtkPopoverMenu">
+  <template class="SongWidgetMenu" parent="GtkPopover">
     <property name="autohide">True</property>
     <property name="position">bottom</property>
     <property name="visible">False</property>
diff --git a/gnomemusic/songlistscope.py b/gnomemusic/songlistscope.py
index 926c01d05..fb4436d02 100644
--- a/gnomemusic/songlistscope.py
+++ b/gnomemusic/songlistscope.py
@@ -28,6 +28,7 @@ import typing
 
 from gi.repository import GObject, Gtk
 
+from gnomemusic.widgets.songwidgetmenu import SongWidgetMenu
 import gnomemusic.utils as utils
 if typing.TYPE_CHECKING:
     from gnomemusic.coresong import CoreSong
@@ -38,8 +39,10 @@ class SongListScope(GObject.GObject, Gtk.BuilderScope):
 
     __gtype_name__ = "SongListScope"
 
-    def __init__(self) -> None:
+    def __init__(self, application, corealbum) -> None:
         super().__init__()
+        self._application = application
+        self._corealbum = corealbum
 
     def do_create_closure(
             self, builder: Gtk.Builder, func_name: str,
@@ -49,3 +52,8 @@ class SongListScope(GObject.GObject, Gtk.BuilderScope):
 
     def song_duration(self, listitem: Gtk.ListItem, coresong: CoreSong) -> str:
         return utils.seconds_to_string(coresong.props.duration)
+
+    def menu(self, listitem: Gtk.ListItem, coresong: CoreSong) -> SongWidgetMenu:
+        menu = SongWidgetMenu(
+            self._application, coresong, self._corealbum)
+        return menu
diff --git a/gnomemusic/widgets/discbox.py b/gnomemusic/widgets/discbox.py
index f1a9957bf..8ec99c465 100644
--- a/gnomemusic/widgets/discbox.py
+++ b/gnomemusic/widgets/discbox.py
@@ -84,7 +84,7 @@ class DiscBox(Gtk.ListBoxRow):
         self._list_view.props.model = multi_selection_model
 
         list_item_factory = Gtk.BuilderListItemFactory(
-            scope=SongListScope(),
+            scope=SongListScope(self._application, self._corealbum),
             resource="/org/gnome/Music/ui/SongListItem.ui")
         self._list_view.props.factory = list_item_factory
 
diff --git a/gnomemusic/widgets/songwidgetmenu.py b/gnomemusic/widgets/songwidgetmenu.py
index 9c4e75b5e..d2e6f35b5 100644
--- a/gnomemusic/widgets/songwidgetmenu.py
+++ b/gnomemusic/widgets/songwidgetmenu.py
@@ -39,7 +39,7 @@ if typing.TYPE_CHECKING:
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/SongWidgetMenu.ui")
-class SongWidgetMenu(Gtk.PopoverMenu):
+class SongWidgetMenu(Gtk.Popover):
 
     __gtype_name__ = "SongWidgetMenu"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]