Mercurial > libervia-backend
diff frontends/src/primitivus/contact_list.py @ 1972:02d21a589be2
quick_frontend, primitivus: notifications refactoring
replaced old "alerts" system by a more generic one which use listeners and can activate callbacks on notification click.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jun 2016 22:36:22 +0200 |
parents | 011eff37e21d |
children | a9908e751c42 |
line wrap: on
line diff
--- a/frontends/src/primitivus/contact_list.py Mon Jun 27 21:45:13 2016 +0200 +++ b/frontends/src/primitivus/contact_list.py Mon Jun 27 22:36:22 2016 +0200 @@ -144,18 +144,16 @@ """Method called when a contact is clicked @param use_bare_jid: True if use_bare_jid is set in self._buildEntityWidget. - If True, all jids in self._alerts with the same bare jid has contact_wid.data will be removed @param contact_wid: widget of the contact, must have the entity set in data attribute @param selected: boolean returned by the widget, telling if it is selected """ entity = contact_wid.data - self.contact_list.removeAlerts(entity, use_bare_jid) self.host.modeHint(C.MODE_INSERTION) self._emit('click', entity) # Methods to build the widget - def _buildEntityWidget(self, entity, keys=None, use_bare_jid=False, with_alert=True, with_show_attr=True, markup_prepend=None, markup_append = None): + def _buildEntityWidget(self, entity, keys=None, use_bare_jid=False, with_notifs=True, with_show_attr=True, markup_prepend=None, markup_append = None): """Build one contact markup data @param entity (jid.JID): entity to build @@ -164,8 +162,8 @@ If key starts with "cache_", it will be checked in cache, else, getattr will be done on entity with the key (e.g. getattr(entity, 'node')). If nothing full or keys is None, full entity is used. - @param use_bare_jid (bool): if True, use bare jid for alerts and selected comparisons - @param with_alert (bool): if True, show alert if entity is in self._alerts + @param use_bare_jid (bool): if True, use bare jid for selected comparisons + @param with_notifs (bool): if True, show notification count @param with_show_attr (bool): if True, show color corresponding to presence status @param markup_prepend (list): markup to prepend to the generated one before building the widget @param markup_append (list): markup to append to the generated one before building the widget @@ -199,12 +197,12 @@ else: entity_attr = 'default' - alerts_count = len(self.contact_list.getAlerts(entity, use_bare_jid=use_bare_jid)) - if with_alert and alerts_count: - entity_attr = 'alert' - header = C.ALERT_HEADER % alerts_count + notifs = self.host.getNotifs(entity.bare, profile=self.profile) + if notifs: + entity_attr = 'cl_notifs' + header = u'({}) '.format(len(notifs)) else: - header = '' + header = u'' markup.append((entity_attr, entity_txt)) if markup_prepend: