From 3b89976e377248fce12b788b6ec52dfe14e138d4 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 30 Nov 2008 18:26:25 +0000 Subject: [PATCH] new Mac file-dialog support only for 10.5 and up svn: r12652 --- src/wxmac/src/mac/wx_file_dialog.m | 66 +++++++++++++++++------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/src/wxmac/src/mac/wx_file_dialog.m b/src/wxmac/src/mac/wx_file_dialog.m index f398b62fc4..9f7be5da6d 100644 --- a/src/wxmac/src/mac/wx_file_dialog.m +++ b/src/wxmac/src/mac/wx_file_dialog.m @@ -6,38 +6,46 @@ void wx_set_nav_file_types(NavDialogRef dlg, int cnt, char **exts, char *def_ext) { - if (cnt) { - id pool = [[NSAutoreleasePool alloc] init]; - id *objs; - int i, j, allow_others = 0; - NSArray *a; - NSSavePanel *sp = (NSSavePanel *)dlg; + SInt32 versionMajor, versionMinor; - 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]; + Gestalt(gestaltSystemVersionMajor, &versionMajor); + Gestalt(gestaltSystemVersionMinor, &versionMinor); + + 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; - [sp setAllowedFileTypes:a]; - [sp setCanSelectHiddenExtension:TRUE]; - if (!allow_others) - [sp setAllowsOtherFileTypes:FALSE]; + for (i = 0; i < cnt; i++) { + if (!strcmp(exts[i], "*")) + allow_others = 1; + } - for (i = 0; i < j; i++) { - [objs[i] release]; - } - free(objs); + 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]; - [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]; + } } }