comparison frontends/src/primitivus/chat.py @ 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 e2e1e27a3680
comparison
equal deleted inserted replaced
1092:0eefc74c346b 1093:11e2bb20e896
130 130
131 def getMenu(self): 131 def getMenu(self):
132 """Return Menu bar""" 132 """Return Menu bar"""
133 menu = sat_widgets.Menu(self.host.loop) 133 menu = sat_widgets.Menu(self.host.loop)
134 if self.type == 'group': 134 if self.type == 'group':
135 self.host.addMenus(menu, C.MENU_ROOM, {'room_jid': self.target.bare})
135 game = _("Game") 136 game = _("Game")
136 muc = _("MUC")
137 menu.addMenu(game, "Tarot", self.onTarotRequest) 137 menu.addMenu(game, "Tarot", self.onTarotRequest)
138 menu.addMenu(muc, _("Configure room"), self.onConfigureRoom)
139 elif self.type == 'one2one': 138 elif self.type == 'one2one':
139 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target})
140 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) 140 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
141 return menu 141 return menu
142 142
143 def setType(self, type_): 143 def setType(self, type_):
144 QuickChat.setType(self, type_) 144 QuickChat.setType(self, type_)
343 if game_type=="Tarot": 343 if game_type=="Tarot":
344 return self.tarot_wid 344 return self.tarot_wid
345 345
346 #MENU EVENTS# 346 #MENU EVENTS#
347 def onTarotRequest(self, menu): 347 def onTarotRequest(self, menu):
348 # TODO: move this to plugin_misc_tarot with dynamic menu
348 if len(self.occupants) != 4: 349 if len(self.occupants) != 4:
349 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)) 350 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))
350 else: 351 else:
351 self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile) 352 self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile)
352 353
356 def configureError(failure): 357 def configureError(failure):
357 self.host.showPopUp(sat_widgets.Alert(failure.fullname, failure.message, ok_cb=self.host.removePopUp)) 358 self.host.showPopUp(sat_widgets.Alert(failure.fullname, failure.message, ok_cb=self.host.removePopUp))
358 self.host.bridge.configureRoom(self.id, self.host.profile, callback=gotUI, errback=configureError) 359 self.host.bridge.configureRoom(self.id, self.host.profile, callback=gotUI, errback=configureError)
359 360
360 def onSendFileRequest(self, menu): 361 def onSendFileRequest(self, menu):
362 # TODO: move this to core with dynamic menus
361 dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp) 363 dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp)
362 self.host.showPopUp(dialog, 80, 80) 364 self.host.showPopUp(dialog, 80, 80)
363 365
364 #MISC EVENTS# 366 #MISC EVENTS#
365 def onFileSelected(self, filepath): 367 def onFileSelected(self, filepath):