Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
497:516b06787c1a | 498:60be99de3808 |
---|---|
43 """The main menu bar which is displayed on top of the document""" | 43 """The main menu bar which is displayed on top of the document""" |
44 | 44 |
45 ITEM_TPL = "<img src='media/icons/menu/%s_menu_red.png' />%s" | 45 ITEM_TPL = "<img src='media/icons/menu/%s_menu_red.png' />%s" |
46 | 46 |
47 def __init__(self, host): | 47 def __init__(self, host): |
48 base_menu.GenericMenuBar.__init__(self, host, vertical=False) | 48 styles = {'moved_popup': 'menuLastPopup', 'menu_bar': 'mainMenuBar'} |
49 self.moved_popup_style = 'menuLastPopup' | 49 base_menu.GenericMenuBar.__init__(self, host, vertical=False, styles=styles) |
50 | 50 |
51 @classmethod | 51 @classmethod |
52 def getCategoryHTML(cls, type_, menu_name_i18n): | 52 def getCategoryHTML(cls, type_, menu_name_i18n): |
53 return cls.ITEM_TPL % (type_, menu_name_i18n) | 53 return cls.ITEM_TPL % (type_, menu_name_i18n) |
54 | 54 |
60 self.host = host | 60 self.host = host |
61 SimplePanel.__init__(self) | 61 SimplePanel.__init__(self) |
62 self.setStyleName('menuContainer') | 62 self.setStyleName('menuContainer') |
63 self.menu_bar = MainMenuBar(self.host) | 63 self.menu_bar = MainMenuBar(self.host) |
64 | 64 |
65 def addMenu(self, *args): | 65 def addMenuItem(self, *args): |
66 self.menu_bar.addMenu(*args) | 66 self.menu_bar.addMenuItem(*args) |
67 | |
68 def addCachedMenus(self, *args): | |
69 self.menu_bar.addCachedMenus(*args) | |
70 | 67 |
71 def createMenus(self): | 68 def createMenus(self): |
72 self.addMenu("General", _("General"), _("Web widget"), 'home', MenuCmd(self, "onWebWidget")) | 69 self.addMenuItem("General", [_("General"), _("Web widget")], 'home', MenuCmd(self, "onWebWidget")) |
73 self.addMenu("General", _("General"), _("Disconnect"), 'home', MenuCmd(self, "onDisconnect")) | 70 self.addMenuItem("General", [_("General"), _("Disconnect")], 'home', MenuCmd(self, "onDisconnect")) |
74 self.addMenu("Contacts", _("Contacts"), None, 'social', None) | 71 self.addMenuItem("Contacts", [_("Contacts"), None], 'social', None) |
75 self.addMenu("Groups", _("Groups"), _("Discussion"), 'social', MenuCmd(self, "onJoinRoom")) | 72 self.addMenuItem("Groups", [_("Groups"), _("Discussion")], 'social', MenuCmd(self, "onJoinRoom")) |
76 self.addMenu("Groups", _("Groups"), _("Collective radio"), 'social', MenuCmd(self, "onCollectiveRadio")) | 73 self.addMenuItem("Groups", [_("Groups"), _("Collective radio")], 'social', MenuCmd(self, "onCollectiveRadio")) |
77 self.addMenu("Games", _("Games"), _("Tarot"), 'games', MenuCmd(self, "onTarotGame")) | 74 self.addMenuItem("Games", [_("Games"), _("Tarot")], 'games', MenuCmd(self, "onTarotGame")) |
78 self.addMenu("Games", _("Games"), _("Xiangqi"), 'games', MenuCmd(self, "onXiangqiGame")) | 75 self.addMenuItem("Games", [_("Games"), _("Xiangqi")], 'games', MenuCmd(self, "onXiangqiGame")) |
79 | 76 |
80 # additional menus | 77 # additional menus |
81 self.addCachedMenus(C.MENU_GLOBAL) | 78 self.menu_bar.addCachedMenus(C.MENU_GLOBAL) |
82 | 79 |
83 # menu items that should be displayed after the automatically added ones | 80 # menu items that should be displayed after the automatically added ones |
84 self.addMenu("Contacts", _("Contacts"), _("Manage groups"), 'social', MenuCmd(self, "onManageContactGroups")) | 81 self.addMenuItem("Contacts", [_("Contacts"), _("Manage groups")], 'social', MenuCmd(self, "onManageContactGroups")) |
85 | 82 |
86 self.menu_bar.addSeparator() | 83 self.menu_bar.addSeparator() |
87 | 84 |
88 self.addMenu("Help", _("Help"), _("Social contract"), 'help', MenuCmd(self, "onSocialContract")) | 85 self.addMenuItem("Help", [_("Help"), _("Social contract")], 'help', MenuCmd(self, "onSocialContract")) |
89 self.addMenu("Help", _("Help"), _("About"), 'help', MenuCmd(self, "onAbout")) | 86 self.addMenuItem("Help", [_("Help"), _("About")], 'help', MenuCmd(self, "onAbout")) |
90 self.addMenu("Settings", _("Settings"), _("Account"), 'settings', MenuCmd(self, "onAccount")) | 87 self.addMenuItem("Settings", [_("Settings"), _("Account")], 'settings', MenuCmd(self, "onAccount")) |
91 self.addMenu("Settings", _("Settings"), _("Parameters"), 'settings', MenuCmd(self, "onParameters")) | 88 self.addMenuItem("Settings", [_("Settings"), _("Parameters")], 'settings', MenuCmd(self, "onParameters")) |
92 | 89 |
93 # XXX: temporary, will change when a full profile will be managed in SàT | 90 # XXX: temporary, will change when a full profile will be managed in SàT |
94 self.addMenu("Settings", _("Settings"), _("Upload avatar"), 'settings', MenuCmd(self, "onAvatarUpload")) | 91 self.addMenuItem("Settings", [_("Settings"), _("Upload avatar")], 'settings', MenuCmd(self, "onAvatarUpload")) |
95 | 92 |
96 self.add(self.menu_bar) | 93 self.add(self.menu_bar) |
97 | 94 |
98 # General menu | 95 # General menu |
99 def onWebWidget(self): | 96 def onWebWidget(self): |