1999-12-20 14:59:05 +00:00
|
|
|
/* GormTest.m
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
|
|
|
|
* Date: 1999
|
|
|
|
*
|
|
|
|
* This file is part of GNUstep.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-12-24 02:50:34 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
1999-12-20 14:59:05 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
|
|
|
|
@interface Controller: NSObject
|
|
|
|
{
|
|
|
|
}
|
|
|
|
- (id)open: (id) sender;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Controller
|
|
|
|
|
|
|
|
- (id) open: (id)sender
|
|
|
|
{
|
2003-12-24 02:50:34 +00:00
|
|
|
NSArray *fileTypes = [NSArray arrayWithObjects: @"gorm", nil];
|
1999-12-20 14:59:05 +00:00
|
|
|
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
|
1999-12-22 12:50:11 +00:00
|
|
|
id oldDelegate = [NSApp delegate];
|
1999-12-20 14:59:05 +00:00
|
|
|
int result;
|
2003-12-24 02:50:34 +00:00
|
|
|
|
1999-12-20 14:59:05 +00:00
|
|
|
[oPanel setAllowsMultipleSelection: NO];
|
|
|
|
[oPanel setCanChooseFiles: YES];
|
|
|
|
[oPanel setCanChooseDirectories: NO];
|
|
|
|
result = [oPanel runModalForDirectory: NSHomeDirectory()
|
|
|
|
file: nil
|
|
|
|
types: fileTypes];
|
|
|
|
if (result == NSOKButton)
|
|
|
|
{
|
|
|
|
[NSBundle loadNibFile: [oPanel filename]
|
2003-12-24 02:50:34 +00:00
|
|
|
externalNameTable:
|
|
|
|
[NSDictionary dictionaryWithObject: NSApp forKey: @"NSOwner"]
|
|
|
|
withZone: NSDefaultMallocZone()];
|
1999-12-22 12:50:11 +00:00
|
|
|
if ([NSApp delegate] == oldDelegate)
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(NULL,
|
2003-12-24 02:50:34 +00:00
|
|
|
[NSString stringWithFormat: @"Nib did not set app delegate"],
|
|
|
|
@"OK", NULL, NULL);
|
1999-12-22 12:50:11 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
if ([[NSApp delegate] isKindOfClass: [NSWindow class]] == NO)
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(NULL,
|
2003-12-24 02:50:34 +00:00
|
|
|
[NSString stringWithFormat:
|
|
|
|
@"Nib set app delegate to something other than a window"],
|
|
|
|
@"OK", NULL, NULL);
|
1999-12-22 12:50:11 +00:00
|
|
|
return nil;
|
|
|
|
}
|
1999-12-20 14:59:05 +00:00
|
|
|
[[NSApp delegate] makeKeyAndOrderFront: self];
|
|
|
|
return self;
|
|
|
|
}
|
2003-12-24 02:50:34 +00:00
|
|
|
return nil; /* Failed */
|
1999-12-20 14:59:05 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
int
|
2003-12-24 02:50:34 +00:00
|
|
|
main(int argc, const char **argv)
|
1999-12-20 14:59:05 +00:00
|
|
|
{
|
2003-12-24 02:50:34 +00:00
|
|
|
return NSApplicationMain(argc, argv);
|
1999-12-20 14:59:05 +00:00
|
|
|
}
|