Primitivus: menu are now managed and fully working

- new class MenuRoller for manager different menus
- Chat window now create is own menu
- some menu items added for general/contact menus
This commit is contained in:
Goffi 2010-07-16 20:25:06 +08:00
commit d6ae995bd6

View file

@ -121,6 +121,14 @@ class Chat(urwid.WidgetWrap, QuickChat):
return super(Chat, self).keypress(size, key)
def getMenu(self):
"""Return Menu bar"""
menu = custom_widgets.Menu(self.host.loop)
if self.type == 'group':
game = _("Game")
menu.addMenu(game, "Tarot", self.onTarotRequest)
return menu
def setType(self, type):
QuickChat.setType(self, type)
@ -201,3 +209,11 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.content.append(ChatText(self, timestamp or None, my_jid, from_jid, msg))
self.text_list.set_focus(len(self.content)-1)
self.host.redraw()
#MENU EVENTS#
def onTarotRequest(self, menu):
if len(self.occupants) != 4:
self.host.debug()
self.host.showPopUp(custom_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:
self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile)