Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 1 | #import "MyAppDelegate.h" |
| 2 | #import "PreferencesWindowController.h" |
| 3 | |
| 4 | @implementation MyAppDelegate |
| 5 | |
| 6 | - (id)init |
| 7 | { |
| 8 | self = [super init]; |
| 9 | initial_action_done = NO; |
| 10 | should_terminate = NO; |
| 11 | return self; |
| 12 | } |
| 13 | |
| 14 | - (IBAction)showPreferences:(id)sender |
| 15 | { |
| 16 | [PreferencesWindowController getPreferencesWindow]; |
| 17 | } |
| 18 | |
| 19 | - (void)applicationDidFinishLaunching:(NSNotification *)notification |
| 20 | { |
| 21 | // If we were opened because of a file drag or doubleclick |
| 22 | // we've set initial_action_done in shouldShowUI |
| 23 | // Otherwise we open a preferences dialog. |
| 24 | if (!initial_action_done) { |
| 25 | initial_action_done = YES; |
| 26 | [self showPreferences: self]; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | - (BOOL)shouldShowUI |
| 31 | { |
| 32 | // if this call comes before applicationDidFinishLaunching: we do not show a UI |
| 33 | // for the file. Also, we should terminate immedeately after starting the script. |
| 34 | if (initial_action_done) |
| 35 | return YES; |
| 36 | initial_action_done = YES; |
| 37 | should_terminate = YES; |
| 38 | return NO; |
| 39 | } |
| 40 | |
| 41 | - (BOOL)shouldTerminate |
| 42 | { |
| 43 | return should_terminate; |
| 44 | } |
| 45 | |
| 46 | - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender |
| 47 | { |
| 48 | return NO; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | - (BOOL)application:(NSApplication *)sender xx_openFile:(NSString *)filename |
| 53 | { |
| 54 | initial_action_done = YES; |
| 55 | return YES; |
| 56 | } |
| 57 | |
| 58 | - (BOOL)application:(id)sender xx_openFileWithoutUI:(NSString *)filename |
| 59 | { |
| 60 | initial_action_done = YES; |
| 61 | return YES; |
| 62 | } |
| 63 | |
| 64 | @end |