primitivus, quick_frontends: show global notifications counter in contact_list + method to get these notifications in QuickApp
This commit is contained in:
parent
8c9161bc87
commit
73a8db4e64
1 changed files with 19 additions and 3 deletions
|
|
@ -49,6 +49,8 @@ class ContactList(PrimitivusWidget, QuickContactList):
|
|||
urwid.connect_signal(self, 'click', on_click, user_data)
|
||||
if on_change:
|
||||
urwid.connect_signal(self, 'change', on_change, user_data)
|
||||
self.host.addListener('notification', self.onNotification, [self.profile])
|
||||
self.host.addListener('notificationsClear', self.onNotification, [self.profile])
|
||||
|
||||
def update(self, entities=None, type_=None, profile=None):
|
||||
"""Update display, keep focus"""
|
||||
|
|
@ -151,6 +153,14 @@ class ContactList(PrimitivusWidget, QuickContactList):
|
|||
self.host.modeHint(C.MODE_INSERTION)
|
||||
self._emit('click', entity)
|
||||
|
||||
def onNotification(self, entity, notif, profile):
|
||||
notifs = self.host.getNotifs(C.ENTITY_ALL, profile=self.profile)
|
||||
if notifs:
|
||||
self.title_dynamic = u"({})".format(len(notifs))
|
||||
else:
|
||||
self.title_dynamic = None
|
||||
self.host.redraw() # FIXME: should not be necessary
|
||||
|
||||
# Methods to build the widget
|
||||
|
||||
def _buildEntityWidget(self, entity, keys=None, use_bare_jid=False, with_notifs=True, with_show_attr=True, markup_prepend=None, markup_append = None):
|
||||
|
|
|
|||
Loading…
Reference in a new issue