[gnome-music/wip/mschraal/selectionbarmenubutton-cleanup: 2/3] ui/SelectionBarMenuButton: Simplify with newer GTK4 functions




commit e7907b72f8cf4c38ea17007a091019a9a9c535a0
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Feb 17 14:28:01 2022 +0100

    ui/SelectionBarMenuButton: Simplify with newer GTK4 functions
    
    GtkMenuButton can now show the arrow.

 data/ui/SelectionBarMenuButton.ui | 26 ++++----------------------
 gnomemusic/widgets/headerbar.py   |  6 ++----
 2 files changed, 6 insertions(+), 26 deletions(-)
---
diff --git a/data/ui/SelectionBarMenuButton.ui b/data/ui/SelectionBarMenuButton.ui
index 464311602..6787651bb 100644
--- a/data/ui/SelectionBarMenuButton.ui
+++ b/data/ui/SelectionBarMenuButton.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.10 -->
+  <requires lib="gtk" version="4.4"/>
   <menu id="selection-menu">
     <section>
       <item>
@@ -14,27 +14,9 @@
     </section>
   </menu>
   <template class="SelectionBarMenuButton" parent="GtkMenuButton">
-    <property name="menu-model">selection-menu</property>
+    <property name="always-show-arrow">True</property>
     <property name="focusable">True</property>
-    <child>
-      <object class="GtkBox" id="selection-menu-button-box">
-        <property name="focusable">True</property>
-        <property name="orientation">horizontal</property>
-        <property name="spacing">6</property>
-        <child>
-          <object class="GtkLabel" id="_menu_label">
-            <property name="label" translatable="yes">Click on items to select them</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkImage">
-            <property name="icon-name">pan-down-symbolic</property>
-          </object>
-        </child>
-      </object>
-    </child>
-    <style>
-      <class name="selection-menu"/>
-    </style>
+    <property name="label" translatable="yes">Click on items to select them</property>
+    <property name="menu-model">selection-menu</property>
   </template>
 </interface>
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index 1b890338a..68bca9bb5 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -39,8 +39,6 @@ class SelectionBarMenuButton(Gtk.MenuButton):
 
     __gtype_name__ = "SelectionBarMenuButton"
 
-    _menu_label = Gtk.Template.Child()
-
     def __init__(self):
         super().__init__()
 
@@ -66,9 +64,9 @@ class SelectionBarMenuButton(Gtk.MenuButton):
         if value > 0:
             text = ngettext(
                 "Selected {} song", "Selected {} songs", value).format(value)
-            self._menu_label.props.label = text
+            self.props.label = text
         else:
-            self._menu_label.props.label = _("Click on items to select them")
+            self.props.label = _("Click on items to select them")
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/HeaderBar.ui")


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