[gnome-builder/ebassi/python-templates: 1/3] templates: Add actions in the application's init




commit 727c1b0d1ecfc23b636b69a1ff61841d65b987df
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Feb 28 20:07:54 2022 +0000

    templates: Add actions in the application's init
    
    Do in Python what we do in other languages.

 src/plugins/meson-templates/resources/src/main-gtk4.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/meson-templates/resources/src/main-gtk4.py 
b/src/plugins/meson-templates/resources/src/main-gtk4.py
index cce5dab7a..cb4c62099 100755
--- a/src/plugins/meson-templates/resources/src/main-gtk4.py
+++ b/src/plugins/meson-templates/resources/src/main-gtk4.py
@@ -19,6 +19,9 @@ class Application({{if is_adwaita}}Adw{{else}}Gtk{{end}}.Application):
     def __init__(self):
         super().__init__(application_id='{{appid}}',
                          flags=Gio.ApplicationFlags.FLAGS_NONE)
+        self.create_action('quit', self.quit, ['<primary>q'])
+        self.create_action('about', self.on_about_action)
+        self.create_action('preferences', self.on_preferences_action)
 
     def do_activate(self):
         """Called when the application is activated.
@@ -29,9 +32,6 @@ class Application({{if is_adwaita}}Adw{{else}}Gtk{{end}}.Application):
         win = self.props.active_window
         if not win:
             win = {{PreFix}}Window(application=self)
-        self.create_action('quit', self.quit, ['<primary>q'])
-        self.create_action('about', self.on_about_action)
-        self.create_action('preferences', self.on_preferences_action)
         win.present()
 
     def on_about_action(self, widget, _):


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