Mercurial > libervia-web
comparison src/browser/sat_browser/panels.py @ 584:0a06cf833f5a
browser_side: various improvements, especially for MUC
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 22 Oct 2014 19:03:55 +0200 (2014-10-22) |
parents | 1c1dbe03d3c6 |
children | bade589dbd5a |
comparison
equal
deleted
inserted
replaced
583:4c6c61696ba0 | 584:0a06cf833f5a |
---|---|
1131 self.__body.setStyleName('chatPanel_body') | 1131 self.__body.setStyleName('chatPanel_body') |
1132 chat_area = HorizontalPanel() | 1132 chat_area = HorizontalPanel() |
1133 chat_area.setStyleName('chatArea') | 1133 chat_area.setStyleName('chatArea') |
1134 if type_ == 'group': | 1134 if type_ == 'group': |
1135 self.occupants_list = base_panels.OccupantsList() | 1135 self.occupants_list = base_panels.OccupantsList() |
1136 self.occupants_initialised = False | |
1136 chat_area.add(self.occupants_list) | 1137 chat_area.add(self.occupants_list) |
1137 self.__body.add(chat_area) | 1138 self.__body.add(chat_area) |
1138 self.content = AbsolutePanel() | 1139 self.content = AbsolutePanel() |
1139 self.content.setStyleName('chatContent') | 1140 self.content.setStyleName('chatContent') |
1140 self.content_scroll = base_widget.ScrollPanelWrapper(self.content) | 1141 self.content_scroll = base_widget.ScrollPanelWrapper(self.content) |
1155 def createPanel(cls, host, item, type_='one2one'): | 1156 def createPanel(cls, host, item, type_='one2one'): |
1156 assert(item) | 1157 assert(item) |
1157 _contact = item if isinstance(item, jid.JID) else jid.JID(item) | 1158 _contact = item if isinstance(item, jid.JID) else jid.JID(item) |
1158 host.contact_panel.setContactMessageWaiting(_contact.bare, False) | 1159 host.contact_panel.setContactMessageWaiting(_contact.bare, False) |
1159 _new_panel = ChatPanel(host, _contact, type_) # XXX: pyjamas doesn't seems to support creating with cls directly | 1160 _new_panel = ChatPanel(host, _contact, type_) # XXX: pyjamas doesn't seems to support creating with cls directly |
1160 _new_panel.historyPrint() | 1161 if type == 'one2one': |
1162 _new_panel.historyPrint() | |
1161 host.setSelected(_new_panel) | 1163 host.setSelected(_new_panel) |
1162 _new_panel.refresh() | 1164 _new_panel.refresh() |
1163 return _new_panel | 1165 return _new_panel |
1164 | 1166 |
1165 def refresh(self): | 1167 def refresh(self): |
1185 self.host.showWarning(*self.getWarningData()) | 1187 self.host.showWarning(*self.getWarningData()) |
1186 | 1188 |
1187 def matchEntity(self, item, type_=None): | 1189 def matchEntity(self, item, type_=None): |
1188 """ | 1190 """ |
1189 @param entity: target jid as a string or jid.JID instance. | 1191 @param entity: target jid as a string or jid.JID instance. |
1190 Could also be a couple with a type in the second element. | |
1191 @return: True if self matches the given entity | 1192 @return: True if self matches the given entity |
1192 """ | 1193 """ |
1193 if type_ is None: | 1194 if type_ is None: |
1194 type_ = self.type | 1195 type_ = self.type |
1195 entity = item if isinstance(item, jid.JID) else jid.JID(item) | 1196 entity = item if isinstance(item, jid.JID) else jid.JID(item) |
1232 self.nick = nick | 1233 self.nick = nick |
1233 | 1234 |
1234 def setPresents(self, nicks): | 1235 def setPresents(self, nicks): |
1235 """Set the users presents in this room | 1236 """Set the users presents in this room |
1236 @param occupants: list of nicks (string)""" | 1237 @param occupants: list of nicks (string)""" |
1237 self.occupants_list.clear() | |
1238 for nick in nicks: | 1238 for nick in nicks: |
1239 self.occupants_list.addOccupant(nick) | 1239 self.occupants_list.addOccupant(nick) |
1240 self.occupants_initialised = True | |
1240 | 1241 |
1241 def userJoined(self, nick, data): | 1242 def userJoined(self, nick, data): |
1243 if self.occupants_list.getOccupantBox(nick): | |
1244 return # user is already displayed | |
1242 self.occupants_list.addOccupant(nick) | 1245 self.occupants_list.addOccupant(nick) |
1243 self.printInfo("=> %s has joined the room" % nick) | 1246 if self.occupants_initialised: |
1247 self.printInfo("=> %s has joined the room" % nick) | |
1244 | 1248 |
1245 def userLeft(self, nick, data): | 1249 def userLeft(self, nick, data): |
1246 self.occupants_list.removeOccupant(nick) | 1250 self.occupants_list.removeOccupant(nick) |
1247 self.printInfo("<= %s has left the room" % nick) | 1251 self.printInfo("<= %s has left the room" % nick) |
1248 | 1252 |
1331 def setState(self, state, nick=None): | 1335 def setState(self, state, nick=None): |
1332 """Set the chat state (XEP-0085) of the contact. Leave nick to None | 1336 """Set the chat state (XEP-0085) of the contact. Leave nick to None |
1333 to set the state for a one2one conversation, or give a nickname or | 1337 to set the state for a one2one conversation, or give a nickname or |
1334 C.ALL_OCCUPANTS to set the state of a participant within a MUC. | 1338 C.ALL_OCCUPANTS to set the state of a participant within a MUC. |
1335 @param state: the new chat state | 1339 @param state: the new chat state |
1336 @param nick: None for one2one, the MUC user nick or ALL_OCCUPANTS | 1340 @param nick: ignored for one2one, otherwise the MUC user nick or C.ALL_OCCUPANTS |
1337 """ | 1341 """ |
1338 if self.type == 'group': | 1342 if self.type == 'group': |
1339 assert(nick) | 1343 assert(nick) |
1340 if nick == C.ALL_OCCUPANTS: | 1344 if nick == C.ALL_OCCUPANTS: |
1341 occupants = self.occupants_list.occupants_list.keys() | 1345 occupants = self.occupants_list.occupants_list.keys() |