diff frontends/primitivus/chat.py @ 137:227394eb080c

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
author Goffi <goffi@goffi.org>
date Fri, 16 Jul 2010 20:25:06 +0800
parents 5a88ad24ccc0
children 80661755ea8d
line wrap: on
line diff
--- a/frontends/primitivus/chat.py	Fri Jul 16 20:17:01 2010 +0800
+++ b/frontends/primitivus/chat.py	Fri Jul 16 20:25:06 2010 +0800
@@ -121,6 +121,14 @@
 
 
         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 @@
         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)