comparison src/browser/sat_browser/menu.py @ 627:30180021f203 frontends_multi_profiles

browser_side: fixes MUC menus
author souliane <souliane@mailoo.org>
date Sun, 22 Feb 2015 21:56:40 +0100
parents 1c0d5a87c554
children 6d3142b782c3
comparison
equal deleted inserted replaced
626:ba2555c29c84 627:30180021f203
20 import pyjd # this is dummy in pyjs 20 import pyjd # this is dummy in pyjs
21 from sat.core.log import getLogger 21 from sat.core.log import getLogger
22 log = getLogger(__name__) 22 log = getLogger(__name__)
23 23
24 from sat.core.i18n import _ 24 from sat.core.i18n import _
25
26 from sat_frontends.tools import jid
27 25
28 from pyjamas.ui.SimplePanel import SimplePanel 26 from pyjamas.ui.SimplePanel import SimplePanel
29 from pyjamas.ui.HTML import HTML 27 from pyjamas.ui.HTML import HTML
30 from pyjamas.ui.Frame import Frame 28 from pyjamas.ui.Frame import Frame
31 from pyjamas import Window 29 from pyjamas import Window
37 import panels 35 import panels
38 import dialog 36 import dialog
39 import contact_group 37 import contact_group
40 import base_menu 38 import base_menu
41 from base_menu import MenuCmd 39 from base_menu import MenuCmd
40
41
42 unicode = str # FIXME: pyjamas workaround
42 43
43 44
44 class MainMenuBar(base_menu.GenericMenuBar): 45 class MainMenuBar(base_menu.GenericMenuBar):
45 """The main menu bar which is displayed on top of the document""" 46 """The main menu bar which is displayed on top of the document"""
46 47
147 #Group menu 148 #Group menu
148 def onJoinRoom(self): 149 def onJoinRoom(self):
149 150
150 def invite(room_jid, contacts): 151 def invite(room_jid, contacts):
151 for contact in contacts: 152 for contact in contacts:
152 self.host.bridge.call('inviteMUC', None, contact, room_jid) 153 self.host.bridge.call('inviteMUC', None, unicode(contact), unicode(room_jid))
153 154
154 def join(room_jid, contacts): 155 def join(room_jid, contacts):
155 if self.host.whoami: 156 if self.host.whoami:
156 nick = self.host.whoami.node 157 nick = self.host.whoami.node
157 if room_jid not in [room.bare for room in self.host.room_list]: 158 contact_list = self.host.contact_list
158 self.host.bridge.call('joinMUC', lambda room_jid: invite(room_jid, contacts), room_jid, nick) 159 if room_jid not in contact_list.getSpecials(C.CONTACT_SPECIAL_GROUP):
160 self.host.bridge.call('joinMUC', lambda room_jid: invite(room_jid, contacts), unicode(room_jid), nick)
159 else: 161 else:
160 self.host.displayWidget(chat.Chat, room_jid, type_="group", new_tab=jid.JID(room_jid).bare) 162 self.host.displayWidget(chat.Chat, room_jid, type_="group", new_tab=room_jid)
161 invite(room_jid, contacts) 163 invite(room_jid, contacts)
162 164
163 dialog.RoomAndContactsChooser(self.host, join, ok_button="Join", visible=(True, False)) 165 dialog.RoomAndContactsChooser(self.host, join, ok_button="Join", visible=(True, False))
164 166
165 def onCollectiveRadio(self): 167 def onCollectiveRadio(self):
166 def callback(room_jid, contacts): 168 def callback(room_jid, contacts):
167 self.host.bridge.call('launchRadioCollective', None, contacts, room_jid) 169 contacts = [unicode(contact) for contact in contacts]
170 self.host.bridge.call('launchRadioCollective', None, contacts, unicode(room_jid))
168 dialog.RoomAndContactsChooser(self.host, callback, ok_button="Choose", title="Collective Radio", visible=(False, True)) 171 dialog.RoomAndContactsChooser(self.host, callback, ok_button="Choose", title="Collective Radio", visible=(False, True))
169 172
170 #Game menu 173 #Game menu
171 def onTarotGame(self): 174 def onTarotGame(self):
172 def onPlayersSelected(room_jid, other_players): 175 def onPlayersSelected(room_jid, other_players):
173 self.host.bridge.call('launchTarotGame', None, other_players, room_jid) 176 other_players = [unicode(contact) for contact in other_players]
177 self.host.bridge.call('launchTarotGame', None, other_players, unicode(room_jid))
174 dialog.RoomAndContactsChooser(self.host, onPlayersSelected, 3, title="Tarot", title_invite="Please select 3 other players", visible=(False, True)) 178 dialog.RoomAndContactsChooser(self.host, onPlayersSelected, 3, title="Tarot", title_invite="Please select 3 other players", visible=(False, True))
175 179
176 def onXiangqiGame(self): 180 def onXiangqiGame(self):
177 Window.alert("A Xiangqi game is planed, but not available yet") 181 Window.alert("A Xiangqi game is planed, but not available yet")
178 182