[gnome-music/wip/jfelder/help-shortcut: 1/2] application: Gather actions creation logic



commit b265721511d8b5a15307c9c2c1f312c67cf60caf
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Jan 2 19:49:08 2020 +0100

    application: Gather actions creation logic
    
    Put the quit action with the other ones.
    
    Also, rename _build_app_menu method to _set_actions. Indeed, the
    _build_app_menu is quite misleading, the menu itself is not built (it
    is handled by AppMenu), only the actions are created.

 gnomemusic/application.py | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index 9415fe1d..cbecfb49 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -130,16 +130,19 @@ class Application(Gtk.Application):
         return self._window
 
     @log
-    def _build_app_menu(self):
+    def _set_actions(self):
         action_entries = [
-            ('about', self._about),
-            ('help', self._help)
+            ('about', self._about, None),
+            ('help', self._help, None),
+            ("quit", self._quit, ("app.quit", ["<Ctrl>Q"]))
         ]
 
-        for action, callback in action_entries:
+        for action, callback, accel in action_entries:
             simple_action = Gio.SimpleAction.new(action, None)
             simple_action.connect('activate', callback)
             self.add_action(simple_action)
+            if accel is not None:
+                self.set_accels_for_action(*accel)
 
     @log
     def _help(self, action, param):
@@ -157,13 +160,7 @@ class Application(Gtk.Application):
     @log
     def do_startup(self):
         Gtk.Application.do_startup(self)
-
-        quit_action = Gio.SimpleAction.new("quit", None)
-        quit_action.connect("activate", self._quit)
-        self.add_action(quit_action)
-        self.set_accels_for_action("app.quit", ["<Ctrl>Q"])
-
-        self._build_app_menu()
+        self._set_actions()
 
     @log
     def _quit(self, action=None, param=None):


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