frontends (xmlui): added a user_action attribute:

this attribute indicate if the data is a result of a user interaction or an event from the backend (in the later case, the frontend can choose to avoid interrupting the user).
Internally (in XMLUI), "FROM_BACKEND" is added to XMLUI.flags if the UI result from a backend event.
This commit is contained in:
Goffi 2016-08-21 12:07:31 +02:00
commit 0c83d13b7c

View file

@ -790,19 +790,21 @@ class QuickApp(object):
def actionResultHandler(self, type, id, data, profile):
raise NotImplementedError
def actionManager(self, action_data, callback=None, ui_show_cb=None, profile=C.PROF_KEY_NONE):
def actionManager(self, action_data, callback=None, ui_show_cb=None, user_action=True, profile=C.PROF_KEY_NONE):
"""Handle backend action
@param action_data(dict): action dict as sent by launchAction or returned by an UI action
@param callback(None, callback): if not None, callback to use on XMLUI answer
@param ui_show_cb(None, callback): if not None, method to call to show the XMLUI
@param user_action(bool): if True, the action is a result of a user interaction
else the action come from backend direclty (i.e. actionNew)
"""
try:
xmlui = action_data.pop('xmlui')
except KeyError:
pass
else:
ui = self.xmlui.create(self, xml_data=xmlui, callback=callback, profile=profile)
ui = self.xmlui.create(self, xml_data=xmlui, flags=("FROM_BACKEND",) if not user_action else None, callback=callback, profile=profile)
if ui_show_cb is None:
ui.show()
else: