blob: cb9797249db7e5875c9c710852ac7bc56266e819 [file] [log] [blame]
Jack Jansen3bbb6172002-07-29 21:36:35 +00001#import "MyAppDelegate.h"
2#import "PreferencesWindowController.h"
Jack Jansen0a3d6062002-08-01 15:07:00 +00003#import <Carbon/Carbon.h>
Jack Jansen3bbb6172002-07-29 21:36:35 +00004
5@implementation MyAppDelegate
6
7- (id)init
8{
9 self = [super init];
10 initial_action_done = NO;
11 should_terminate = NO;
12 return self;
13}
14
15- (IBAction)showPreferences:(id)sender
16{
17 [PreferencesWindowController getPreferencesWindow];
18}
19
20- (void)applicationDidFinishLaunching:(NSNotification *)notification
21{
22 // If we were opened because of a file drag or doubleclick
23 // we've set initial_action_done in shouldShowUI
24 // Otherwise we open a preferences dialog.
25 if (!initial_action_done) {
26 initial_action_done = YES;
27 [self showPreferences: self];
28 }
29}
30
31- (BOOL)shouldShowUI
32{
Jack Jansen0a3d6062002-08-01 15:07:00 +000033 // if this call comes before applicationDidFinishLaunching: we
34 // should terminate immedeately after starting the script.
35 if (!initial_action_done)
36 should_terminate = YES;
Jack Jansen3bbb6172002-07-29 21:36:35 +000037 initial_action_done = YES;
Jack Jansen0a3d6062002-08-01 15:07:00 +000038 if( GetCurrentKeyModifiers() & optionKey )
39 return YES;
Jack Jansen3bbb6172002-07-29 21:36:35 +000040 return NO;
41}
42
43- (BOOL)shouldTerminate
44{
45 return should_terminate;
46}
47
48- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
49{
50 return NO;
51}
52
Jack Jansen3bbb6172002-07-29 21:36:35 +000053@end