From 252bf6bef37ff5efc58f2e04aded834943d090df Mon Sep 17 00:00:00 2001 From: souliane Date: Mon, 20 Jul 2015 10:23:58 +0200 Subject: [PATCH] quick_frontend: display over whole alerts counter --- frontends/src/quick_frontend/quick_app.py | 11 +++++++++++ frontends/src/quick_frontend/quick_contact_list.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index d459f428..819add93 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -278,6 +278,11 @@ class QuickApp(object): """widgets currently visible (must be implemented by frontend)""" raise NotImplementedError + @property + def alerts_count(self): + """Count the over whole alerts for all contact lists""" + return sum([len(clist._alerts) for clist in self.contact_lists.values()]) + def registerSignal(self, function_name, handler=None, iface="core", with_profile=True): """Register a handler for a signal @@ -638,6 +643,12 @@ class QuickApp(object): def showAlert(self, message): pass #FIXME + def updateAlertsCounter(self): + """Update the over whole alerts counter + + """ + pass + def paramUpdateHandler(self, name, value, namespace, profile): log.debug(_(u"param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace': namespace, 'name': name, 'value': value}) if (namespace, name) == ("Connection", "JabberID"): diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index 1f0f64d7..ebf221b6 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -272,6 +272,7 @@ class QuickContactList(QuickWidget): self._special_extras.clear() self._roster.clear() self._alerts.clear() + self.host.updateAlertsCounter() self.update() def setContact(self, entity, groups=None, attributes=None, in_roster=False): @@ -466,6 +467,7 @@ class QuickContactList(QuickWidget): """ self._alerts.add(entity) self.update() + self.host.updateAlertsCounter() def removeAlert(self, entity, use_bare_jid=True): """Eventually remove an alert on the entity (usually for a waiting message). @@ -482,6 +484,7 @@ class QuickContactList(QuickWidget): else: self._alerts.discard(entity) self.update() + self.host.updateAlertsCounter() def _showOfflineContacts(self, show_str): self.showOfflineContacts(C.bool(show_str))