Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cocoa/dlg.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <Cocoa/Cocoa.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#include "dlg.h"

void* NSStr(void* buf, int len) {
Expand Down Expand Up @@ -93,7 +94,15 @@ - (NSInteger)runPanel:(NSSavePanel*)panel {
[panel setTitle:[[NSString alloc] initWithUTF8String:self->params->title]];
}
if(self->params->numext > 0) {
[panel setAllowedFileTypes:[NSArray arrayWithObjects:(NSString**)self->params->exts count:self->params->numext]];
NSString** exts = (NSString**)self->params->exts;
NSMutableArray *types = [NSMutableArray array];

for (int i=0; i<self->params->numext; i++) {
NSString* ext = exts[i];
UTType *t = [UTType typeWithFilenameExtension: exts[i]];
[types addObject: t];
}
[panel setAllowedContentTypes:types];
}
if(self->params->relaxext) {
[panel setAllowsOtherFileTypes:YES];
Expand Down
2 changes: 1 addition & 1 deletion cocoa/dlg_darwin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cocoa

// #cgo darwin LDFLAGS: -framework Cocoa
// #cgo darwin LDFLAGS: -framework Cocoa -framework UniformTypeIdentifiers
// #include <stdlib.h>
// #include <sys/syslimits.h>
// #include "dlg.h"
Expand Down