new Mac file-dialog support only for 10.5 and up

svn: r12652
This commit is contained in:
Matthew Flatt 2008-11-30 18:26:25 +00:00
parent 67f29daee5
commit 3b89976e37

View File

@ -6,38 +6,46 @@
void wx_set_nav_file_types(NavDialogRef dlg, int cnt, char **exts, char *def_ext) void wx_set_nav_file_types(NavDialogRef dlg, int cnt, char **exts, char *def_ext)
{ {
if (cnt) { SInt32 versionMajor, versionMinor;
id pool = [[NSAutoreleasePool alloc] init];
id *objs;
int i, j, allow_others = 0;
NSArray *a;
NSSavePanel *sp = (NSSavePanel *)dlg;
for (i = 0; i < cnt; i++) { Gestalt(gestaltSystemVersionMajor, &versionMajor);
if (!strcmp(exts[i], "*")) Gestalt(gestaltSystemVersionMinor, &versionMinor);
allow_others = 1;
} if ((versionMajor >= 10)
&& (versionMinor >= 5)) {
objs = (id *)malloc(sizeof(id) * (1 + (cnt - allow_others))); if (cnt) {
j = 0; id pool = [[NSAutoreleasePool alloc] init];
objs[j++] = [[NSString alloc] initWithUTF8String: def_ext]; id *objs;
for (i = 0; i < cnt; i++) { int i, j, allow_others = 0;
if (strcmp(exts[i], "*")) NSArray *a;
objs[j++] = [[NSString alloc] initWithUTF8String: exts[i]]; NSSavePanel *sp = (NSSavePanel *)dlg;
}
a = [NSArray arrayWithObjects:objs count:j];
[sp setAllowedFileTypes:a]; for (i = 0; i < cnt; i++) {
[sp setCanSelectHiddenExtension:TRUE]; if (!strcmp(exts[i], "*"))
if (!allow_others) allow_others = 1;
[sp setAllowsOtherFileTypes:FALSE]; }
for (i = 0; i < j; i++) { objs = (id *)malloc(sizeof(id) * (1 + (cnt - allow_others)));
[objs[i] release]; j = 0;
} objs[j++] = [[NSString alloc] initWithUTF8String: def_ext];
free(objs); for (i = 0; i < cnt; i++) {
if (strcmp(exts[i], "*"))
objs[j++] = [[NSString alloc] initWithUTF8String: exts[i]];
}
a = [NSArray arrayWithObjects:objs count:j];
[pool release]; [sp setAllowedFileTypes:a];
[sp setCanSelectHiddenExtension:TRUE];
if (!allow_others)
[sp setAllowsOtherFileTypes:FALSE];
for (i = 0; i < j; i++) {
[objs[i] release];
}
free(objs);
[pool release];
}
} }
} }