[gnome-weather/wip/christopherdavis/app-menu-retirement] Retire app menu



commit 0d775fb3692c981de6eeed28e69fb3978deb3369
Author: Christopher Davis <brainblasted disroot org>
Date:   Mon Nov 5 12:04:02 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 Weather".
    
    Related to https://gitlab.gnome.org/GNOME/gnome-weather/issues/11

 data/app-menu.ui                                   | 28 ----------------------
 ...rg.gnome.Weather.Application.data.gresource.xml |  2 +-
 data/primary-menu.ui                               | 23 ++++++++++++++++++
 data/window.ui                                     | 22 +++++++++++++++++
 src/app/main.js                                    | 11 +--------
 src/app/window.js                                  |  7 ++++++
 6 files changed, 54 insertions(+), 39 deletions(-)
---
diff --git a/data/org.gnome.Weather.Application.data.gresource.xml 
b/data/org.gnome.Weather.Application.data.gresource.xml
index c83a910..e634d6f 100644
--- a/data/org.gnome.Weather.Application.data.gresource.xml
+++ b/data/org.gnome.Weather.Application.data.gresource.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/Weather/Application">
-    <file preprocess="xml-stripblanks">app-menu.ui</file>
     <file preprocess="xml-stripblanks">city.ui</file>
     <file preprocess="xml-stripblanks">places-popover.ui</file>
+    <file preprocess="xml-stripblanks">primary-menu.ui</file>
     <file preprocess="xml-stripblanks">weather-widget.ui</file>
     <file preprocess="xml-stripblanks">window.ui</file>
     <file>application.css</file>
diff --git a/data/primary-menu.ui b/data/primary-menu.ui
new file mode 100644
index 0000000..c6d55f0
--- /dev/null
+++ b/data/primary-menu.ui
@@ -0,0 +1,23 @@
+<interface>
+  <menu id="primary-menu">
+    <submenu>
+      <attribute translatable="yes" name="label">_Temperature Unit</attribute>
+      <item>
+        <attribute translatable="yes" name="label">_Celsius</attribute>
+        <attribute name="action">app.temperature-unit</attribute>
+        <attribute name="target">centigrade</attribute>
+      </item>
+      <item>
+        <attribute translatable="yes" name="label">_Fahrenheit</attribute>
+        <attribute name="action">app.temperature-unit</attribute>
+        <attribute name="target">fahrenheit</attribute>
+      </item>
+    </submenu>
+    <section>
+      <item>
+        <attribute name="action">win.about</attribute>
+        <attribute name="label" translatable="yes">_About Weather</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/data/window.ui b/data/window.ui
index ee93f55..fa2bcc0 100644
--- a/data/window.ui
+++ b/data/window.ui
@@ -5,6 +5,27 @@
     <property name="visible">True</property>
     <property name="vexpand">False</property>
     <property name="show-close-button">True</property>
+    <child>
+      <object class="GtkMenuButton" id="primary-menu-button">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="use-popover">True</property>
+        <property name="valign">center</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage" id="primary-menu-img">
+            <property name="visible">True</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="GtkMenuButton" id="places-button">
         <property name="visible">True</property>
@@ -144,3 +165,4 @@
     </child>
   </object>
 </interface>
+
diff --git a/src/app/main.js b/src/app/main.js
index adf3ac2..733fcd0 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -75,14 +75,6 @@ const Application = new Lang.Class({
         this._showWindowWhenReady(win);
     },
 
-    _initAppMenu: function() {
-        let builder = new Gtk.Builder();
-        builder.add_from_resource('/org/gnome/Weather/Application/app-menu.ui');
-
-        let menu = builder.get_object('app-menu');
-        this.set_app_menu(menu);
-    },
-
     vfunc_startup: function() {
         this.parent();
         // ensure the type before we call to GtkBuilder
@@ -149,10 +141,9 @@ const Application = new Lang.Class({
         });
         this.add_action(temperatureAction);
 
-        this._initAppMenu();
-
         this.add_accelerator("Escape", "win.selection-mode", new GLib.Variant('b', false));
         this.add_accelerator("<Primary>a", "win.select-all", null);
+        this.add_accelerator("<Primary>q", "app.quit", null);
     },
 
     _createWindow: function() {
diff --git a/src/app/window.js b/src/app/window.js
index d4c8739..2b1bc71 100644
--- a/src/app/window.js
+++ b/src/app/window.js
@@ -54,6 +54,7 @@ var MainWindow = new Lang.Class({
 
         let builder = new Gtk.Builder();
         builder.add_from_resource('/org/gnome/Weather/Application/window.ui');
+        builder.add_from_resource('/org/gnome/Weather/Application/primary-menu.ui');
 
         let grid = builder.get_object('main-panel');
         this._header = builder.get_object('header-bar');
@@ -80,6 +81,12 @@ var MainWindow = new Lang.Class({
         let refresh = builder.get_object('refresh-button');
         this._pageWidgets[Page.CITY].push(refresh);
 
+        let primaryMenuModel = builder.get_object('primary-menu');
+        let primaryMenuButton = builder.get_object('primary-menu-button');
+        let popover = Gtk.Popover.new_from_model(primaryMenuButton, primaryMenuModel);
+
+        primaryMenuButton.set_popover(popover);
+
         this._stack = builder.get_object('main-stack');
 
         this._cityView = new City.WeatherView({ hexpand: true,


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