Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
4111db01
Unverified
Commit
4111db01
authored
Nov 05, 2025
by
Vincent Koc
Committed by
GitHub
Nov 05, 2025
Browse files
app: fix macOS file picker to support Uniform Type Identifiers (#12965)
parent
80d34260
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
app/dialog/cocoa/dlg.m
app/dialog/cocoa/dlg.m
+17
-4
app/dialog/cocoa/dlg_darwin.go
app/dialog/cocoa/dlg_darwin.go
+1
-1
No files found.
app/dialog/cocoa/dlg.m
View file @
4111db01
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
#include <string.h>
#include <string.h>
#include <sys/syslimits.h>
#include <sys/syslimits.h>
// Import UniformTypeIdentifiers for macOS 11+
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#endif
void
*
NSStr
(
void
*
buf
,
int
len
)
{
void
*
NSStr
(
void
*
buf
,
int
len
)
{
return
(
void
*
)[[
NSString
alloc
]
initWithBytes
:
buf
length
:
len
encoding
:
NSUTF8StringEncoding
];
return
(
void
*
)[[
NSString
alloc
]
initWithBytes
:
buf
length
:
len
encoding
:
NSUTF8StringEncoding
];
}
}
...
@@ -109,12 +114,20 @@ DlgResult fileDlg(FileDlgParams* params) {
...
@@ -109,12 +114,20 @@ DlgResult fileDlg(FileDlgParams* params) {
if
(
self
->
params
->
title
!=
nil
)
{
if
(
self
->
params
->
title
!=
nil
)
{
[
panel
setTitle
:[[
NSString
alloc
]
initWithUTF8String
:
self
->
params
->
title
]];
[
panel
setTitle
:[[
NSString
alloc
]
initWithUTF8String
:
self
->
params
->
title
]];
}
}
#pragma clang diagnostic push
// Use modern allowedContentTypes API for better file type support (especially video files)
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if
(
self
->
params
->
numext
>
0
)
{
if
(
self
->
params
->
numext
>
0
)
{
[
panel
setAllowedFileTypes
:[
NSArray
arrayWithObjects
:(
NSString
**
)
self
->
params
->
exts
count
:
self
->
params
->
numext
]];
NSMutableArray
*
utTypes
=
[
NSMutableArray
arrayWithCapacity
:
self
->
params
->
numext
];
NSString
**
exts
=
(
NSString
**
)
self
->
params
->
exts
;
for
(
int
i
=
0
;
i
<
self
->
params
->
numext
;
i
++
)
{
UTType
*
type
=
[
UTType
typeWithFilenameExtension
:
exts
[
i
]];
if
(
type
)
{
[
utTypes
addObject
:
type
];
}
}
if
([
utTypes
count
]
>
0
)
{
[
panel
setAllowedContentTypes
:
utTypes
];
}
}
}
#pragma clang diagnostic pop
if
(
self
->
params
->
relaxext
)
{
if
(
self
->
params
->
relaxext
)
{
[
panel
setAllowsOtherFileTypes
:
YES
];
[
panel
setAllowsOtherFileTypes
:
YES
];
}
}
...
...
app/dialog/cocoa/dlg_darwin.go
View file @
4111db01
package
cocoa
package
cocoa
// #cgo darwin LDFLAGS: -framework Cocoa
// #cgo darwin LDFLAGS: -framework Cocoa
-framework UniformTypeIdentifiers
// #include <stdlib.h>
// #include <stdlib.h>
// #include <sys/syslimits.h>
// #include <sys/syslimits.h>
// #include "dlg.h"
// #include "dlg.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment