Mercurial > libervia-backend
comparison frontends/src/primitivus/contact_list.py @ 2009:90134b2e3dc4
primitivus, quick_frontends: show global notifications counter in contact_list + method to get these notifications in QuickApp
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 17 Jul 2016 17:32:46 +0200 |
parents | a9908e751c42 |
children | 20fb71b656e3 |
comparison
equal
deleted
inserted
replaced
2008:8a749ec21c50 | 2009:90134b2e3dc4 |
---|---|
47 PrimitivusWidget.__init__(self, self.frame, _(u'Contacts')) | 47 PrimitivusWidget.__init__(self, self.frame, _(u'Contacts')) |
48 if on_click: | 48 if on_click: |
49 urwid.connect_signal(self, 'click', on_click, user_data) | 49 urwid.connect_signal(self, 'click', on_click, user_data) |
50 if on_change: | 50 if on_change: |
51 urwid.connect_signal(self, 'change', on_change, user_data) | 51 urwid.connect_signal(self, 'change', on_change, user_data) |
52 self.host.addListener('notification', self.onNotification, [self.profile]) | |
53 self.host.addListener('notificationsClear', self.onNotification, [self.profile]) | |
52 | 54 |
53 def update(self, entities=None, type_=None, profile=None): | 55 def update(self, entities=None, type_=None, profile=None): |
54 """Update display, keep focus""" | 56 """Update display, keep focus""" |
55 # FIXME: full update is done each time, must handle entities, type_ and profile | 57 # FIXME: full update is done each time, must handle entities, type_ and profile |
56 widget, position = self.frame.body.get_focus() | 58 widget, position = self.frame.body.get_focus() |
149 """ | 151 """ |
150 entity = contact_wid.data | 152 entity = contact_wid.data |
151 self.host.modeHint(C.MODE_INSERTION) | 153 self.host.modeHint(C.MODE_INSERTION) |
152 self._emit('click', entity) | 154 self._emit('click', entity) |
153 | 155 |
156 def onNotification(self, entity, notif, profile): | |
157 notifs = self.host.getNotifs(C.ENTITY_ALL, profile=self.profile) | |
158 if notifs: | |
159 self.title_dynamic = u"({})".format(len(notifs)) | |
160 else: | |
161 self.title_dynamic = None | |
162 self.host.redraw() # FIXME: should not be necessary | |
163 | |
154 # Methods to build the widget | 164 # Methods to build the widget |
155 | 165 |
156 def _buildEntityWidget(self, entity, keys=None, use_bare_jid=False, with_notifs=True, with_show_attr=True, markup_prepend=None, markup_append = None): | 166 def _buildEntityWidget(self, entity, keys=None, use_bare_jid=False, with_notifs=True, with_show_attr=True, markup_prepend=None, markup_append = None): |
157 """Build one contact markup data | 167 """Build one contact markup data |
158 | 168 |