comparison src/tools/xml_tools.py @ 1521:d2ab9c62ac3a

core (xmlui): deferDialog can now manage additional dialog options through the "options" argument
author Goffi <goffi@goffi.org>
date Fri, 25 Sep 2015 19:19:12 +0200
parents 84250128e425
children 94cd4d242dc5
comparison
equal deleted inserted replaced
1520:9667103a0c10 1521:d2ab9c62ac3a
1054 - C.XMLUI_DATA_LVL_WARNING: attention of user is important 1054 - C.XMLUI_DATA_LVL_WARNING: attention of user is important
1055 - C.XMLUI_DATA_LVL_ERROR: something went wrong 1055 - C.XMLUI_DATA_LVL_ERROR: something went wrong
1056 - C.XMLUI_DATA_BTNS_SET: one of: 1056 - C.XMLUI_DATA_BTNS_SET: one of:
1057 - C.XMLUI_DATA_BTNS_SET_OKCANCEL (default): classical "OK" and "Cancel" set 1057 - C.XMLUI_DATA_BTNS_SET_OKCANCEL (default): classical "OK" and "Cancel" set
1058 - C.XMLUI_DATA_BTNS_SET_YESNO: a translated "yes" for OK, and "no" for Cancel 1058 - C.XMLUI_DATA_BTNS_SET_YESNO: a translated "yes" for OK, and "no" for Cancel
1059 - C.XMLUI_DATA_FILETYPE: only used for file dialogs, one of:
1060 - C.XMLUI_DATA_FILETYPE_FILE: a file path is requested
1061 - C.XMLUI_DATA_FILETYPE_DIR: a dir path is requested
1062 - C.XMLUI_DATA_FILETYPE_DEFAULT: same as C.XMLUI_DATA_FILETYPE_FILE
1063
1059 @param title: title or default if None 1064 @param title: title or default if None
1060 @param submit_id: callback id to call for panel_type we can submit (form, param, dialog) 1065 @param submit_id: callback id to call for panel_type we can submit (form, param, dialog)
1061 @param session_id: use to keep a session attached to the dialog, must be returned by frontends 1066 @param session_id: use to keep a session attached to the dialog, must be returned by frontends
1062 """ 1067 """
1063 self._introspect() 1068 self._introspect()
1257 1262
1258 xmlui.submit_id = host.registerCallback(onSubmit, with_data=True, one_shot=True) 1263 xmlui.submit_id = host.registerCallback(onSubmit, with_data=True, one_shot=True)
1259 host.actionNew({'xmlui': xmlui.toXml()}, profile) 1264 host.actionNew({'xmlui': xmlui.toXml()}, profile)
1260 return xmlui_d 1265 return xmlui_d
1261 1266
1262 def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, profile=None): 1267 def deferDialog(host, message, title=u'Please confirm', type_=C.XMLUI_DIALOG_CONFIRM, options=None, profile=None):
1263 """Create a submitable dialog and manage it with a deferred 1268 """Create a submitable dialog and manage it with a deferred
1264 1269
1265 @param message(unicode): message to display 1270 @param message(unicode): message to display
1266 @param title(unicode): title of the dialog 1271 @param title(unicode): title of the dialog
1267 @param type(unicode): dialog type (C.XMLUI_DIALOG_*) 1272 @param type(unicode): dialog type (C.XMLUI_DIALOG_*)
1273 @param options(None, dict): if not None, will be used to update (extend) dialog_opt arguments of XMLUI
1268 @param profile: %(doc_profile)s 1274 @param profile: %(doc_profile)s
1269 @return (dict): Deferred dict 1275 @return (dict): Deferred dict
1270 """ 1276 """
1271 assert profile is not None 1277 assert profile is not None
1272 dialog = XMLUI(C.XMLUI_DIALOG, title=title, dialog_opt = {'type': type_, 'message': message}, submit_id='') 1278 dialog_opt = {'type': type_, 'message': message}
1279 if options is not None:
1280 dialog_opt.update(options)
1281 dialog = XMLUI(C.XMLUI_DIALOG, title=title, dialog_opt=dialog_opt, submit_id='')
1273 return deferXMLUI(host, dialog, profile) 1282 return deferXMLUI(host, dialog, profile)
1274 1283
1275 def deferConfirm(*args, **kwargs): 1284 def deferConfirm(*args, **kwargs):
1276 """call deferDialog and return a boolean instead of the whole data dict""" 1285 """call deferDialog and return a boolean instead of the whole data dict"""
1277 d = deferDialog(*args, **kwargs) 1286 d = deferDialog(*args, **kwargs)