comparison frontends/src/primitivus/primitivus @ 1290:faa1129559b8 frontends_multi_profiles

core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit): /!\ not finished, everything is still instable ! - bridge: DBus bridge has been modified to allow blocking call to be called in the same way as asynchronous calls - bridge: calls with a callback and no errback are now possible, default errback log the error - constants: removed hack to manage presence without OrderedDict, as an OrderedDict like class has been implemented in Libervia - core: getLastResource has been removed and replaced by getMainResource (there is a global better management of resources) - various style improvments: use of constants when possible, fixed variable overlaps, import of module instead of direct class import - frontends: printInfo and printMessage methods in (Quick)Chat are more generic (use of extra instead of timestamp) - frontends: bridge creation and option parsing (command line arguments) are now specified by the frontend in QuickApp __init__ - frontends: ProfileManager manage a more complete plug sequence (some stuff formerly manage in contact_list have moved to ProfileManager) - quick_frontend (quick_widgets): QuickWidgetsManager is now iterable (all widgets are then returned), or can return an iterator on a specific class (return all widgets of this class) with getWidgets - frontends: tools.jid can now be used in Pyjamas, with some care - frontends (XMLUI): profile is now managed - core (memory): big improvment on entities cache management (and specially resource management) - core (params/exceptions): added PermissionError - various fixes and improvments, check diff for more details
author Goffi <goffi@goffi.org>
date Sat, 24 Jan 2015 01:00:29 +0100
parents e3a9ea76de35
children 0f92b6a150ff 2ecc07a8f91b
comparison
equal deleted inserted replaced
1289:653f2e2eea31 1290:faa1129559b8
25 from sat.core import log as logging 25 from sat.core import log as logging
26 log = logging.getLogger(__name__) 26 log = logging.getLogger(__name__)
27 import urwid 27 import urwid
28 from urwid_satext import sat_widgets 28 from urwid_satext import sat_widgets
29 from urwid_satext.files_management import FileDialog 29 from urwid_satext.files_management import FileDialog
30 from sat_frontends.bridge.DBus import DBusBridgeFrontend
30 from sat_frontends.quick_frontend.quick_app import QuickApp 31 from sat_frontends.quick_frontend.quick_app import QuickApp
31 from sat_frontends.quick_frontend.quick_utils import getNewPath 32 from sat_frontends.quick_frontend import quick_utils
32 from sat_frontends.quick_frontend import quick_chat 33 from sat_frontends.quick_frontend import quick_chat
33 from sat_frontends.primitivus.profile_manager import ProfileManager 34 from sat_frontends.primitivus.profile_manager import ProfileManager
34 from sat_frontends.primitivus.contact_list import ContactList 35 from sat_frontends.primitivus.contact_list import ContactList
35 from sat_frontends.primitivus.chat import Chat 36 from sat_frontends.primitivus.chat import Chat
36 from sat_frontends.primitivus import xmlui 37 from sat_frontends.primitivus import xmlui
275 276
276 277
277 class PrimitivusApp(QuickApp, InputHistory): 278 class PrimitivusApp(QuickApp, InputHistory):
278 279
279 def __init__(self): 280 def __init__(self):
280 QuickApp.__init__(self) 281 QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, check_options=quick_utils.check_options)
281 282
282 ## main loop setup ## 283 ## main loop setup ##
283 self.main_widget = ProfileManager(self) 284 self.main_widget = ProfileManager(self)
284 self.loop = urwid.MainLoop(self.main_widget, C.PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) 285 self.loop = urwid.MainLoop(self.main_widget, C.PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler)
285 286
286
287 ##misc setup## 287 ##misc setup##
288 self._visible_widgets = set()
288 self.notif_bar = sat_widgets.NotificationBar() 289 self.notif_bar = sat_widgets.NotificationBar()
289 urwid.connect_signal(self.notif_bar, 'change', self.onNotification) 290 urwid.connect_signal(self.notif_bar, 'change', self.onNotification)
290 291
291 self.progress_wid = self.widgets.getOrCreateWidget(Progress, None, on_new_widget=None) 292 self.progress_wid = self.widgets.getOrCreateWidget(Progress, None, on_new_widget=None)
292 urwid.connect_signal(self.notif_bar.progress, 'click', lambda x: self.selectWidget(self.progress_wid)) 293 urwid.connect_signal(self.notif_bar.progress, 'click', lambda x: self.selectWidget(self.progress_wid))
294 295
295 self.x_notify = Notify() 296 self.x_notify = Notify()
296 297
297 # we already manage exit with a_key['APP_QUIT'], so we don't want C-c 298 # we already manage exit with a_key['APP_QUIT'], so we don't want C-c
298 signal.signal(signal.SIGINT, signal.SIG_IGN) 299 signal.signal(signal.SIGINT, signal.SIG_IGN)
300
301 @property
302 def visible_widgets(self):
303 return self._visible_widgets
299 304
300 @property 305 @property
301 def mode(self): 306 def mode(self):
302 return self.editBar.mode 307 return self.editBar.mode
303 308
494 """"Notify message to user via notification bar""" 499 """"Notify message to user via notification bar"""
495 self.notif_bar.addMessage(message) 500 self.notif_bar.addMessage(message)
496 self.redraw() 501 self.redraw()
497 502
498 def newWidget(self, widget): 503 def newWidget(self, widget):
504 self.selectWidget(widget)
505
506 def selectWidget(self, widget):
499 """Display a widget if possible, 507 """Display a widget if possible,
500 508
501 else add it in the notification bar queue 509 else add it in the notification bar queue
502 @param widget: BoxWidget 510 @param widget: BoxWidget
503 """ 511 """
504 self.selectWidget(widget)
505
506 def selectWidget(self, widget):
507 assert len(self.center_part.widget_list)<=2 512 assert len(self.center_part.widget_list)<=2
508 wid_idx = len(self.center_part.widget_list)-1 513 wid_idx = len(self.center_part.widget_list)-1
509 self.center_part.widget_list[wid_idx] = widget 514 self.center_part.widget_list[wid_idx] = widget
510 try: 515 try:
511 self.menu_roller.removeMenu(C.MENU_ID_WIDGET) 516 self.menu_roller.removeMenu(C.MENU_ID_WIDGET)
512 except KeyError: 517 except KeyError:
513 log.debug("No menu to delete") 518 log.debug("No menu to delete")
514 self.selected_widget = widget 519 self.selected_widget = widget
515 self.visible_widgets = set([widget]) # XXX: we can only have one widget visible at the time for now 520 self._visible_widgets = set([widget]) # XXX: we can only have one widget visible at the time for now
516 for contact_list in self.contact_lists.itervalues(): 521 for contact_list in self.contact_lists.itervalues():
517 contact_list.unselectAll() 522 contact_list.unselectAll()
518 523
519 for wid in self.visible_widgets: 524 for wid in self.visible_widgets:
520 if isinstance(wid, Chat): 525 if isinstance(wid, Chat):
640 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): 645 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
641 answer_data={} 646 answer_data={}
642 647
643 def dir_selected_cb(path): 648 def dir_selected_cb(path):
644 dest_path = join(path, data['filename']) 649 dest_path = join(path, data['filename'])
645 answer_data["dest_path"] = getNewPath(dest_path) 650 answer_data["dest_path"] = quick_utils.getNewPath(dest_path)
646 self.addProgress(confirmation_id, dest_path) 651 self.addProgress(confirmation_id, dest_path)
647 accept_cb(None) 652 accept_cb(None)
648 653
649 def accept_file_transfer_cb(widget): 654 def accept_file_transfer_cb(widget):
650 self.removePopUp() 655 self.removePopUp()