comparison frontends/src/tools/xmlui.py @ 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 <goffi@goffi.org>
date Sun, 21 Aug 2016 12:07:31 +0200
parents 9ad1a06ed0f8
children cbf3af02e941
comparison
equal deleted inserted replaced
2035:5c6db4329288 2036:db3bbbd745e4
202 """Dialog with a OK/Cancel type configuration""" 202 """Dialog with a OK/Cancel type configuration"""
203 pass 203 pass
204 204
205 205
206 class NoteDialog(Dialog): 206 class NoteDialog(Dialog):
207 """Dialog with a OK/Cancel type configuration""" 207 """Short message which doesn't need user confirmation to disappear"""
208 pass 208 pass
209 209
210 210
211 class ConfirmDialog(Dialog): 211 class ConfirmDialog(Dialog):
212 """Dialog with a OK/Cancel type configuration""" 212 """Dialog with a OK/Cancel type configuration"""
235 @param host: %(doc_host)s 235 @param host: %(doc_host)s
236 @param parsed_dom: main parsed dom 236 @param parsed_dom: main parsed dom
237 @param title: force the title, or use XMLUI one if None 237 @param title: force the title, or use XMLUI one if None
238 @param flags: list of string which can be: 238 @param flags: list of string which can be:
239 - NO_CANCEL: the UI can't be cancelled 239 - NO_CANCEL: the UI can't be cancelled
240 - FROM_BACKEND: the UI come from backend (i.e. it's not the direct result of user operation)
240 @param callback(callable, None): if not None, will be used with launchAction: 241 @param callback(callable, None): if not None, will be used with launchAction:
241 - if None is used, default behaviour will be used (closing the dialog and calling host.actionManager) 242 - if None is used, default behaviour will be used (closing the dialog and calling host.actionManager)
242 - if a callback is provided, it will be used instead, so you'll have to manage 243 - if a callback is provided, it will be used instead, so you'll have to manage
243 dialog closing or new xmlui to display, or other action (you can call host.actionManager) 244 dialog closing or new xmlui to display, or other action (you can call host.actionManager)
244 """ 245 """
250 if flags is None: 251 if flags is None:
251 flags = [] 252 flags = []
252 self.flags = flags 253 self.flags = flags
253 self.callback = callback or self._defaultCb 254 self.callback = callback or self._defaultCb
254 self.profile = profile 255 self.profile = profile
256
257 @property
258 def user_action(self):
259 return "FROM_BACKEND" not in self.flags
255 260
256 def _defaultCb(self, data, cb_id, profile): 261 def _defaultCb(self, data, cb_id, profile):
257 # TODO: when XMLUI updates will be managed, the _xmluiClose 262 # TODO: when XMLUI updates will be managed, the _xmluiClose
258 # must be called only if there is not update 263 # must be called only if there is not update
259 self._xmluiClose() 264 self._xmluiClose()