quick_frontend, primitivus (chat): merge setOccupantStates and setContactStates
This commit is contained in:
parent
6dc8b211bf
commit
83af62d142
2 changed files with 20 additions and 21 deletions
|
|
@ -149,28 +149,22 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
|
||||
return menu
|
||||
|
||||
def setOccupantStates(self, occupant_jid, states):
|
||||
"""Set a MUC occupant's states.
|
||||
|
||||
@param occupant_jid (jid.JID): occupant to update
|
||||
@param states (dict{unicode: unicode}): new states
|
||||
"""
|
||||
options = self.occupants_list.getAllValues()
|
||||
for index in xrange(0, len(options)):
|
||||
nick = options[index].value
|
||||
if nick == occupant_jid.resource:
|
||||
options[index] = (nick, "%s %s" % (u''.join(states.values()), nick))
|
||||
self.occupants_list.changeValues(options)
|
||||
break
|
||||
self.host.redraw()
|
||||
|
||||
def setContactStates(self, contact_jid, states):
|
||||
"""Set a one2one contact's states.
|
||||
"""Set a contact (one2one or MUC occupant) states.
|
||||
|
||||
@param contact_jid (jid.JID): contact
|
||||
@param states (dict{unicode: unicode}): new states
|
||||
"""
|
||||
self.title_dynamic = ' '.join([u'({})'.format(state) for state in states.values()])
|
||||
if self.type == C.CHAT_GROUP:
|
||||
options = self.occupants_list.getAllValues()
|
||||
for index in xrange(0, len(options)):
|
||||
nick = options[index].value
|
||||
if nick == contact_jid.resource:
|
||||
options[index] = (nick, "%s %s" % (u''.join(states.values()), nick))
|
||||
self.occupants_list.changeValues(options)
|
||||
break
|
||||
else:
|
||||
self.title_dynamic = ' '.join([u'({})'.format(state) for state in states.values()])
|
||||
self.host.redraw()
|
||||
|
||||
def _occupantsClicked(self, list_wid, clicked_wid):
|
||||
|
|
|
|||
|
|
@ -224,10 +224,15 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
value = clist.getCache(entity, key)
|
||||
if value:
|
||||
states[key] = value
|
||||
if self.type == C.CHAT_GROUP:
|
||||
self.setOccupantStates(entity, states)
|
||||
else:
|
||||
self.setContactStates(entity, states)
|
||||
self.setContactStates(entity, states)
|
||||
|
||||
def setContactStates(self, contact_jid, states):
|
||||
"""Set a contact (one2one or MUC occupant) states.
|
||||
|
||||
@param contact_jid (jid.JID): contact
|
||||
@param states (dict{unicode: unicode}): new states
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def addGamePanel(self, widget):
|
||||
"""Insert a game panel to this Chat dialog.
|
||||
|
|
|
|||
Loading…
Reference in a new issue