changeset 2036:db3bbbd745e4

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.
author Goffi <>
date Sun, 21 Aug 2016 12:07:31 +0200
parents 5c6db4329288
children 0f485f1d627d
files frontends/src/quick_frontend/ frontends/src/tools/
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/	Sun Aug 21 12:03:34 2016 +0200
+++ b/frontends/src/quick_frontend/	Sun Aug 21 12:07:31 2016 +0200
@@ -790,19 +790,21 @@
     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)
             xmlui = action_data.pop('xmlui')
         except KeyError:
-            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:
--- a/frontends/src/tools/	Sun Aug 21 12:03:34 2016 +0200
+++ b/frontends/src/tools/	Sun Aug 21 12:07:31 2016 +0200
@@ -204,7 +204,7 @@
 class NoteDialog(Dialog):
-    """Dialog with a OK/Cancel type configuration"""
+    """Short message which doesn't need user confirmation to disappear"""
@@ -237,6 +237,7 @@
         @param title: force the title, or use XMLUI one if None
         @param flags: list of string which can be:
             - NO_CANCEL: the UI can't be cancelled
+            - FROM_BACKEND: the UI come from backend (i.e. it's not the direct result of user operation)
         @param callback(callable, None): if not None, will be used with launchAction:
             - if None is used, default behaviour will be used (closing the dialog and calling host.actionManager)
             - if a callback is provided, it will be used instead, so you'll have to manage
@@ -253,6 +254,10 @@
         self.callback = callback or self._defaultCb
         self.profile = profile
+    @property
+    def user_action(self):
+        return "FROM_BACKEND" not in self.flags
     def _defaultCb(self, data, cb_id, profile):
         # TODO: when XMLUI updates will be managed, the _xmluiClose
         #       must be called only if there is not update