comparison frontends/src/wix/main_window.py @ 759:93bd868b8fb6

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
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 15:19:08 +0100
parents e3ad48a2aab2
children bfabeedbf32e
comparison
equal deleted inserted replaced
758:86224a13cc1d 759:93bd868b8fb6
235 pass 235 pass
236 else: 236 else:
237 self.SetStatusText(Const.msgOFFLINE) 237 self.SetStatusText(Const.msgOFFLINE)
238 self.tools.Disable() 238 self.tools.Disable()
239 return 239 return
240
241 def launchAction(self, callback_id, data=None, profile_key="@NONE@"):
242 """ Launch a dynamic action
243 @param callback_id: id of the action to launch
244 @param data: data needed only for certain actions
245 @param profile_key: %(doc_profile_key)s
246
247 """
248 if data is None:
249 data = dict()
250 def action_cb(data):
251 if not data:
252 # action was a one shot, nothing to do
253 pass
254 elif "xmlui" in data:
255 debug (_("XML user interface received"))
256 XMLUI(self, xml_data = data['xmlui'])
257 else:
258 dlg = wx.MessageDialog(self, _(u"Unmanaged action result"),
259 _('Error'),
260 wx.OK | wx.ICON_ERROR
261 )
262 dlg.ShowModal()
263 dlg.Destroy()
264 def action_eb(failure):
265 dlg = wx.MessageDialog(self, unicode(failure),
266 _('Error'),
267 wx.OK | wx.ICON_ERROR
268 )
269 dlg.ShowModal()
270 dlg.Destroy()
271
272 self.bridge.launchAction(callback_id, data, profile_key, callback=action_cb, errback=action_eb)
240 273
241 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): 274 def askConfirmation(self, confirmation_id, confirmation_type, data, profile):
242 #TODO: refactor this in QuickApp 275 #TODO: refactor this in QuickApp
243 if not self.check_profile(profile): 276 if not self.check_profile(profile):
244 return 277 return