From 4cee13f1a5777d8cc7d3fdcff6854c22eaf8c0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 12 Jun 2020 12:39:17 +0200 Subject: [PATCH] Update primary menu after changing the language issue7955 review303761006 --- tryton/gui/main.py | 67 ++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/tryton/gui/main.py b/tryton/gui/main.py index 8ef399d9fc..9fa77f848f 100644 --- a/tryton/gui/main.py +++ b/tryton/gui/main.py @@ -138,38 +138,9 @@ class Main(Gtk.Application): self.window.set_titlebar(self.header) self.set_title() - menu = Gio.Menu.new() - menu.append(_("Preferences..."), 'app.preferences') - - section = Gio.Menu.new() - toolbar = Gio.Menu.new() - section.append_submenu(_("Toolbar"), toolbar) - toolbar.append(_("Default"), 'app.toolbar::default') - toolbar.append(_("Text and Icons"), 'app.toolbar::both') - toolbar.append(_("Text"), 'app.toolbar::text') - toolbar.append(_("Icons"), 'app.toolbar::icons') - - form = Gio.Menu.new() - section.append_submenu(_("Form"), form) - form.append(_("Save Column Width"), 'app.save-tree-width') - form.append(_("Save Tree State"), 'app.save-tree-state') - form.append(_("Spell Checking"), 'app.spell-checking') - - section.append(_("PDA Mode"), 'app.mode-pda') - section.append(_("Search Limit..."), 'app.search-limit') - section.append(_("Email..."), 'app.email') - section.append(_("Check Version"), 'app.check-version') - - menu.append_section(_("Options"), section) - - section = Gio.Menu.new() - section.append(_("Keyboard Shortcuts..."), 'app.shortcuts') - section.append(_("About..."), 'app.about') - menu.append_section(_("Help"), section) - - primary_menu = Gtk.MenuButton.new() - primary_menu.set_menu_model(menu) - self.header.pack_end(primary_menu) + self.primary_menu = Gtk.MenuButton.new() + self.primary_menu.set_menu_model(self._get_primary_menu()) + self.header.pack_end(self.primary_menu) menu = Gtk.Button.new() menu.set_relief(Gtk.ReliefStyle.NONE) @@ -305,6 +276,37 @@ class Main(Gtk.Application): rpc.logout() self.quit() + def _get_primary_menu(self): + menu = Gio.Menu.new() + menu.append(_("Preferences..."), 'app.preferences') + + section = Gio.Menu.new() + toolbar = Gio.Menu.new() + section.append_submenu(_("Toolbar"), toolbar) + toolbar.append(_("Default"), 'app.toolbar::default') + toolbar.append(_("Text and Icons"), 'app.toolbar::both') + toolbar.append(_("Text"), 'app.toolbar::text') + toolbar.append(_("Icons"), 'app.toolbar::icons') + + form = Gio.Menu.new() + section.append_submenu(_("Form"), form) + form.append(_("Save Column Width"), 'app.save-tree-width') + form.append(_("Save Tree State"), 'app.save-tree-state') + form.append(_("Spell Checking"), 'app.spell-checking') + + section.append(_("PDA Mode"), 'app.mode-pda') + section.append(_("Search Limit..."), 'app.search-limit') + section.append(_("Email..."), 'app.email') + section.append(_("Check Version"), 'app.check-version') + + menu.append_section(_("Options"), section) + + section = Gio.Menu.new() + section.append(_("Keyboard Shortcuts..."), 'app.shortcuts') + section.append(_("About..."), 'app.about') + menu.append_section(_("Help"), section) + return menu + def set_global_search(self): self.global_search_entry = Gtk.Entry.new() self.global_search_entry.set_width_chars(20) @@ -535,6 +537,7 @@ class Main(Gtk.Application): translate.setlang(prefs['language'], prefs.get('locale')) if CONFIG['client.lang'] != prefs['language']: self.favorite_unset() + self.primary_menu.set_menu_model(self._get_primary_menu()) CONFIG['client.lang'] = prefs['language'] # Set placeholder after language is set to get correct translation self.global_search_entry.set_placeholder_text(_("Action"))