backend, frontends: callbacks refactoring:

- launchAction is now async, and return a dictionary for its result
    - no more action_id, actionResult* are deprecated
    - callback system is about to be unified
This commit is contained in:
Goffi 2013-12-24 15:19:08 +01:00
commit 069a250b04

View file

@ -238,6 +238,39 @@ class MainWindow(wx.Frame, QuickApp):
self.tools.Disable()
return
def launchAction(self, callback_id, data=None, profile_key="@NONE@"):
""" Launch a dynamic action
@param callback_id: id of the action to launch
@param data: data needed only for certain actions
@param profile_key: %(doc_profile_key)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:
debug (_("XML user interface received"))
XMLUI(self, xml_data = data['xmlui'])
else:
dlg = wx.MessageDialog(self, _(u"Unmanaged action result"),
_('Error'),
wx.OK | wx.ICON_ERROR
)
dlg.ShowModal()
dlg.Destroy()
def action_eb(failure):
dlg = wx.MessageDialog(self, unicode(failure),
_('Error'),
wx.OK | wx.ICON_ERROR
)
dlg.ShowModal()
dlg.Destroy()
self.bridge.launchAction(callback_id, data, profile_key, callback=action_cb, errback=action_eb)
def askConfirmation(self, confirmation_id, confirmation_type, data, profile):
#TODO: refactor this in QuickApp
if not self.check_profile(profile):