comparison src/browser/libervia_main.py @ 834:2491898b3041

browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
author souliane <souliane@mailoo.org>
date Tue, 12 Jan 2016 17:59:07 +0100
parents f8a7a046ff9c
children a964ff397484
comparison
equal deleted inserted replaced
833:4db064a70fc7 834:2491898b3041
45 45
46 from sat_browser import json 46 from sat_browser import json
47 from sat_browser import register 47 from sat_browser import register
48 from sat_browser.contact_list import ContactList 48 from sat_browser.contact_list import ContactList
49 from sat_browser import main_panel 49 from sat_browser import main_panel
50 from sat_browser import chat
50 from sat_browser import blog 51 from sat_browser import blog
51 from sat_browser import xmlui 52 from sat_browser import xmlui
52 from sat_browser import dialog 53 from sat_browser import dialog
53 from sat_browser import html_tools 54 from sat_browser import html_tools
54 from sat_browser import notification 55 from sat_browser import notification
85 self.tab_panel = self.panel.tab_panel 86 self.tab_panel = self.panel.tab_panel
86 self.tab_panel.addTabListener(self) 87 self.tab_panel.addTabListener(self)
87 self._register_box = None 88 self._register_box = None
88 RootPanel().add(self.panel) 89 RootPanel().add(self.panel)
89 90
90 self.notification = notification.Notification()
91 self.alerts_counter = notification.FaviconCounter() 91 self.alerts_counter = notification.FaviconCounter()
92 self.notification = notification.Notification(self.alerts_counter)
92 DOM.addEventPreview(self) 93 DOM.addEventPreview(self)
93 self.importPlugins() 94 self.importPlugins()
94 self._register = json.RegisterCall() 95 self._register = json.RegisterCall()
95 self._register.call('getMenus', self.gotMenus) 96 self._register.call('getMenus', self.gotMenus)
96 self._register.call('registerParams', None) 97 self._register.call('registerParams', None)
269 if tab_index is None or tab_index < 0 or tab_index >= self.tab_panel.getWidgetCount(): 270 if tab_index is None or tab_index < 0 or tab_index >= self.tab_panel.getWidgetCount():
270 panel = self.tab_panel.getCurrentPanel() 271 panel = self.tab_panel.getCurrentPanel()
271 else: 272 else:
272 panel = self.tab_panel.deck.getWidget(tab_index) 273 panel = self.tab_panel.deck.getWidget(tab_index)
273 panel.addWidget(wid) 274 panel.addWidget(wid)
274
275 def displayNotification(self, title, body):
276 self.notification.notify(title, body)
277 275
278 def gotMenus(self, backend_menus): 276 def gotMenus(self, backend_menus):
279 """Put the menus data in cache and build the main menu bar 277 """Put the menus data in cache and build the main menu bar
280 278
281 @param backend_menus (list[tuple]): menu data from backend 279 @param backend_menus (list[tuple]): menu data from backend
610 dialog.ConfirmDialog(confirm_cb, text=data["message"], title=data["title"]).show() 608 dialog.ConfirmDialog(confirm_cb, text=data["message"], title=data["title"]).show()
611 609
612 def _newAlert(self, message, title, alert_type): 610 def _newAlert(self, message, title, alert_type):
613 dialog.InfoDialog(title, message).show() 611 dialog.InfoDialog(title, message).show()
614 612
615 def updateAlertsCounter(self): 613 def isHidden(self):
614 """Tells if the frontend window is hidden.
615
616 @return bool
617 """
618 return self.notification.isHidden()
619
620 def updateAlertsCounter(self, extra_inc=0):
616 """Update the over whole alerts counter 621 """Update the over whole alerts counter
617 622
618 """ 623 @param extra_inc (int): extra counter
619 self.alerts_counter.update(self.alerts_count) 624 """
625 extra = self.alerts_counter.extra + extra_inc
626 self.alerts_counter.update(self.alerts_count, extra=extra)
620 627
621 def _paramUpdate(self, name, value, category, refresh=True): 628 def _paramUpdate(self, name, value, category, refresh=True):
622 """This is called when the paramUpdate signal is received, but also 629 """This is called when the paramUpdate signal is received, but also
623 during initialization when the UI parameters values are retrieved. 630 during initialization when the UI parameters values are retrieved.
624 @param refresh: set to True to refresh the general UI 631 @param refresh: set to True to refresh the general UI