[baobab/wip/vala: 30/45] Let's give up and special case menus.



commit b0755691f139a2f513a27faf03b856922ea2fe04
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Jan 17 19:53:48 2012 +0100

    Let's give up and special case menus.
    
    On new shells just use the new app menu, on other systems use a plain
    menubar.

 data/baobab-menu.ui         |   16 ++++++++++++++++
 src/baobab-application.vala |   15 ++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/data/baobab-menu.ui b/data/baobab-menu.ui
index 8918f1b..fac090c 100644
--- a/data/baobab-menu.ui
+++ b/data/baobab-menu.ui
@@ -16,6 +16,16 @@
     </section>
   </menu>
   <menu id="menubar">
+    <submenu label="_Analizer">
+      <section>
+        <item label="_Scan Home" action="win.scan-home" accel="&lt;Primary&gt;h"/>
+        <item label="Scan _Filesystem" action="win.scan-filesystem" accel="&lt;Primary&gt;f"/>
+        <item label="Scan F_older" action="win.scan-folder" accel="&lt;Primary&gt;o"/>
+      </section>
+      <section>
+        <item label="_Quit" action="app.quit" accel="&lt;Primary&gt;q"/>
+      </section>
+    </submenu>
     <submenu label="_View">
       <section>
         <item label="_Stop" action="win.stop"/>
@@ -33,5 +43,11 @@
         <item label="_Collapse All" action="win.collapse-all"/>
       </section>
     </submenu>
+    <submenu label="_Help">
+      <section>
+        <item label="_Help" action="win.help" accel="F1"/>
+        <item label="_About" action="win.about"/>
+      </section>
+    </submenu>
   </menu>
 </interface>
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index 83256ea..81cb47e 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -53,17 +53,22 @@ namespace Baobab {
 			prefs_settings = new Settings ("org.gnome.baobab.preferences");
 			desktop_settings = new Settings ("org.gnome.desktop.interface");
 
-			// Menus
+			// Menus: in gnome shell we just use the app menu, since the remaining
+			// items are too few to look ok in a menubar and they are not essential
+			var gtk_settings = Gtk.Settings.get_default ();
 			var builder = new Gtk.Builder ();
 			try {
 				builder.add_from_file (Config.PKGDATADIR + "/baobab-menu.ui");
 			} catch (Error e) {
 				error ("loading menu builder file: %s", e.message);
 			}
-			var app_menu = builder.get_object ("appmenu") as MenuModel;
-			var menubar = builder.get_object ("menubar") as MenuModel;
-			set_app_menu (app_menu);
-			set_menubar (menubar);
+			if (gtk_settings.gtk_shell_shows_app_menu) {
+				var app_menu = builder.get_object ("appmenu") as MenuModel;
+				set_app_menu (app_menu);
+			} else {
+				var menubar = builder.get_object ("menubar") as MenuModel;
+				set_menubar (menubar);
+			}
 		}
 
 		protected override bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] ref unowned string[] arguments, out int exit_status) {



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