quick_frontend, primitivus: display the number of alerts for each contact and not only a symbol (*)

This commit is contained in:
souliane 2015-11-24 13:31:28 +01:00
commit 54e9afe5a3
2 changed files with 53 additions and 26 deletions

View file

@ -98,4 +98,4 @@ class Const(constants.Const):
GROUP_DATA_FOLDED = 'folded'
# contacts and contact list
ALERT_HEADER='(*) '
ALERT_HEADER='(%i) '

View file

@ -136,7 +136,7 @@ class ContactList(PrimitivusWidget, QuickContactList):
@param selected: boolean returned by the widget, telling if it is selected
"""
entity = contact_wid.data
self.removeAlert(entity, use_bare_jid)
self.removeAlerts(entity, use_bare_jid)
self.host.modeHint(C.MODE_INSERTION)
self._emit('click', entity)
@ -163,10 +163,8 @@ class ContactList(PrimitivusWidget, QuickContactList):
"""
markup = []
if use_bare_jid:
alerts = {entity.bare for entity in self._alerts}
selected = {entity.bare for entity in self._selected}
else:
alerts = self._alerts
selected = self._selected
if keys is None:
entity_txt = entity
@ -191,9 +189,10 @@ class ContactList(PrimitivusWidget, QuickContactList):
else:
entity_attr = 'default'
if with_alert and entity in alerts:
alerts_count = self.getAlerts(entity, use_bare_jid=use_bare_jid)
if with_alert and alerts_count:
entity_attr = 'alert'
header = C.ALERT_HEADER
header = C.ALERT_HEADER % alerts_count
else:
header = ''