[latexila] Set app menu only if the desktop prefers one



commit c8c4ad80589273262f797ec59cbd4ff5aa369ae3
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Apr 21 12:35:56 2017 +0200

    Set app menu only if the desktop prefers one
    
    I'm back to Xfce again, and now the app menu is shown as a second
    menubar on top of the main menubar. I really don't like that, the app
    menu is anyway useless, the main menubar contains everything.

 src/latexila_app.vala |   14 ++++++++++++++
 src/ui/menus.ui       |    3 ++-
 2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/latexila_app.vala b/src/latexila_app.vala
index 34b4a10..fe52017 100644
--- a/src/latexila_app.vala
+++ b/src/latexila_app.vala
@@ -117,7 +117,20 @@ public class LatexilaApp : Gtk.Application
     private void startup_cb ()
     {
         hold ();
+
         add_action_entries (_app_actions, this);
+
+        GLib.MenuModel manual_app_menu = get_menu_by_id ("manual-app-menu");
+        if (manual_app_menu == null)
+            warning ("manual-app-menu not available.");
+
+        // The menubar contains everything, so we don't need the fallback app
+        // menu on desktops that don't support app menus (e.g. on Xfce).
+        if (prefers_app_menu ())
+        {
+            set_app_menu (manual_app_menu);
+        }
+
         set_application_icons ();
         Latexila.utils_register_icons ();
         StockIcons.register_stock_icons ();
@@ -125,6 +138,7 @@ public class LatexilaApp : Gtk.Application
         AppSettings.get_default ();
         support_backward_search ();
         Gtk.AccelMap.load (get_accel_filename ());
+
         release ();
     }
 
diff --git a/src/ui/menus.ui b/src/ui/menus.ui
index df6af64..b324f17 100644
--- a/src/ui/menus.ui
+++ b/src/ui/menus.ui
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <interface>
-  <menu id="app-menu">
+  <!-- The app menu is set manually if needed. -->
+  <menu id="manual-app-menu">
     <section>
       <item>
         <attribute name="label" translatable="yes">_New Window</attribute>


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