core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed

This commit is contained in:
Goffi 2014-06-26 00:05:20 +02:00
commit 08be0324a6

View file

@ -132,11 +132,11 @@ class Chat(urwid.WidgetWrap, QuickChat):
"""Return Menu bar"""
menu = sat_widgets.Menu(self.host.loop)
if self.type == 'group':
self.host.addMenus(menu, C.MENU_ROOM, {'room_jid': self.target.bare})
game = _("Game")
muc = _("MUC")
menu.addMenu(game, "Tarot", self.onTarotRequest)
menu.addMenu(muc, _("Configure room"), self.onConfigureRoom)
elif self.type == 'one2one':
self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target})
menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
return menu
@ -345,6 +345,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
#MENU EVENTS#
def onTarotRequest(self, menu):
# TODO: move this to plugin_misc_tarot with dynamic menu
if len(self.occupants) != 4:
self.host.showPopUp(sat_widgets.Alert(_("Can't start game"), _("You need to be exactly 4 peoples in the room to start a Tarot game"), ok_cb=self.host.removePopUp))
else:
@ -358,6 +359,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.host.bridge.configureRoom(self.id, self.host.profile, callback=gotUI, errback=configureError)
def onSendFileRequest(self, menu):
# TODO: move this to core with dynamic menus
dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp)
self.host.showPopUp(dialog, 80, 80)