1 ! Copyright (C) 2006, 2008 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel cocoa cocoa.messages cocoa.classes
4 cocoa.application sequences splitting core-foundation
5 core-foundation.strings ;
8 : <NSOpenPanel> ( -- panel )
9 NSOpenPanel -> openPanel
10 dup 1 -> setCanChooseFiles:
11 dup 0 -> setCanChooseDirectories:
12 dup 1 -> setResolvesAliases:
13 dup 1 -> setAllowsMultipleSelection: ;
15 : <NSSavePanel> ( -- panel )
16 NSSavePanel -> savePanel
17 dup 1 -> setCanChooseFiles:
18 dup 0 -> setCanChooseDirectories:
19 dup 0 -> setAllowsMultipleSelection: ;
24 : open-panel ( -- paths )
26 dup -> runModal NSOKButton =
27 [ -> filenames CF>string-array ] [ drop f ] if ;
29 : split-path ( path -- dir file )
30 "/" split1-last [ <NSString> ] bi@ ;
32 : save-panel ( path -- paths )
33 [ <NSSavePanel> dup ] dip
34 split-path -> runModalForDirectory:file: NSOKButton =
35 [ -> filename CF>string ] [ drop f ] if ;