Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 1093:11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jun 2014 00:05:20 +0200 |
parents | 6ec513ad92c2 |
children | a096b8579a3c |
comparison
equal
deleted
inserted
replaced
1092:0eefc74c346b | 1093:11e2bb20e896 |
---|---|
280 try: | 280 try: |
281 return self.menu_roller.checkShortcuts(input) | 281 return self.menu_roller.checkShortcuts(input) |
282 except AttributeError: | 282 except AttributeError: |
283 return input | 283 return input |
284 | 284 |
285 def addMenus(self, menu, type_, menu_data=None): | |
286 """Add cached menus to instance | |
287 @param menu: sat_widgets.Menu instance | |
288 @param type_: menu type like is sat.core.sat_main.importMenu | |
289 @param menu_data: data to send with these menus | |
290 | |
291 """ | |
292 menus = self.profiles[self.profile]['menus'].get(type_,[]) | |
293 def add_menu_cb(callback_id): | |
294 self.launchAction(callback_id, menu_data, profile_key = self.profile) | |
295 for id_, path, path_i18n in menus: | |
296 if len(path) != 2: | |
297 raise NotImplementedError("Menu with a path != 2 are not implemented yet") | |
298 menu.addMenu(path_i18n[0], path_i18n[1], lambda dummy,id_=id_: add_menu_cb(id_)) | |
299 | |
300 | |
285 def _buildMenuRoller(self): | 301 def _buildMenuRoller(self): |
286 menu = sat_widgets.Menu(self.loop) | 302 menu = sat_widgets.Menu(self.loop) |
287 general = _("General") | 303 general = _("General") |
288 menu.addMenu(general, _("Connect"), self.onConnectRequest) | 304 menu.addMenu(general, _("Connect"), self.onConnectRequest) |
289 menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest) | 305 menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest) |
294 menu.addMenu(contact) | 310 menu.addMenu(contact) |
295 communication = _("Communication") | 311 communication = _("Communication") |
296 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') | 312 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') |
297 #additionals menus | 313 #additionals menus |
298 #FIXME: do this in a more generic way (in quickapp) | 314 #FIXME: do this in a more generic way (in quickapp) |
299 add_menus = self.bridge.getMenus('', C.NO_SECURITY_LIMIT) | 315 self.addMenus(menu, C.MENU_GLOBAL) |
300 def add_menu_cb(callback_id): | |
301 self.launchAction(callback_id, None, profile_key = self.profile) | |
302 for id_, type_, path, path_i18n in add_menus: | |
303 assert(type_=="NORMAL") #TODO: manage other types | |
304 if len(path) != 2: | |
305 raise NotImplementedError("Menu with a path != 2 are not implemented yet") | |
306 menu.addMenu(path_i18n[0], path_i18n[1], lambda menu,id_=id_: add_menu_cb(id_)) | |
307 | 316 |
308 menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)]) | 317 menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)]) |
309 return menu_roller | 318 return menu_roller |
310 | 319 |
311 def _buildMainWidget(self): | 320 def _buildMainWidget(self): |