changeset c2bff499cec9 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=c2bff499cec9
description:
        Retire App Menu usage

        We replace the retired App Menu by a primary menu in the header bar.

        issue9115
        review258901002
diffstat:

 CHANGELOG          |   1 +
 tryton/gui/main.py |  46 ++++++++++++++++++++++------------------------
 2 files changed, 23 insertions(+), 24 deletions(-)

diffs (71 lines):

diff -r 3e26acf942b9 -r c2bff499cec9 CHANGELOG
--- a/CHANGELOG Sat Mar 28 00:13:56 2020 +0100
+++ b/CHANGELOG Sat Mar 28 00:15:03 2020 +0100
@@ -1,3 +1,4 @@
+* Retire App Menu
 * Add support for Python 3.8
 * Manage readonly dates in calendar view
 * Manage editable on calendar view
diff -r 3e26acf942b9 -r c2bff499cec9 tryton/gui/main.py
--- a/tryton/gui/main.py        Sat Mar 28 00:13:56 2020 +0100
+++ b/tryton/gui/main.py        Sat Mar 28 00:15:03 2020 +0100
@@ -119,6 +119,25 @@
         self.add_action(action)
         self.set_accels_for_action('app.quit', ['<Primary>q'])
 
+    def do_activate(self):
+        if self.window:
+            self.window.present()
+            return
+
+        self.window = Gtk.ApplicationWindow(application=self, title="Tryton")
+        self.window.set_default_size(960, 720)
+        self.window.maximize()
+        self.window.set_position(Gtk.WindowPosition.CENTER)
+        self.window.set_resizable(True)
+        self.window.set_icon(TRYTON_ICON)
+        self.window.connect("destroy", self.on_quit)
+        self.window.connect("delete_event", self.on_quit)
+
+        self.header = Gtk.HeaderBar.new()
+        self.header.set_show_close_button(True)
+        self.window.set_titlebar(self.header)
+        self.set_title()
+
         menu = Gio.Menu.new()
         menu.append(_("Preferences..."), 'app.preferences')
 
@@ -148,30 +167,9 @@
         section.append(_("About..."), 'app.about')
         menu.append_section(_("Help"), section)
 
-        section = Gio.Menu.new()
-        section.append(_("Quit"), 'app.quit')
-        menu.append_section(None, section)
-
-        self.set_app_menu(menu)
-
-    def do_activate(self):
-        if self.window:
-            self.window.present()
-            return
-
-        self.window = Gtk.ApplicationWindow(application=self, title="Tryton")
-        self.window.set_default_size(960, 720)
-        self.window.maximize()
-        self.window.set_position(Gtk.WindowPosition.CENTER)
-        self.window.set_resizable(True)
-        self.window.set_icon(TRYTON_ICON)
-        self.window.connect("destroy", self.on_quit)
-        self.window.connect("delete_event", self.on_quit)
-
-        self.header = Gtk.HeaderBar.new()
-        self.header.set_show_close_button(True)
-        self.window.set_titlebar(self.header)
-        self.set_title()
+        primary_menu = Gtk.MenuButton.new()
+        primary_menu.set_menu_model(menu)
+        self.header.pack_end(primary_menu)
 
         menu = Gtk.Button.new()
         menu.set_relief(Gtk.ReliefStyle.NONE)

Reply via email to