[baobab/remove-app-menu] Remove App menu



commit 49902fc7326c77cfa8490035a35a330d85bb3844
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Wed Oct 10 18:53:32 2018 +0200

    Remove App menu
    
    See https://gitlab.gnome.org/GNOME/Initiatives/issues/4

 src/baobab-application.vala |  3 +++
 src/baobab-main-window.ui   | 41 ++++++++++++++++++++++++++++++++---------
 src/baobab-window.vala      | 12 +++++++++---
 src/menus.ui                | 18 ------------------
 4 files changed, 44 insertions(+), 30 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index 05523e7..0b0cf98 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -94,8 +94,11 @@ namespace Baobab {
             }
             Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, 
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
 
+            set_accels_for_action ("win.show-primary-menu", { "F10" });
             set_accels_for_action ("win.scan-folder", { "<Primary>o" });
             set_accels_for_action ("win.reload", { "<Primary>r" });
+            set_accels_for_action ("win.help", { "F1" });
+            set_accels_for_action ("app.quit", { "<Primary>q" });
         }
 
         protected override int handle_local_options (GLib.VariantDict options) {
diff --git a/src/baobab-main-window.ui b/src/baobab-main-window.ui
index 0f88273..41d12db 100644
--- a/src/baobab-main-window.ui
+++ b/src/baobab-main-window.ui
@@ -1,6 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <menu id="primarymenu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Scan Folder…</attribute>
+        <attribute name="action">win.scan-folder</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">win.help</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_About Disk Usage Analyzer</attribute>
+        <attribute name="action">win.about</attribute>
+      </item>
+    </section>
+  </menu>
   <object class="GtkMenu" id="treeview_popup_menu">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -39,15 +57,6 @@
     <style>
       <class name="titlebar"/>
     </style>
-    <child>
-      <object class="GtkButton" id="scan_button">
-        <property name="action_name">win.scan-folder</property>
-        <property name="label" translatable="yes">Scan Folder…</property>
-      </object>
-      <packing>
-        <property name="pack_type">start</property>
-      </packing>
-    </child>
     <child>
       <object class="GtkButton" id="back_button">
         <property name="valign">center</property>
@@ -88,6 +97,20 @@
         <property name="pack_type">end</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkMenuButton" id="menu_button">
+        <property name="valign">center</property>
+        <property name="menu_model">primarymenu</property>
+        <property name="action_name">win.show-primary-menu</property>
+        <property name="direction">none</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+      </object>
+      <packing>
+        <property name="pack_type">end</property>
+      </packing>
+    </child>
   </object>
   <template class="BaobabWindow" parent="GtkApplicationWindow">
     <property name="title" translatable="yes">Disk Usage Analyzer</property>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index cc2df0d..c91bf46 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -29,12 +29,12 @@ namespace Baobab {
         [GtkChild]
         private Gtk.HeaderBar header_bar;
         [GtkChild]
-        private Gtk.Button scan_button;
-        [GtkChild]
         private Gtk.Button back_button;
         [GtkChild]
         private Gtk.Button reload_button;
         [GtkChild]
+        private Gtk.MenuButton menu_button;
+        [GtkChild]
         private Gtk.Stack main_stack;
         [GtkChild]
         private Gtk.Widget home_page;
@@ -82,6 +82,7 @@ namespace Baobab {
         static Gdk.Cursor busy_cursor;
 
         private const GLib.ActionEntry[] action_entries = {
+            { "show-primary-menu", on_show_primary_menu_activate, null, "false", null },
             { "show-home-page", on_show_home_page_activate },
             { "scan-folder", on_scan_folder_activate },
             { "reload", on_reload_activate },
@@ -196,6 +197,11 @@ namespace Baobab {
             show ();
         }
 
+        void on_show_primary_menu_activate (SimpleAction action) {
+            var state = action.get_state ().get_boolean ();
+            action.set_state (new Variant.boolean (!state));
+        }
+
         void on_show_home_page_activate () {
             if (active_location != null && active_location.scanner != null) {
                 active_location.scanner.cancel ();
@@ -493,7 +499,7 @@ namespace Baobab {
         }
 
         void set_ui_state (Gtk.Widget child, bool busy) {
-            scan_button.visible = (child == home_page);
+            menu_button.visible = (child == home_page);
             reload_button.visible = (child == result_page);
             back_button.visible = (child == result_page);
 
diff --git a/src/menus.ui b/src/menus.ui
index 1f9fe9b..d9cbd5d 100644
--- a/src/menus.ui
+++ b/src/menus.ui
@@ -1,24 +1,6 @@
 <?xml version="1.0"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <menu id="app-menu">
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">_Help</attribute>
-        <attribute name="action">win.help</attribute>
-        <attribute name="accel">F1</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_About</attribute>
-        <attribute name="action">win.about</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_Quit</attribute>
-        <attribute name="action">app.quit</attribute>
-        <attribute name="accel">&lt;Primary&gt;q</attribute>
-      </item>
-    </section>
-  </menu>
   <menu id="chartmenu">
     <section>
       <item>


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