Mercurial > libervia-web
diff src/browser/sat_browser/menu.py @ 498:60be99de3808
browser_side: menus refactorization + handle levels > 2
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 25 Jul 2014 02:38:30 +0200 |
parents | 5d8632a7bfde |
children | 67a4e8383b70 |
line wrap: on
line diff
--- a/src/browser/sat_browser/menu.py Thu Jul 24 12:20:36 2014 +0200 +++ b/src/browser/sat_browser/menu.py Fri Jul 25 02:38:30 2014 +0200 @@ -45,8 +45,8 @@ ITEM_TPL = "<img src='media/icons/menu/%s_menu_red.png' />%s" def __init__(self, host): - base_menu.GenericMenuBar.__init__(self, host, vertical=False) - self.moved_popup_style = 'menuLastPopup' + styles = {'moved_popup': 'menuLastPopup', 'menu_bar': 'mainMenuBar'} + base_menu.GenericMenuBar.__init__(self, host, vertical=False, styles=styles) @classmethod def getCategoryHTML(cls, type_, menu_name_i18n): @@ -62,36 +62,33 @@ self.setStyleName('menuContainer') self.menu_bar = MainMenuBar(self.host) - def addMenu(self, *args): - self.menu_bar.addMenu(*args) - - def addCachedMenus(self, *args): - self.menu_bar.addCachedMenus(*args) + def addMenuItem(self, *args): + self.menu_bar.addMenuItem(*args) def createMenus(self): - self.addMenu("General", _("General"), _("Web widget"), 'home', MenuCmd(self, "onWebWidget")) - self.addMenu("General", _("General"), _("Disconnect"), 'home', MenuCmd(self, "onDisconnect")) - self.addMenu("Contacts", _("Contacts"), None, 'social', None) - self.addMenu("Groups", _("Groups"), _("Discussion"), 'social', MenuCmd(self, "onJoinRoom")) - self.addMenu("Groups", _("Groups"), _("Collective radio"), 'social', MenuCmd(self, "onCollectiveRadio")) - self.addMenu("Games", _("Games"), _("Tarot"), 'games', MenuCmd(self, "onTarotGame")) - self.addMenu("Games", _("Games"), _("Xiangqi"), 'games', MenuCmd(self, "onXiangqiGame")) + self.addMenuItem("General", [_("General"), _("Web widget")], 'home', MenuCmd(self, "onWebWidget")) + self.addMenuItem("General", [_("General"), _("Disconnect")], 'home', MenuCmd(self, "onDisconnect")) + self.addMenuItem("Contacts", [_("Contacts"), None], 'social', None) + self.addMenuItem("Groups", [_("Groups"), _("Discussion")], 'social', MenuCmd(self, "onJoinRoom")) + self.addMenuItem("Groups", [_("Groups"), _("Collective radio")], 'social', MenuCmd(self, "onCollectiveRadio")) + self.addMenuItem("Games", [_("Games"), _("Tarot")], 'games', MenuCmd(self, "onTarotGame")) + self.addMenuItem("Games", [_("Games"), _("Xiangqi")], 'games', MenuCmd(self, "onXiangqiGame")) # additional menus - self.addCachedMenus(C.MENU_GLOBAL) + self.menu_bar.addCachedMenus(C.MENU_GLOBAL) # menu items that should be displayed after the automatically added ones - self.addMenu("Contacts", _("Contacts"), _("Manage groups"), 'social', MenuCmd(self, "onManageContactGroups")) + self.addMenuItem("Contacts", [_("Contacts"), _("Manage groups")], 'social', MenuCmd(self, "onManageContactGroups")) self.menu_bar.addSeparator() - self.addMenu("Help", _("Help"), _("Social contract"), 'help', MenuCmd(self, "onSocialContract")) - self.addMenu("Help", _("Help"), _("About"), 'help', MenuCmd(self, "onAbout")) - self.addMenu("Settings", _("Settings"), _("Account"), 'settings', MenuCmd(self, "onAccount")) - self.addMenu("Settings", _("Settings"), _("Parameters"), 'settings', MenuCmd(self, "onParameters")) + self.addMenuItem("Help", [_("Help"), _("Social contract")], 'help', MenuCmd(self, "onSocialContract")) + self.addMenuItem("Help", [_("Help"), _("About")], 'help', MenuCmd(self, "onAbout")) + self.addMenuItem("Settings", [_("Settings"), _("Account")], 'settings', MenuCmd(self, "onAccount")) + self.addMenuItem("Settings", [_("Settings"), _("Parameters")], 'settings', MenuCmd(self, "onParameters")) # XXX: temporary, will change when a full profile will be managed in SàT - self.addMenu("Settings", _("Settings"), _("Upload avatar"), 'settings', MenuCmd(self, "onAvatarUpload")) + self.addMenuItem("Settings", [_("Settings"), _("Upload avatar")], 'settings', MenuCmd(self, "onAvatarUpload")) self.add(self.menu_bar)