comparison browser_side/panels.py @ 407:6a6551de4414

browser_side: display chat states (with symbols) for MUC participants
author souliane <souliane@mailoo.org>
date Sun, 16 Mar 2014 21:03:50 +0100
parents c393e7dc9ae6
children ee8ebfe23e16
comparison
equal deleted inserted replaced
406:63f8469b4ad3 407:6a6551de4414
1045 def __init__(self, host, target, type_='one2one'): 1045 def __init__(self, host, target, type_='one2one'):
1046 """Panel used for conversation (one 2 one or group chat) 1046 """Panel used for conversation (one 2 one or group chat)
1047 @param host: SatWebFrontend instance 1047 @param host: SatWebFrontend instance
1048 @param target: entity (JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) 1048 @param target: entity (JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room)
1049 @param type: one2one for simple conversation, group for MUC""" 1049 @param type: one2one for simple conversation, group for MUC"""
1050 base_widget.LiberviaWidget.__init__(self, host, target.bare, selectable=True) 1050 base_widget.LiberviaWidget.__init__(self, host, title=target.bare, selectable=True)
1051 self.vpanel = VerticalPanel() 1051 self.vpanel = VerticalPanel()
1052 self.vpanel.setSize('100%', '100%') 1052 self.vpanel.setSize('100%', '100%')
1053 self.type = type_ 1053 self.type = type_
1054 self.nick = None 1054 self.nick = None
1055 if not target: 1055 if not target:
1072 self.vpanel.add(self.__body) 1072 self.vpanel.add(self.__body)
1073 self.vpanel.setCellHeight(self.__body, '100%') 1073 self.vpanel.setCellHeight(self.__body, '100%')
1074 self.addStyleName('chatPanel') 1074 self.addStyleName('chatPanel')
1075 self.setWidget(self.vpanel) 1075 self.setWidget(self.vpanel)
1076 self.state_machine = ChatStateMachine(self.host, str(self.target)) 1076 self.state_machine = ChatStateMachine(self.host, str(self.target))
1077 1077 self._state = None
1078 """def doDetachChildren(self):
1079 #We need to force the use of a panel subclass method here,
1080 #for the same reason as doAttachChildren
1081 base_widget.ScrollPanelWrapper.doDetachChildren(self)
1082
1083 def doAttachChildren(self):
1084 #We need to force the use of a panel subclass method here, else
1085 #the event will not propagate to children
1086 base_widget.ScrollPanelWrapper.doAttachChildren(self)"""
1087 1078
1088 @classmethod 1079 @classmethod
1089 def registerClass(cls): 1080 def registerClass(cls):
1090 base_widget.LiberviaWidget.addDropKey("CONTACT", cls.createPanel) 1081 base_widget.LiberviaWidget.addDropKey("CONTACT", cls.createPanel)
1091 1082
1239 # TODO: check that the game is launched, and manage errors 1230 # TODO: check that the game is launched, and manage errors
1240 if game_type == "Tarot": 1231 if game_type == "Tarot":
1241 return self.tarot_panel 1232 return self.tarot_panel
1242 elif game_type == "RadioCol": 1233 elif game_type == "RadioCol":
1243 return self.radiocol_panel 1234 return self.radiocol_panel
1235
1236 def setState(self, state, nick=None):
1237 """Set the chat state (XEP-0085) of the contact. Leave nick to None
1238 to set the state for a one2one conversation, or give a nickname or
1239 Const.ALL_OCCUPANTS to set the state of a participant within a MUC.
1240 @param state: the new chat state
1241 @param nick: None for one2one, the MUC user nick or ALL_OCCUPANTS
1242 """
1243 if nick:
1244 assert(self.type == 'group')
1245 occupants = self.occupants_list.occupants_list.keys() if nick == Const.ALL_OCCUPANTS else [nick]
1246 for occupant in occupants:
1247 self.occupants_list.occupants_list[occupant].setState(state)
1248 else:
1249 assert(self.type == 'one2one')
1250 self._state = state
1251 self.refreshTitle()
1252 self.state_machine.started = not not state # start to send "composing" state from now
1253
1254 def refreshTitle(self):
1255 """Refresh the title of this ChatPanel dialog"""
1256 if self._state:
1257 self.setTitle(self.target.bare + " (" + self._state + ")")
1258 else:
1259 self.setTitle(self.target.bare)
1244 1260
1245 1261
1246 class WebPanel(base_widget.LiberviaWidget): 1262 class WebPanel(base_widget.LiberviaWidget):
1247 """ (mini)browser like widget """ 1263 """ (mini)browser like widget """
1248 1264