Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 1383:59c48796759e
quick_frontend, primitivus (chat): merge setOccupantStates and setContactStates
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 23 Mar 2015 09:34:23 +0100 |
parents | b01efa1c0f5e |
children | 1f3513cfb246 |
comparison
equal
deleted
inserted
replaced
1382:b01efa1c0f5e | 1383:59c48796759e |
---|---|
147 elif self.type == C.CHAT_ONE2ONE: | 147 elif self.type == C.CHAT_ONE2ONE: |
148 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target}) | 148 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target}) |
149 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) | 149 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) |
150 return menu | 150 return menu |
151 | 151 |
152 def setOccupantStates(self, occupant_jid, states): | |
153 """Set a MUC occupant's states. | |
154 | |
155 @param occupant_jid (jid.JID): occupant to update | |
156 @param states (dict{unicode: unicode}): new states | |
157 """ | |
158 options = self.occupants_list.getAllValues() | |
159 for index in xrange(0, len(options)): | |
160 nick = options[index].value | |
161 if nick == occupant_jid.resource: | |
162 options[index] = (nick, "%s %s" % (u''.join(states.values()), nick)) | |
163 self.occupants_list.changeValues(options) | |
164 break | |
165 self.host.redraw() | |
166 | |
167 def setContactStates(self, contact_jid, states): | 152 def setContactStates(self, contact_jid, states): |
168 """Set a one2one contact's states. | 153 """Set a contact (one2one or MUC occupant) states. |
169 | 154 |
170 @param contact_jid (jid.JID): contact | 155 @param contact_jid (jid.JID): contact |
171 @param states (dict{unicode: unicode}): new states | 156 @param states (dict{unicode: unicode}): new states |
172 """ | 157 """ |
173 self.title_dynamic = ' '.join([u'({})'.format(state) for state in states.values()]) | 158 if self.type == C.CHAT_GROUP: |
159 options = self.occupants_list.getAllValues() | |
160 for index in xrange(0, len(options)): | |
161 nick = options[index].value | |
162 if nick == contact_jid.resource: | |
163 options[index] = (nick, "%s %s" % (u''.join(states.values()), nick)) | |
164 self.occupants_list.changeValues(options) | |
165 break | |
166 else: | |
167 self.title_dynamic = ' '.join([u'({})'.format(state) for state in states.values()]) | |
174 self.host.redraw() | 168 self.host.redraw() |
175 | 169 |
176 def _occupantsClicked(self, list_wid, clicked_wid): | 170 def _occupantsClicked(self, list_wid, clicked_wid): |
177 assert self.type == C.CHAT_GROUP | 171 assert self.type == C.CHAT_GROUP |
178 nick = clicked_wid.getValue().value | 172 nick = clicked_wid.getValue().value |