From cc829beac7fe9189ee3639535d495b53e0dae68c Mon Sep 17 00:00:00 2001 From: souliane Date: Thu, 16 Apr 2015 13:31:14 +0200 Subject: [PATCH] quick_frontend, primitivus: move code to remove a new message alert from primitivus to quick_frontend --- frontends/src/primitivus/contact_list.py | 10 +--------- .../src/quick_frontend/quick_contact_list.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontends/src/primitivus/contact_list.py b/frontends/src/primitivus/contact_list.py index e493196c..839f9d1c 100644 --- a/frontends/src/primitivus/contact_list.py +++ b/frontends/src/primitivus/contact_list.py @@ -136,16 +136,8 @@ class ContactList(PrimitivusWidget, QuickContactList): @param selected: boolean returned by the widget, telling if it is selected """ entity = contact_wid.data - if use_bare_jid: - to_remove = set() - for alert_entity in self._alerts: - if alert_entity.bare == entity.bare: - to_remove.add(alert_entity) - self._alerts.difference_update(to_remove) - else: - self._alerts.discard(entity) + self.removeAlert(entity, use_bare_jid) self.host.modeHint(C.MODE_INSERTION) - self.update() self._emit('click', entity) def onNickUpdate(self, entity, new_nick, profile): diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index 2131657b..c05e89bb 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -444,6 +444,22 @@ class QuickContactList(QuickWidget): self._alerts.add(entity) self.update() + def removeAlert(self, entity, use_bare_jid=True): + """Eventually remove an alert on the entity (usually for a waiting message). + + @param entity(jid.JID): entity (resource is significant) + @param use_bare_jid (bool): if True, ignore the resource + """ + if use_bare_jid: + to_remove = set() + for alert_entity in self._alerts: + if alert_entity.bare == entity.bare: + to_remove.add(alert_entity) + self._alerts.difference_update(to_remove) + else: + self._alerts.discard(entity) + self.update() + def _showOfflineContacts(self, show_str): self.showOfflineContacts(C.bool(show_str))