forked from millenomi/afloat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AfloatNag.m
49 lines (40 loc) · 1.31 KB
/
AfloatNag.m
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
//
// AfloatNag.m
// Afloat
//
// Created by ∞ on 29/03/08.
// Copyright 2008 Emanuele Vulcano. All rights reserved.
//
#import "AfloatNag.h"
#import <Carbon/Carbon.h>
#import "NSAlert+L0Alert.h"
#import "AfloatNagPreferences.h"
@implementation AfloatNag
- (void) applicationDidFinishLaunching:(NSNotification*) n {
NSAlert* a = nil; NSInteger donateButton;
switch (AfloatNagCurrentAction()) {
case kAfloatDoNotShowAlerts:
break;
case kAfloatShouldShowFirstAlert:
AfloatNagSetPreferenceForKey(kAfloatFirstAlertShownKey, [NSNumber numberWithBool:YES]);
a = [NSAlert alertNamed:@"AfloatDonateFirstAlert"];
donateButton = NSAlertSecondButtonReturn;
break;
case kAfloatShouldShowLastAlert:
AfloatNagSetPreferenceForKey(kAfloatDidEndAlertsKey, [NSNumber numberWithBool:YES]);
a = [NSAlert alertNamed:@"AfloatDonateLastAlert"];
donateButton = NSAlertFirstButtonReturn;
break;
}
if (a) {
[NSApp activateIgnoringOtherApps:YES];
NSInteger result = [a runModal];
if (result == donateButton) {
AfloatNagSetPreferenceForKey(kAfloatDidEndAlertsKey, [NSNumber numberWithBool:YES]);
NSURL* url = [NSURL URLWithString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"AfloatDonationsURL"]];
[[NSWorkspace sharedWorkspace] openURL:url];
}
}
[NSApp terminate:self];
}
@end