[gnome-usage/wip/christopherdavis/remove-appmenu] Retire app menu



commit 7f4d12ffcf45c32a16c206f96d817eae3debbe3f
Author: Christopher Davis <brainblasted disroot org>
Date:   Sun Nov 4 19:30:39 2018 -0500

    Retire app menu
    
    As per https://gitlab.gnome.org/GNOME/Initiatives/issues/4,
    the application menu is being retired.
    
    The application menu has been moved into a primary menu within
    Usage, with "About" being changed to "About Usage".
    
    Related to https://gitlab.gnome.org/GNOME/gnome-usage/issues/52

 data/meson.build                   |  1 +
 data/org.gnome.Usage.gresource.xml |  1 +
 data/ui/header-bar.ui              | 18 +++++++++++++++++-
 data/ui/primary-menu.ui            | 20 ++++++++++++++++++++
 org.gnome.Usage.json               |  4 ++--
 src/application.vala               | 15 +--------------
 src/header-bar.vala                |  6 ++++++
 src/meson.build                    |  1 +
 src/primary-menu.vala              | 33 +++++++++++++++++++++++++++++++++
 9 files changed, 82 insertions(+), 17 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index b8fa0c6..a4400e5 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,5 +1,6 @@
 resource_data = files(
   'interface/adwaita.css',
+  'ui/primary-menu.ui',
   'ui/header-bar.ui',
   'ui/memory-speedometer.ui',
   'ui/no-results-found-view.ui',
diff --git a/data/org.gnome.Usage.gresource.xml b/data/org.gnome.Usage.gresource.xml
index ab09a2b..de8eece 100644
--- a/data/org.gnome.Usage.gresource.xml
+++ b/data/org.gnome.Usage.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
     <gresource prefix="/org/gnome/Usage">
         <file compressed="true">interface/adwaita.css</file>
+        <file preprocess="xml-stripblanks">ui/primary-menu.ui</file>
         <file preprocess="xml-stripblanks">ui/header-bar.ui</file>
         <file preprocess="xml-stripblanks">ui/memory-speedometer.ui</file>
         <file preprocess="xml-stripblanks">ui/no-results-found-view.ui</file>
diff --git a/data/ui/header-bar.ui b/data/ui/header-bar.ui
index c264278..b086595 100644
--- a/data/ui/header-bar.ui
+++ b/data/ui/header-bar.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.9 -->
+  <!-- interface-requires gtk+ 3.12 -->
 
   <template class="UsageHeaderBar" parent="GtkHeaderBar">
     <property name="visible">False</property>
@@ -30,6 +30,21 @@
       </object>
     </child>
 
+    <child>
+      <object class="GtkMenuButton" id="primary_menu_button">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">open-menu-symbolic</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+
     <child>
       <object class="GtkButton" id="storage_rescan_button">
         <property name="visible">False</property>
@@ -96,3 +111,4 @@
     </child>
   </template>
 </interface>
+
diff --git a/data/ui/primary-menu.ui b/data/ui/primary-menu.ui
new file mode 100644
index 0000000..751c45b
--- /dev/null
+++ b/data/ui/primary-menu.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.16 -->
+  <template class="UsagePrimaryMenu" parent="GtkPopover">
+    <child>
+      <object class="GtkBox" id="primary_menu_container">
+        <property name="visible">True</property>
+        <property name="margin">6</property>
+        <child>
+          <object class="GtkModelButton" id="about_usage_button">
+            <property name="visible">True</property>
+            <property name="action-name">app.about</property>
+            <property name="text" translatable="yes">_About Usage</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
+
diff --git a/org.gnome.Usage.json b/org.gnome.Usage.json
index e5a07a7..a97219a 100644
--- a/org.gnome.Usage.json
+++ b/org.gnome.Usage.json
@@ -1,7 +1,7 @@
 {
     "app-id": "org.gnome.Usage",
     "runtime": "org.gnome.Platform",
-    "runtime-version": "master",
+    "runtime-version": "3.30",
     "sdk": "org.gnome.Sdk",
     "command": "gnome-usage",
     "tags": ["devel"],
@@ -47,4 +47,4 @@
             ]
         }
     ]
-}
+}
\ No newline at end of file
diff --git a/src/application.vala b/src/application.vala
index 404bbdd..4afeb35 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -50,21 +50,8 @@ namespace Usage
 
             window = new Window(this);
 
-            // Create menu
-            GLib.Menu menu_preferences = new GLib.Menu();
-            GLib.Menu menu_common = new GLib.Menu();
-            var item = new GLib.MenuItem (_("About"), "app.about");
-            menu_common.append_item(item);
+            set_accels_for_action("app.quit", {"<Primary>q"});
 
-            item = new GLib.MenuItem (_("Quit"), "app.quit");
-            item.set_attribute("accel", "s", "<Primary>q");
-            menu_common.append_item(item);
-
-            GLib.Menu menu = new GLib.Menu();
-            menu.append_section(null, menu_preferences);
-            menu.append_section(null, menu_common);
-
-            set_app_menu(menu);
             window.show_all();
         }
 
diff --git a/src/header-bar.vala b/src/header-bar.vala
index 1374098..17d8f39 100644
--- a/src/header-bar.vala
+++ b/src/header-bar.vala
@@ -49,9 +49,13 @@ namespace Usage
         [GtkChild]
         private Gtk.Button storage_cancel_button;
 
+        [GtkChild]
+        private Gtk.MenuButton primary_menu_button;
+
            private Gtk.MenuButton? storage_selection_menu;
            private string title_text = "";
            private HeaderBarMode mode;
+           private Usage.PrimaryMenu menu;
 
            const GLib.ActionEntry[] select_action_entries = {
            { "select-all", select_all },
@@ -61,7 +65,9 @@ namespace Usage
            public HeaderBar(Gtk.Stack stack)
            {
                mode = HeaderBarMode.PERFORMANCE;
+               menu = new Usage.PrimaryMenu();
             stack_switcher.set_stack(stack);
+            this.primary_menu_button.set_popover(menu);
 
             set_mode(HeaderBarMode.PERFORMANCE);
            }
diff --git a/src/meson.build b/src/meson.build
index 693445e..8484bc5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -22,6 +22,7 @@ vala_sources = [
   'no-results-found-view.vala',
   'performance-view.vala',
   'pie-chart.vala',
+  'primary-menu.vala',
   'process-list-box.vala',
   'process-row.vala',
   'process.vala',
diff --git a/src/primary-menu.vala b/src/primary-menu.vala
new file mode 100644
index 0000000..f18f250
--- /dev/null
+++ b/src/primary-menu.vala
@@ -0,0 +1,33 @@
+/* primary-menu.vala
+ *
+ * Copyright 2018 Christopher Davis <brainblasted disroot org>
+ *
+ * This program 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.
+ *
+ * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+using Gtk;
+
+namespace Usage {
+    [GtkTemplate (ui="/org/gnome/Usage/ui/primary-menu.ui")]
+    public class PrimaryMenu : Gtk.Popover {
+        [GtkChild]
+        private Gtk.ModelButton about_usage_button;
+
+        public PrimaryMenu() {
+
+        }
+    }
+}


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