Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 1 | #import "MyAppDelegate.h" |
| 2 | #import "PreferencesWindowController.h" |
Jack Jansen | 0a3d606 | 2002-08-01 15:07:00 +0000 | [diff] [blame] | 3 | #import <Carbon/Carbon.h> |
Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 4 | |
| 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 Jansen | 0a3d606 | 2002-08-01 15:07:00 +0000 | [diff] [blame] | 33 | // 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 Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 37 | initial_action_done = YES; |
Jack Jansen | 0a3d606 | 2002-08-01 15:07:00 +0000 | [diff] [blame] | 38 | if( GetCurrentKeyModifiers() & optionKey ) |
| 39 | return YES; |
Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 40 | 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 Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 53 | @end |