Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 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 |
---|---|
280 return self.menu_roller.checkShortcuts(input) | 280 return self.menu_roller.checkShortcuts(input) |
281 except AttributeError: | 281 except AttributeError: |
282 return input | 282 return input |
283 | 283 |
284 def _dynamicMenuCb(self, xmlui): | 284 def _dynamicMenuCb(self, xmlui): |
285 misc = {} | |
286 ui = XMLUI(self, xml_data = xmlui) | 285 ui = XMLUI(self, xml_data = xmlui) |
287 ui.show('popup') | 286 ui.show('popup') |
288 | 287 |
289 def _dynamicMenuEb(self, failure): | 288 def _dynamicMenuEb(self, failure): |
290 self.showDialog(_(u"Error while calling menu"), type="error") | 289 self.showDialog(_(u"Error while calling menu"), type="error") |
445 error(_("INTERNAL ERROR: Unexpected class for main widget's footer")) | 444 error(_("INTERNAL ERROR: Unexpected class for main widget's footer")) |
446 assert(False) | 445 assert(False) |
447 if self.notBar.canHide(): | 446 if self.notBar.canHide(): |
448 #No notification left, we can hide the bar | 447 #No notification left, we can hide the bar |
449 self.main_widget.footer = self.editBar | 448 self.main_widget.footer = self.editBar |
449 | |
450 def launchAction(self, callback_id, data=None, profile_key="@NONE@"): | |
451 """ Launch a dynamic action | |
452 @param callback_id: id of the action to launch | |
453 @param data: data needed only for certain actions | |
454 @param profile_key: %(doc_profile_key)s | |
455 | |
456 """ | |
457 if data is None: | |
458 data = dict() | |
459 def action_cb(data): | |
460 if not data: | |
461 # action was a one shot, nothing to do | |
462 pass | |
463 elif "xmlui" in data: | |
464 ui = XMLUI(self, xml_data = data['xmlui']) | |
465 ui.show('popup') | |
466 else: | |
467 self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp)) | |
468 def action_eb(failure): | |
469 self.showPopUp(sat_widgets.Alert(_("Error"), unicode(failure), ok_cb=self.removePopUp)) | |
470 | |
471 self.bridge.launchAction(callback_id, data, profile_key, callback=action_cb, errback=action_eb) | |
450 | 472 |
451 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): | 473 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): |
452 if not self.check_profile(profile): | 474 if not self.check_profile(profile): |
453 return | 475 return |
454 answer_data={} | 476 answer_data={} |