comparison frontends/src/primitivus/primitivus @ 1385:0dca4f9b264d

primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
author souliane <souliane@mailoo.org>
date Tue, 24 Mar 2015 07:38:40 +0100
parents ba87b940f07a
children 069ad98b360d
comparison
equal deleted inserted replaced
1384:73f8582c7c99 1385:0dca4f9b264d
620 self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp)) 620 self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp))
621 621
622 if callback and 'validated' in data: 622 if callback and 'validated' in data:
623 callback(callback_id, data, profile) 623 callback(callback_id, data, profile)
624 624
625 def action_eb(failure): 625 self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.showFailure)
626 self.showPopUp(sat_widgets.Alert(failure.fullname, failure.message, ok_cb=self.removePopUp)) 626
627 627 def showFailure(self, failure):
628 self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=action_eb) 628 """Show a failure that has been returned by an asynchronous bridge method.
629
630 @param failure (defer.Failure): Failure instance
631 """
632 self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp))
629 633
630 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): 634 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
631 answer_data={} 635 answer_data = {}
632 636
633 def dir_selected_cb(path): 637 def dir_selected_cb(path):
634 dest_path = join(path, data['filename']) 638 dest_path = join(path, data['filename'])
635 answer_data["dest_path"] = quick_utils.getNewPath(dest_path) 639 answer_data["dest_path"] = quick_utils.getNewPath(dest_path)
636 self.addProgress(confirmation_id, dest_path) 640 self.addProgress(confirmation_id, dest_path)
708 712
709 ##DIALOGS CALLBACKS## 713 ##DIALOGS CALLBACKS##
710 def onJoinRoom(self, button, edit): 714 def onJoinRoom(self, button, edit):
711 self.removePopUp() 715 self.removePopUp()
712 room_jid = jid.JID(edit.get_edit_text()) 716 room_jid = jid.JID(edit.get_edit_text())
713 if room_jid.is_valid(): 717 self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.showFailure)
714 self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile)
715 else:
716 message = _("'%s' is an invalid jid.JID !") % room_jid
717 log.error (message)
718 self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
719 718
720 #MENU EVENTS# 719 #MENU EVENTS#
721 def onConnectRequest(self, menu): 720 def onConnectRequest(self, menu):
722 QuickApp.asyncConnect(self, self.current_profile) 721 QuickApp.asyncConnect(self, self.current_profile)
723 722
737 QuickApp.onExit(self) 736 QuickApp.onExit(self)
738 raise urwid.ExitMainLoop() 737 raise urwid.ExitMainLoop()
739 738
740 def onJoinRoomRequest(self, menu): 739 def onJoinRoomRequest(self, menu):
741 """User wants to join a MUC room""" 740 """User wants to join a MUC room"""
742 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom) 741 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt=C.DEFAULT_MUC, cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
743 self.showPopUp(pop_up_widget) 742 self.showPopUp(pop_up_widget)
744 743
745 def onAboutRequest(self, menu): 744 def onAboutRequest(self, menu):
746 self.showPopUp(sat_widgets.Alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp)) 745 self.showPopUp(sat_widgets.Alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
747 746