diff src/browser/libervia_main.py @ 944:5d9f6d25c586

browser: various fixes this is a first pass to fix main Libervia features which have been broken with changes in backend: - fixed Chat signature - added/removed/replaced a couple of missing methods - use contact_list_widget instead of contact_list when needed
author Goffi <goffi@goffi.org>
date Fri, 19 May 2017 17:03:04 +0200
parents 0c0551967bdf
children fd4eae654182
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Fri May 19 13:54:49 2017 +0200
+++ b/src/browser/libervia_main.py	Fri May 19 17:03:04 2017 +0200
@@ -47,7 +47,7 @@
 from sat_browser import register
 from sat_browser.contact_list import ContactList
 from sat_browser import main_panel
-from sat_browser import chat
+# from sat_browser import chat
 from sat_browser import blog
 from sat_browser import xmlui
 from sat_browser import dialog
@@ -215,10 +215,12 @@
         return True
 
     def onTabSelected(self, sender, tab_index):
-        for widget in self.tab_panel.getCurrentPanel().widgets:
-            if isinstance(widget, chat.Chat):
-                clist = self.contact_list
-                clist.removeAlerts(widget.current_target, True)
+        pass
+    # def onTabSelected(self, sender, tab_index):
+    #     for widget in self.tab_panel.getCurrentPanel().widgets:
+    #         if isinstance(widget, chat.Chat):
+    #             clist = self.contact_list
+    #             clist.removeAlerts(widget.current_target, True)
 
     def onEventPreview(self, event):
         if event.type in ["keydown", "keypress", "keyup"] and event.keyCode == KEY_ESCAPE:
@@ -311,6 +313,20 @@
         # XXX: temp, will be reworked in the backed static blog plugin
         self.menus.addMenu(C.MENU_JID_CONTEXT, (D_(u"User"), D_("Public blog")), callback=main_menu.onPublicBlog)
 
+    def removeListener(self, type_, callback):
+        """Remove a callback from listeners
+
+        @param type_: same as for [addListener]
+        @param callback: callback to remove
+        """
+        # FIXME: workaround for pyjamas
+        #        check KeyError issue
+        assert type_ in C.LISTENERS
+        try:
+            self._listeners[type_].pop(callback)
+        except KeyError:
+            pass
+
     def _getSessionMetadataCB(self, metadata):
         if not metadata['plugged']:
             warning = metadata.get("warning")
@@ -357,6 +373,7 @@
         self._profile_plugged = True
         QuickApp.profilePlugged(self, C.PROF_KEY_NONE)
         contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, profile=C.PROF_KEY_NONE)
+        self.contact_list_widget = contact_list
         self.panel.addContactList(contact_list)
 
         # FIXME: the contact list height has to be set manually the first time