quick_frontend, primitivus: notifications refactoring
replaced old "alerts" system by a more generic one which use listeners and can activate callbacks on notification click.
This commit is contained in:
parent
22d70f23c4
commit
b388d2b172
1 changed files with 131 additions and 139 deletions
|
|
@ -586,11 +586,24 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
else:
|
||||
self.notif_bar.addPopUp(pop_up_widget)
|
||||
|
||||
def notify(self, message):
|
||||
def barNotify(self, message):
|
||||
""""Notify message to user via notification bar"""
|
||||
self.notif_bar.addMessage(message)
|
||||
self.redraw()
|
||||
|
||||
def notify(self, type_, entity=None, message=None, subject=None, callback=None, cb_args=None, widget=None, profile=C.PROF_KEY_NONE):
|
||||
if widget is None or widget is not None and widget != self.selected_widget:
|
||||
# we ignore notification if the widget is selected but we can
|
||||
# still do a desktop notification is the X window has not the focus
|
||||
super(PrimitivusApp, self).notify(type_, entity, message, subject, callback, cb_args, widget, profile)
|
||||
if not self.x_notify.hasFocus():
|
||||
if message is None:
|
||||
message = _("{app}: a new event has just happened{entity}").format(
|
||||
app=C.APP_NAME,
|
||||
entity=u' ({})'.format(entity) if entity else '')
|
||||
self.x_notify.sendNotification(message)
|
||||
|
||||
|
||||
def newWidget(self, widget):
|
||||
if self.selected_widget is None:
|
||||
self.selectWidget(widget)
|
||||
|
|
@ -651,6 +664,7 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
# we have clicked on a private MUC conversation
|
||||
chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, force_hash = Chat.getPrivateHash(contact_list.profile, entity), profile=contact_list.profile)
|
||||
else:
|
||||
self.clearNotifs(entity, profile=contact_list.profile)
|
||||
chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, profile=contact_list.profile)
|
||||
self.selectWidget(chat_widget)
|
||||
self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET)
|
||||
|
|
|
|||
Loading…
Reference in a new issue