From 5c6634c807c193e06a0bf78171032a35cfa57cbd Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Thu, 13 Jan 2000 16:26:35 +0000 Subject: [PATCH] - Actually _implemented_ SetFolder() - Fixed StandardPutFile: prompt, default - Check explicitly for userCanceledErr, pass other Nav.error exceptions through. --- Mac/Lib/macfsn.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Mac/Lib/macfsn.py b/Mac/Lib/macfsn.py index dcff677fceb..c78459d3767 100644 --- a/Mac/Lib/macfsn.py +++ b/Mac/Lib/macfsn.py @@ -35,10 +35,14 @@ def _PromptGetFile(prompt, *typelist): args['preferenceKey'] = 'PyMC' if _movablemodal: args['eventProc'] = None + args['dialogOptionFlags'] = flags + _handleSetFolder(args) try: rr = Nav.NavChooseFile(args) good = 1 except Nav.error, arg: + if arg[0] != -128: # userCancelledErr + raise Nav.error, arg good = 0 fss = macfs.FSSpec(':cancelled') else: @@ -49,16 +53,22 @@ def _PromptGetFile(prompt, *typelist): def _StandardPutFile(prompt, default=None): args = {} - flags = 0x57 + flags = 0x07 if prompt: args['message'] = prompt args['preferenceKey'] = 'PyMC' if _movablemodal: args['eventProc'] = None + if default: + args['savedFileName'] = default + args['dialogOptionFlags'] = flags + _handleSetFolder(args) try: rr = Nav.NavPutFile(args) good = 1 except Nav.error, arg: + if arg[0] != -128: # userCancelledErr + raise Nav.error, arg good = 0 fss = macfs.FSSpec(':cancelled') else: @@ -70,22 +80,36 @@ def _SetFolder(folder): if _curfolder: rv = _curfolder else: - _curfolder = macfs.FSSpec(":") + rv = None _curfolder = macfs.FSSpec(folder) return rv +def _handleSetFolder(args): + global _curfolder + if not _curfolder: + return + import aepack + fss = macfs.FSSpec(_curfolder) + aedesc = aepack.pack(fss) + args['defaultLocation'] = aedesc + _curfolder = None + def _GetDirectory(prompt=None): args = {} - flags = 0x57 + flags = 0x17 if prompt: args['message'] = prompt args['preferenceKey'] = 'PyMC' if _movablemodal: args['eventProc'] = None + args['dialogOptionFlags'] = flags + _handleSetFolder(args) try: rr = Nav.NavChooseFolder(args) good = 1 except Nav.error, arg: + if arg[0] != -128: # userCancelledErr + raise Nav.error, arg good = 0 fss = macfs.FSSpec(':cancelled') else: