quick_frontend, primitivus: handling of actionNew signal
This commit is contained in:
parent
97d140566c
commit
3312c3bf97
1 changed files with 52 additions and 44 deletions
|
|
@ -280,7 +280,7 @@ class PrimitivusTopWidget(sat_widgets.FocusPile):
|
|||
class PrimitivusApp(QuickApp, InputHistory):
|
||||
|
||||
def __init__(self):
|
||||
QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, check_options=quick_utils.check_options)
|
||||
QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, xmlui=xmlui, check_options=quick_utils.check_options)
|
||||
|
||||
## main loop setup ##
|
||||
self.main_widget = ProfileManager(self)
|
||||
|
|
@ -583,6 +583,13 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
log.error(_('unmanaged dialog type: %s'), type_)
|
||||
self.showPopUp(popup)
|
||||
|
||||
def dialogFailure(self, failure):
|
||||
"""Show a failure that has been returned by an asynchronous bridge method.
|
||||
|
||||
@param failure (defer.Failure): Failure instance
|
||||
"""
|
||||
self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp))
|
||||
|
||||
def onNotification(self, notif_bar):
|
||||
"""Called when a new notification has been received"""
|
||||
if not isinstance(self.main_widget, PrimitivusTopWidget):
|
||||
|
|
@ -594,43 +601,8 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
else:
|
||||
self.main_widget.show('notif_bar')
|
||||
|
||||
def launchAction(self, callback_id, data=None, callback=None, profile=C.PROF_KEY_NONE):
|
||||
""" Launch a dynamic action
|
||||
@param callback_id: id of the action to launch
|
||||
@param data: data needed only for certain actions
|
||||
@param callback: if not None and 'validated' key is present, it will be called with the following parameters:
|
||||
- callback_id
|
||||
- data
|
||||
- profile
|
||||
@param profile: %(doc_profile)s
|
||||
|
||||
"""
|
||||
if data is None:
|
||||
data = dict()
|
||||
|
||||
def action_cb(data):
|
||||
if not data:
|
||||
# action was a one shot, nothing to do
|
||||
pass
|
||||
elif "xmlui" in data:
|
||||
ui = xmlui.create(self, xml_data=data['xmlui'], callback=callback, profile=profile)
|
||||
ui.show()
|
||||
elif 'validated' in data:
|
||||
pass # this key is managed below
|
||||
else:
|
||||
self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp))
|
||||
|
||||
if callback and 'validated' in data:
|
||||
callback(callback_id, data, profile)
|
||||
|
||||
self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.showFailure)
|
||||
|
||||
def showFailure(self, failure):
|
||||
"""Show a failure that has been returned by an asynchronous bridge method.
|
||||
|
||||
@param failure (defer.Failure): Failure instance
|
||||
"""
|
||||
self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp))
|
||||
def _actionManagerUnknownError(self):
|
||||
self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action"), ok_cb=self.removePopUp))
|
||||
|
||||
def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
|
||||
answer_data = {}
|
||||
|
|
@ -715,7 +687,7 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
def onJoinRoom(self, button, edit):
|
||||
self.removePopUp()
|
||||
room_jid = jid.JID(edit.get_edit_text())
|
||||
self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.showFailure)
|
||||
self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self._notifyFailure)
|
||||
|
||||
#MENU EVENTS#
|
||||
def onConnectRequest(self, menu):
|
||||
|
|
|
|||
Loading…
Reference in a new issue