16 #include "cocoa_gui_p.h"
20 #include <gwenhywfar/inherit.h>
21 #include <gwenhywfar/debug.h>
22 #include <gwenhywfar/gui_be.h>
23 #include <gwenhywfar/i18n.h>
25 #include <gwenhywfar/text.h>
26 #include <gwenhywfar/mdigest.h>
27 #include <gwenhywfar/debug.h>
33 #define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
106 NSLog(
@"OpenDialog Setup");
115 NSLog(
@"OpenDialog GetMainWidget");
124 NSLog(
@"OpenDialog EmitSignalToAll");
128 [g makeKeyAndOrderFront:nil];
182 const char *patterns,
203 NSString *title = nil;
204 if (caption && *caption)
205 title = [[[NSString alloc] initWithCString:caption encoding:NSUTF8StringEncoding] autorelease];
207 NSOpenPanel *openPanel = [NSOpenPanel openPanel];
209 if (title) [openPanel setTitle:title];
210 [openPanel setAllowsMultipleSelection:NO];
211 [openPanel setCanChooseFiles:(fnt == GWEN_Gui_FileNameType_OpenFileName)];
212 [openPanel setCanChooseDirectories:(fnt == GWEN_Gui_FileNameType_OpenDirectory)];
214 NSString *pathToFolder = nil;
216 if (fileName && *fileName)
217 pathToFolder = [[[NSString alloc] initWithCString:fileName encoding:NSUTF8StringEncoding] autorelease];
220 [openPanel setDirectory:pathToFolder];
222 NSInteger result = [openPanel runModal];
223 if (result == NSFileHandlingPanelOKButton) {
224 NSArray *urls = [openPanel URLs];
225 if (urls && [urls count] > 0) {
226 NSString *path = [[(NSURL*)[urls objectAtIndex:0] path] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
227 if (path && [path length]>0) {
228 const char *filename = [path cStringUsingEncoding:NSUTF8StringEncoding];
242 NSString *title = nil;
243 if (caption && *caption)
244 title = [[[NSString alloc] initWithCString:caption encoding:NSUTF8StringEncoding] autorelease];
246 NSSavePanel *savePanel = [NSSavePanel savePanel];
248 if (title) [savePanel setTitle:title];
249 [savePanel setCanCreateDirectories:YES];
251 NSString *pathToFolder = nil;
253 if (fileName && *fileName)
254 pathToFolder = [[[NSString alloc] initWithCString:fileName encoding:NSUTF8StringEncoding] autorelease];
257 [savePanel setDirectory:pathToFolder];
259 NSInteger result = [savePanel runModal];
260 if (result == NSFileHandlingPanelOKButton) {
261 NSURL *url = [savePanel URL];
263 NSString *path = [[url path] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
264 if (path && [path length]>0) {
265 const char *filename = [path cStringUsingEncoding:NSUTF8StringEncoding];