comparison 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
comparison
equal deleted inserted replaced
943:aacda981c348 944:5d9f6d25c586
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 chat
51 from sat_browser import blog 51 from sat_browser import blog
52 from sat_browser import xmlui 52 from sat_browser import xmlui
53 from sat_browser import dialog 53 from sat_browser import dialog
54 from sat_browser import html_tools 54 from sat_browser import html_tools
55 from sat_browser import notification 55 from sat_browser import notification
213 213
214 def onBeforeTabSelected(self, sender, tab_index): 214 def onBeforeTabSelected(self, sender, tab_index):
215 return True 215 return True
216 216
217 def onTabSelected(self, sender, tab_index): 217 def onTabSelected(self, sender, tab_index):
218 for widget in self.tab_panel.getCurrentPanel().widgets: 218 pass
219 if isinstance(widget, chat.Chat): 219 # def onTabSelected(self, sender, tab_index):
220 clist = self.contact_list 220 # for widget in self.tab_panel.getCurrentPanel().widgets:
221 clist.removeAlerts(widget.current_target, True) 221 # if isinstance(widget, chat.Chat):
222 # clist = self.contact_list
223 # clist.removeAlerts(widget.current_target, True)
222 224
223 def onEventPreview(self, event): 225 def onEventPreview(self, event):
224 if event.type in ["keydown", "keypress", "keyup"] and event.keyCode == KEY_ESCAPE: 226 if event.type in ["keydown", "keypress", "keyup"] and event.keyCode == KEY_ESCAPE:
225 #needed to prevent request cancellation in Firefox 227 #needed to prevent request cancellation in Firefox
226 event.preventDefault() 228 event.preventDefault()
308 # we can now display all the menus 310 # we can now display all the menus
309 main_menu.update(C.MENU_GLOBAL) 311 main_menu.update(C.MENU_GLOBAL)
310 312
311 # XXX: temp, will be reworked in the backed static blog plugin 313 # XXX: temp, will be reworked in the backed static blog plugin
312 self.menus.addMenu(C.MENU_JID_CONTEXT, (D_(u"User"), D_("Public blog")), callback=main_menu.onPublicBlog) 314 self.menus.addMenu(C.MENU_JID_CONTEXT, (D_(u"User"), D_("Public blog")), callback=main_menu.onPublicBlog)
315
316 def removeListener(self, type_, callback):
317 """Remove a callback from listeners
318
319 @param type_: same as for [addListener]
320 @param callback: callback to remove
321 """
322 # FIXME: workaround for pyjamas
323 # check KeyError issue
324 assert type_ in C.LISTENERS
325 try:
326 self._listeners[type_].pop(callback)
327 except KeyError:
328 pass
313 329
314 def _getSessionMetadataCB(self, metadata): 330 def _getSessionMetadataCB(self, metadata):
315 if not metadata['plugged']: 331 if not metadata['plugged']:
316 warning = metadata.get("warning") 332 warning = metadata.get("warning")
317 self.panel.setStyleAttribute("opacity", "0.25") # set background transparency 333 self.panel.setStyleAttribute("opacity", "0.25") # set background transparency
355 371
356 def profilePlugged(self, dummy): 372 def profilePlugged(self, dummy):
357 self._profile_plugged = True 373 self._profile_plugged = True
358 QuickApp.profilePlugged(self, C.PROF_KEY_NONE) 374 QuickApp.profilePlugged(self, C.PROF_KEY_NONE)
359 contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, profile=C.PROF_KEY_NONE) 375 contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, profile=C.PROF_KEY_NONE)
376 self.contact_list_widget = contact_list
360 self.panel.addContactList(contact_list) 377 self.panel.addContactList(contact_list)
361 378
362 # FIXME: the contact list height has to be set manually the first time 379 # FIXME: the contact list height has to be set manually the first time
363 self.resize() 380 self.resize()
364 381