[gnome-mahjongg: 1/2] Remove AppMenu



commit 76d8385e35dfaed1ad6978f75a9577742791b0f6
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Oct 10 11:23:51 2018 +1300

    Remove AppMenu
    
    Also remove legacy Unity workarounds
    
    https://gitlab.gnome.org/GNOME/Initiatives/wikis/App-Menu-Retirement

 po/POTFILES.in                   |  1 -
 src/gnome-mahjongg.gresource.xml |  6 ----
 src/gnome-mahjongg.vala          | 76 ++++++++++++----------------------------
 src/meson.build                  |  6 +---
 4 files changed, 23 insertions(+), 66 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1deb74e..01810d9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,5 +8,4 @@ src/game.vala
 src/game-view.vala
 src/gnome-mahjongg.vala
 src/map.vala
-src/menu.ui
 src/score-dialog.vala
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index a46f1cb..8beee8d 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -62,20 +62,16 @@ public class Mahjongg : Gtk.Application
         base.startup ();
 
         add_action_entries (action_entries, this);
+        set_accels_for_action ("app.new-game", {"<Primary>n"});
         set_accels_for_action ("app.pause", {"Pause"});
         set_accels_for_action ("app.hint", {"<Primary>h"});
         set_accels_for_action ("app.undo", {"<Primary>z"});
         set_accels_for_action ("app.redo", {"<Primary><Shift>z"});
+        set_accels_for_action ("app.help", {"F1"});
+        set_accels_for_action ("app.quit", {"<Primary>q", "<Primary>w"});
 
         settings = new Settings ("org.gnome.mahjongg");
 
-        var builder = new Gtk.Builder ();
-        try {
-            builder.add_from_resource ("/org/gnome/mahjongg/ui/menu.ui");
-        } catch (Error e) {
-            error ("loading menu builder file: %s", e.message);
-        }
-
         load_maps ();
 
         history = new History (Path.build_filename (Environment.get_user_data_dir (), "gnome-mahjongg", 
"history"));
@@ -141,46 +137,31 @@ public class Mahjongg : Gtk.Application
         status_box.halign = Gtk.Align.CENTER;
         title_box.pack_start (status_box, false, false, 0);
 
-        bool shell_shows_menubar;
-        Gtk.Settings.get_default ().get ("gtk-shell-shows-menubar", out shell_shows_menubar);
-
-        if (!shell_shows_menubar)
-        {
-            var app_menu = builder.get_object ("appmenu") as MenuModel;
-            set_app_menu (app_menu);
-        }
-        else
-        {
-            var menu = new Menu ();
-            var mahjongg_menu = new Menu ();
-            menu.append_submenu (_("_Mahjongg"), mahjongg_menu);
-            mahjongg_menu.append (_("_New Game"), "app.new-game");
-            mahjongg_menu.append (_("_Restart Game"), "app.restart-game");
-            mahjongg_menu.append (_("_Scores"), "app.scores");
-            mahjongg_menu.append (_("_Preferences"), "app.preferences");
-            mahjongg_menu.append (_("_Quit"), "app.quit");
-            var help_menu = new Menu ();
-            menu.append_submenu (_("_Help"), help_menu);
-            help_menu.append (_("_Contents"), "app.help");
-            help_menu.append (_("_About"), "app.about");
-            set_menubar (menu);
-        }
+        var menu = new Menu ();
+        var mahjongg_menu = new Menu ();
+        menu.append_section (null, mahjongg_menu);
+        mahjongg_menu.append (_("_New Game"), "app.new-game");
+        mahjongg_menu.append (_("_Restart Game"), "app.restart-game");
+        mahjongg_menu.append (_("_Scores"), "app.scores");
+        mahjongg_menu.append (_("_Preferences"), "app.preferences");
+        var help_menu = new Menu ();
+        menu.append_section (null, help_menu);
+        help_menu.append (_("_Help"), "app.help");
+        help_menu.append (_("_About Mahjongg"), "app.about");
+
+        var menu_button = new Gtk.MenuButton ();
+        menu_button.valign = Gtk.Align.CENTER;
+        menu_button.set_menu_model (menu);
+        menu_button.set_image (new Gtk.Image.from_icon_name ("open-menu-symbolic", Gtk.IconSize.BUTTON));
 
         var header_bar = new Gtk.HeaderBar ();
         header_bar.set_custom_title (title_box);
+        header_bar.set_show_close_button (true);
         header_bar.pack_start (hbox);
+        header_bar.pack_end (menu_button);
         header_bar.pack_end (hint_button);
         header_bar.pack_end (pause_button);
-
-        if (!is_desktop ("Unity"))
-        {
-            header_bar.set_show_close_button (true);
-            window.set_titlebar (header_bar);
-        }
-        else
-        {
-            vbox.pack_start (header_bar, false, false, 0);
-        }
+        window.set_titlebar (header_bar);
 
         vbox.pack_start (game_view, true, true, 0);
 
@@ -198,19 +179,6 @@ public class Mahjongg : Gtk.Application
         tick_cb ();
     }
 
-    private bool is_desktop (string name)
-    {
-        var desktop_name_list = Environment.get_variable ("XDG_CURRENT_DESKTOP");
-        if (desktop_name_list == null)
-            return false;
-
-        foreach (var n in desktop_name_list.split (":"))
-            if (n == name)
-                return true;
-
-        return false;
-    }
-
     private void size_allocate_cb (Gtk.Allocation allocation)
     {
         if (is_maximized || is_tiled)
diff --git a/src/meson.build b/src/meson.build
index 4282ad7..3ca963a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,7 +1,3 @@
-resources = gnome.compile_resources ('resources', 'gnome-mahjongg.gresource.xml',
-                                     source_dir: '.',
-                                     c_name: 'resources')
-
 gnome_mahjongg = executable ('gnome-mahjongg',
                              [ 'config.vapi',
                                'game.vala',
@@ -9,7 +5,7 @@ gnome_mahjongg = executable ('gnome-mahjongg',
                                'gnome-mahjongg.vala',
                                'history.vala',
                                'map.vala',                               
-                               'score-dialog.vala'] + resources,
+                               'score-dialog.vala'],
                              dependencies: [ glib_dep,
                                              gtk_dep,
                                              librsvg_dep ],


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