/* * AppController.m created by phr on 2000-08-27 11:38:58 +0000 * * Project TestApp * * Created with ProjectCenter - http://www.gnustep.org * * $Id: AppController.m,v 1.10.2.1 2003/08/01 15:30:49 probert Exp $ */ #include "AppController.h" #include "ImageWindow.h" #include "ImagesWindow.h" #include "Inspector.h" #include "PrefController.h" @implementation AppController static NSDictionary *infoDict = nil; + (void)initialize { NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; /* * Register your app's defaults here by adding objects to the * dictionary, eg * * [defaults setObject:anObject forKey:keyForThatObject]; * */ [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; [[NSUserDefaults standardUserDefaults] synchronize]; } - (id)init { if ((self = [super init])) { images = [[NSMutableArray alloc] init]; } return self; } - (void)dealloc { RELEASE(images); [super dealloc]; } - (void)applicationDidFinishLaunching:(NSNotification *)notif { } - (BOOL)applicationShouldTerminate:(id)sender { return YES; } - (void)applicationWillTerminate:(NSNotification *)notification { [[NSUserDefaults standardUserDefaults] synchronize]; } - (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName { // [[NSApplication sharedApplication] activateIgnoringOtherApps: NO]; return [self openImageAtPath:fileName]; } - (void)showPrefPanel:(id)sender { if( preferences == nil ) { preferences = [[PrefController alloc] init]; } [preferences show]; } - (void)showInfoPanel:(id)sender { [[NSApplication sharedApplication] orderFrontStandardInfoPanel:sender]; } - (void)showInspector:(id)sender { if( inspector == nil ) { inspector = [Inspector sharedInspector]; } [inspector show]; } - (BOOL)openImageAtPath:(NSString *)path { ImageWindow *win = [[ImageWindow alloc] initWithContentsOfFile:path]; if (win) { [win setDelegate:self]; [images addObject:win]; return YES; } return NO; } - (void)openImage:(id)sender { int result; NSArray *fileTypes = [NSImage imageFileTypes]; NSOpenPanel *openPanel = [NSOpenPanel openPanel]; NSString *pth = [[NSUserDefaults standardUserDefaults] objectForKey:@"OpenDir"]; [openPanel setAllowsMultipleSelection:YES]; result = [openPanel runModalForDirectory:pth file:nil types:fileTypes]; if (result == NSOKButton) { NSArray *files = [openPanel filenames]; int i; int count = [files count]; NSString *_pth = [openPanel directory]; [[NSUserDefaults standardUserDefaults] setObject:_pth forKey:@"OpenDir"]; for (i=0; i