Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 1468:731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 18 Aug 2015 09:01:18 +0200 |
parents | b06047e1c1fb |
children | 641cfd2faefe |
comparison
equal
deleted
inserted
replaced
1467:ceba6fd77739 | 1468:731fbed0b9cf |
---|---|
278 | 278 |
279 | 279 |
280 class PrimitivusApp(QuickApp, InputHistory): | 280 class PrimitivusApp(QuickApp, InputHistory): |
281 | 281 |
282 def __init__(self): | 282 def __init__(self): |
283 QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, check_options=quick_utils.check_options) | 283 QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, xmlui=xmlui, check_options=quick_utils.check_options) |
284 | 284 |
285 ## main loop setup ## | 285 ## main loop setup ## |
286 self.main_widget = ProfileManager(self) | 286 self.main_widget = ProfileManager(self) |
287 self.loop = urwid.MainLoop(self.main_widget, C.PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) | 287 self.loop = urwid.MainLoop(self.main_widget, C.PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) |
288 | 288 |
581 else: | 581 else: |
582 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore | 582 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
583 log.error(_('unmanaged dialog type: %s'), type_) | 583 log.error(_('unmanaged dialog type: %s'), type_) |
584 self.showPopUp(popup) | 584 self.showPopUp(popup) |
585 | 585 |
586 def dialogFailure(self, failure): | |
587 """Show a failure that has been returned by an asynchronous bridge method. | |
588 | |
589 @param failure (defer.Failure): Failure instance | |
590 """ | |
591 self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp)) | |
592 | |
586 def onNotification(self, notif_bar): | 593 def onNotification(self, notif_bar): |
587 """Called when a new notification has been received""" | 594 """Called when a new notification has been received""" |
588 if not isinstance(self.main_widget, PrimitivusTopWidget): | 595 if not isinstance(self.main_widget, PrimitivusTopWidget): |
589 #if we are not in the main configuration, we ignore the notifications bar | 596 #if we are not in the main configuration, we ignore the notifications bar |
590 return | 597 return |
592 #No notification left, we can hide the bar | 599 #No notification left, we can hide the bar |
593 self.main_widget.hide('notif_bar') | 600 self.main_widget.hide('notif_bar') |
594 else: | 601 else: |
595 self.main_widget.show('notif_bar') | 602 self.main_widget.show('notif_bar') |
596 | 603 |
597 def launchAction(self, callback_id, data=None, callback=None, profile=C.PROF_KEY_NONE): | 604 def _actionManagerUnknownError(self): |
598 """ Launch a dynamic action | 605 self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action"), ok_cb=self.removePopUp)) |
599 @param callback_id: id of the action to launch | |
600 @param data: data needed only for certain actions | |
601 @param callback: if not None and 'validated' key is present, it will be called with the following parameters: | |
602 - callback_id | |
603 - data | |
604 - profile | |
605 @param profile: %(doc_profile)s | |
606 | |
607 """ | |
608 if data is None: | |
609 data = dict() | |
610 | |
611 def action_cb(data): | |
612 if not data: | |
613 # action was a one shot, nothing to do | |
614 pass | |
615 elif "xmlui" in data: | |
616 ui = xmlui.create(self, xml_data=data['xmlui'], callback=callback, profile=profile) | |
617 ui.show() | |
618 elif 'validated' in data: | |
619 pass # this key is managed below | |
620 else: | |
621 self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp)) | |
622 | |
623 if callback and 'validated' in data: | |
624 callback(callback_id, data, profile) | |
625 | |
626 self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.showFailure) | |
627 | |
628 def showFailure(self, failure): | |
629 """Show a failure that has been returned by an asynchronous bridge method. | |
630 | |
631 @param failure (defer.Failure): Failure instance | |
632 """ | |
633 self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp)) | |
634 | 606 |
635 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): | 607 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): |
636 answer_data = {} | 608 answer_data = {} |
637 | 609 |
638 def dir_selected_cb(path): | 610 def dir_selected_cb(path): |
713 | 685 |
714 ##DIALOGS CALLBACKS## | 686 ##DIALOGS CALLBACKS## |
715 def onJoinRoom(self, button, edit): | 687 def onJoinRoom(self, button, edit): |
716 self.removePopUp() | 688 self.removePopUp() |
717 room_jid = jid.JID(edit.get_edit_text()) | 689 room_jid = jid.JID(edit.get_edit_text()) |
718 self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.showFailure) | 690 self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self._notifyFailure) |
719 | 691 |
720 #MENU EVENTS# | 692 #MENU EVENTS# |
721 def onConnectRequest(self, menu): | 693 def onConnectRequest(self, menu): |
722 QuickApp.asyncConnect(self, self.current_profile) | 694 QuickApp.asyncConnect(self, self.current_profile) |
723 | 695 |