]> granicus.if.org Git - python/commitdiff
Added SetFolder method which sets Standard File initial folder
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 22 Jul 1996 15:26:01 +0000 (15:26 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 22 Jul 1996 15:26:01 +0000 (15:26 +0000)
Mac/Modules/macfsmodule.c

index 69725cccc870c795c91f1aa9c8fc96096d4d905f..9bcdf622bce3cd906978527a02003925e3d3b946 100644 (file)
@@ -31,6 +31,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <Folders.h>
 #include <StandardFile.h>
 #include <Aliases.h>
+#include <LowMem.h>
 
 #include "nfullpath.h"
 
@@ -689,6 +690,33 @@ mfs_StandardPutFile(self, args)
        return mkvalue("(Oi)",newmfssobject(&reply.sfFile), reply.sfGood);
 }
 
+/*
+** Set initial directory for file dialogs */
+static object *
+mfs_SetFolder(self, args)
+       object *self;
+       object *args;
+{
+       FSSpec spec;
+       FSSpec ospec;
+       short orefnum;
+       long oparid;
+       
+       /* Get old values */
+       orefnum = -LMGetSFSaveDisk();
+       oparid = LMGetCurDirStore();
+       (void)FSMakeFSSpec(orefnum, oparid, "\pplaceholder", &ospec);
+       
+       /* Go to working directory by default */
+       (void)FSMakeFSSpec(0, 0, "\p:placeholder", &spec);
+       if (!newgetargs(args, "|O&", PyMac_GetFSSpec, &spec))
+               return NULL;
+       /* Set standard-file working directory */
+       LMSetSFSaveDisk(-spec.vRefNum);
+       LMSetCurDirStore(spec.parID);
+       return (object *)newmfssobject(&ospec);
+}
+
 static object *
 mfs_FSSpec(self, args)
        object *self;   /* Not used */
@@ -794,6 +822,7 @@ static struct methodlist mfs_methods[] = {
        {"PromptGetFile",               mfs_PromptGetFile,              1},
        {"StandardPutFile",             mfs_StandardPutFile,    1},
        {"GetDirectory",                mfs_GetDirectory,               1},
+       {"SetFolder",                   mfs_SetFolder,                  1},
        {"FSSpec",                              mfs_FSSpec,                             1},
        {"RawFSSpec",                   mfs_RawFSSpec,                  1},
        {"RawAlias",                    mfs_RawAlias,                   1},