comparison frontends/src/primitivus/primitivus @ 1972:02d21a589be2

quick_frontend, primitivus: notifications refactoring replaced old "alerts" system by a more generic one which use listeners and can activate callbacks on notification click.
author Goffi <goffi@goffi.org>
date Mon, 27 Jun 2016 22:36:22 +0200
parents 9421e721d5e2
children da6d1988dfcb
comparison
equal deleted inserted replaced
1971:9421e721d5e2 1972:02d21a589be2
584 self.loop.widget = display_widget 584 self.loop.widget = display_widget
585 self.redraw() 585 self.redraw()
586 else: 586 else:
587 self.notif_bar.addPopUp(pop_up_widget) 587 self.notif_bar.addPopUp(pop_up_widget)
588 588
589 def notify(self, message): 589 def barNotify(self, message):
590 """"Notify message to user via notification bar""" 590 """"Notify message to user via notification bar"""
591 self.notif_bar.addMessage(message) 591 self.notif_bar.addMessage(message)
592 self.redraw() 592 self.redraw()
593
594 def notify(self, type_, entity=None, message=None, subject=None, callback=None, cb_args=None, widget=None, profile=C.PROF_KEY_NONE):
595 if widget is None or widget is not None and widget != self.selected_widget:
596 # we ignore notification if the widget is selected but we can
597 # still do a desktop notification is the X window has not the focus
598 super(PrimitivusApp, self).notify(type_, entity, message, subject, callback, cb_args, widget, profile)
599 if not self.x_notify.hasFocus():
600 if message is None:
601 message = _("{app}: a new event has just happened{entity}").format(
602 app=C.APP_NAME,
603 entity=u' ({})'.format(entity) if entity else '')
604 self.x_notify.sendNotification(message)
605
593 606
594 def newWidget(self, widget): 607 def newWidget(self, widget):
595 if self.selected_widget is None: 608 if self.selected_widget is None:
596 self.selectWidget(widget) 609 self.selectWidget(widget)
597 610
649 def contactSelected(self, contact_list, entity): 662 def contactSelected(self, contact_list, entity):
650 if entity.resource: 663 if entity.resource:
651 # we have clicked on a private MUC conversation 664 # we have clicked on a private MUC conversation
652 chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, force_hash = Chat.getPrivateHash(contact_list.profile, entity), profile=contact_list.profile) 665 chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, force_hash = Chat.getPrivateHash(contact_list.profile, entity), profile=contact_list.profile)
653 else: 666 else:
667 self.clearNotifs(entity, profile=contact_list.profile)
654 chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, profile=contact_list.profile) 668 chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, profile=contact_list.profile)
655 self.selectWidget(chat_widget) 669 self.selectWidget(chat_widget)
656 self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET) 670 self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET)
657 671
658 def _dialogOkCb(self, widget, data): 672 def _dialogOkCb(self, widget, data):