[gnome-music] Replace AppMenu with Primary Menu



commit 9aa739a911d9afdc5d993287626b03dd69a43bca
Author: Christopher Davis <brainblasted disroot org>
Date:   Sat Sep 29 10:17:33 2018 -0400

    Replace AppMenu with Primary Menu
    
    Retires the AppMenu in favor of a Primary Menu,
    as a part of the ongoing initiative:
    https://gitlab.gnome.org/GNOME/Initiatives/issues/4
    
    The new AppMenu has it's own source file and .ui file,
    the .ui file replacing app-menu.ui. "About" has been
    renamed to "About Music".
    
    Related to https://gitlab.gnome.org/GNOME/gnome-music/issues/229

 data/org.gnome.Music.gresource.xml |  2 +-
 data/ui/AppMenu.ui                 | 62 ++++++++++++++++++++++++++++++++++++++
 data/ui/HeaderBar.ui               | 23 ++++++++++++++
 data/ui/app-menu.ui                | 24 ---------------
 gnomemusic/widgets/appmenu.py      | 38 +++++++++++++++++++++++
 gnomemusic/widgets/headerbar.py    |  9 ++++++
 po/POTFILES.in                     |  2 +-
 7 files changed, 134 insertions(+), 26 deletions(-)
---
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index cd2e7d0d..200159ae 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/Music">
-    <file alias="gtk/menus.ui" preprocess="xml-stripblanks">ui/app-menu.ui</file>
     <file alias="gtk/help-overlay.ui" preprocess="xml-stripblanks">ui/help-overlay.ui</file>
     <file>org.gnome.Music.css</file>
     <file>icons/initial-state.png</file>
     <file preprocess="xml-stripblanks">ui/AboutDialog.ui</file>
     <file preprocess="xml-stripblanks">ui/AlbumCover.ui</file>
     <file preprocess="xml-stripblanks">ui/AlbumWidget.ui</file>
+    <file preprocess="xml-stripblanks">ui/AppMenu.ui</file>
     <file preprocess="xml-stripblanks">ui/ArtistAlbumWidget.ui</file>
     <file preprocess="xml-stripblanks">ui/ArtistAlbumsWidget.ui</file>
     <file preprocess="xml-stripblanks">ui/DiscBox.ui</file>
diff --git a/data/ui/AppMenu.ui b/data/ui/AppMenu.ui
new file mode 100644
index 00000000..adaf3ce7
--- /dev/null
+++ b/data/ui/AppMenu.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <template class="AppMenu" parent="GtkPopoverMenu">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="margin">6</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkModelButton" id="_keyboard_shortcuts_model_button">
+            <property name="halign">fill</property>
+            <property name="hexpand">False</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="action_name">win.show-help-overlay</property>
+            <property name="text" translatable="yes">_Keyboard Shortcuts</property>
+          </object>
+          <packing>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkModelButton" id="_help_model_button">
+            <property name="halign">fill</property>
+            <property name="hexpand">False</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="action_name">app.help</property>
+            <property name="text" translatable="yes">_Help</property>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkModelButton" id="_about_model_button">
+            <property name="halign">fill</property>
+            <property name="hexpand">False</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="action_name">app.about</property>
+            <property name="text" translatable="yes">_About Music</property>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="submenu">main</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </template>
+</interface>
diff --git a/data/ui/HeaderBar.ui b/data/ui/HeaderBar.ui
index d2dd7926..94476a4c 100644
--- a/data/ui/HeaderBar.ui
+++ b/data/ui/HeaderBar.ui
@@ -4,6 +4,29 @@
   <template class="HeaderBar" parent="GtkHeaderBar">
     <property name="visible">True</property>
     <property name="vexpand">False</property>
+    <child>
+      <object class="GtkMenuButton" id="_menu_button">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="valign">center</property>
+        <property name="sensitive">True</property>
+        <property name="tooltip_text" translatable="yes">Menu</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage" id="_menu_button_image">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="icon-name">open-menu-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack_type">end</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkToggleButton" id="_search_button">
         <property name="visible">True</property>
diff --git a/gnomemusic/widgets/appmenu.py b/gnomemusic/widgets/appmenu.py
new file mode 100644
index 00000000..a66d9299
--- /dev/null
+++ b/gnomemusic/widgets/appmenu.py
@@ -0,0 +1,38 @@
+# Copyright 2018 The GNOME Music developers
+#
+# GNOME Music is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GNOME Music is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with GNOME Music; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# The GNOME Music authors hereby grant permission for non-GPL compatible
+# GStreamer plugins to be used and distributed together with GStreamer
+# and GNOME Music.  This permission is above and beyond the permissions
+# granted by the GPL license by which GNOME Music is covered.  If you
+# modify this code, you may extend this exception to your version of the
+# code, but you are not obligated to do so.  If you do not wish to do so,
+# delete this exception statement from your version.
+
+from gi.repository import Gtk
+
+
+@Gtk.Template(resource_path="/org/gnome/Music/ui/AppMenu.ui")
+class AppMenu(Gtk.PopoverMenu):
+    """AppMenu shown from the HeaderBar within the main view"""
+
+    __gtype_name__ = "AppMenu"
+
+    def __repr__(self):
+        return "<AppMenu>"
+
+    def __init__(self):
+        super().__init__()
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index fd66782f..5db06299 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -28,6 +28,7 @@ from gettext import gettext as _, ngettext
 from gi.repository import GObject, Gtk
 
 from gnomemusic import log
+from gnomemusic.widgets.appmenu import AppMenu
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/SelectionBarMenuButton.ui")
@@ -95,6 +96,7 @@ class HeaderBar(Gtk.HeaderBar):
     _select_button = Gtk.Template.Child()
     _cancel_button = Gtk.Template.Child()
     _back_button = Gtk.Template.Child()
+    _menu_button = Gtk.Template.Child()
 
     search_mode_enabled = GObject.Property(type=bool, default=False)
     selected_items_count = GObject.Property(type=int, default=0, minimum=0)
@@ -116,6 +118,8 @@ class HeaderBar(Gtk.HeaderBar):
 
         self._selection_menu = SelectionBarMenuButton()
 
+        self._menu_button.set_popover(AppMenu())
+
         self.bind_property(
             "selection-mode", self, "show-close-button",
             GObject.BindingFlags.INVERT_BOOLEAN |
@@ -226,6 +230,11 @@ class HeaderBar(Gtk.HeaderBar):
             and self.props.state != HeaderBar.State.EMPTY
         )
 
+        self._menu_button.props.visible = (
+            not self.props.selection_mode
+            and self.props.state == HeaderBar.State.MAIN
+        )
+
     @log
     def _on_selection_mode_allowed_changed(self, widget, data):
         if self.props.selection_mode_allowed:
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 24ec7293..15aaaf14 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -5,7 +5,7 @@ data/org.gnome.Music.desktop.in.in
 data/org.gnome.Music.gschema.xml
 data/ui/AboutDialog.ui.in
 data/ui/AlbumWidget.ui
-data/ui/app-menu.ui
+data/ui/AppMenu.ui
 data/ui/HeaderBar.ui
 data/ui/help-overlay.ui
 data/ui/PlayerToolbar.ui


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