summaryrefslogtreecommitdiffstats
path: root/Mac/OSX/PythonLauncher/MyAppDelegate.m
blob: 107e7d092b6e1675d0b2bad3eb9b68a66c3edcbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import "MyAppDelegate.h"
#import "PreferencesWindowController.h"

@implementation MyAppDelegate

- (id)init
{
    self = [super init];
    initial_action_done = NO;
    should_terminate = NO;
    return self;
}

- (IBAction)showPreferences:(id)sender
{
    [PreferencesWindowController getPreferencesWindow];
}

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
    // If we were opened because of a file drag or doubleclick
    // we've set initial_action_done in shouldShowUI
    // Otherwise we open a preferences dialog.
    if (!initial_action_done) {
        initial_action_done = YES;
        [self showPreferences: self];
    }
}

- (BOOL)shouldShowUI
{
    // if this call comes before applicationDidFinishLaunching: we do not show a UI
    // for the file. Also, we should terminate immedeately after starting the script.
    if (initial_action_done)
        return YES;
    initial_action_done = YES;
    should_terminate = YES;
    return NO;
}

- (BOOL)shouldTerminate
{
    return should_terminate;
}

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
    return NO;
}


- (BOOL)application:(NSApplication *)sender xx_openFile:(NSString *)filename
{
    initial_action_done = YES;
    return YES;
}

- (BOOL)application:(id)sender xx_openFileWithoutUI:(NSString *)filename
{
    initial_action_done = YES;
    return YES;
}

@end