new Mac file-dialog support only for 10.5 and up
svn: r12652
This commit is contained in:
parent
67f29daee5
commit
3b89976e37
|
@ -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)) {
|
||||||
|
if (cnt) {
|
||||||
|
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++) {
|
||||||
|
if (!strcmp(exts[i], "*"))
|
||||||
|
allow_others = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
objs = (id *)malloc(sizeof(id) * (1 + (cnt - allow_others)));
|
||||||
|
j = 0;
|
||||||
|
objs[j++] = [[NSString alloc] initWithUTF8String: def_ext];
|
||||||
|
for (i = 0; i < cnt; i++) {
|
||||||
|
if (strcmp(exts[i], "*"))
|
||||||
|
objs[j++] = [[NSString alloc] initWithUTF8String: exts[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
a = [NSArray arrayWithObjects:objs count:j];
|
||||||
|
|
||||||
|
[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];
|
||||||
}
|
}
|
||||||
|
|
||||||
objs = (id *)malloc(sizeof(id) * (1 + (cnt - allow_others)));
|
|
||||||
j = 0;
|
|
||||||
objs[j++] = [[NSString alloc] initWithUTF8String: def_ext];
|
|
||||||
for (i = 0; i < cnt; i++) {
|
|
||||||
if (strcmp(exts[i], "*"))
|
|
||||||
objs[j++] = [[NSString alloc] initWithUTF8String: exts[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
a = [NSArray arrayWithObjects:objs count:j];
|
|
||||||
|
|
||||||
[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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user