-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathAboutWindowController.m
98 lines (79 loc) · 2.41 KB
/
AboutWindowController.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// file: AboutWindowController.m
// project: lulu (config)
// description: about window display/controller
//
// created by Patrick Wardle
// copyright (c) 2018 Objective-See. All rights reserved.
//
#import "Consts.h"
#import "Utilities.h"
#import "AboutWindowController.h"
@implementation AboutWindowController
@synthesize patrons;
@synthesize supportUs;
@synthesize versionLabel;
//automatically called when nib is loaded
// center window
-(void)awakeFromNib
{
//center
[self.window center];
}
//automatically invoked when window is loaded
// set to white
-(void)windowDidLoad
{
//super
[super windowDidLoad];
//not in dark mode?
// make window white
if(YES != isDarkMode())
{
//make white
self.window.backgroundColor = NSColor.whiteColor;
}
//set version sting
self.versionLabel.stringValue = [NSString stringWithFormat:@"Version: %@", getAppVersion()];
//load patrons
self.patrons.string = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"patrons" ofType:@"txt"] encoding:NSUTF8StringEncoding error:NULL];
//make 'support us' default
[self.supportUs setKeyEquivalent:@"\r"];
//make first responder
// calling this without a timeout sometimes fails :/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (100 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
//and make it first responder
[self.window makeFirstResponder:self.supportUs];
});
return;
}
//automatically invoked when window is closing
// make ourselves unmodal
-(void)windowWillClose:(NSNotification *)notification
{
#pragma unused(notification)
//make un-modal
[[NSApplication sharedApplication] stopModal];
return;
}
//automatically invoked when user clicks any of the buttons
// load patreon or products webpage in user's default browser
-(IBAction)buttonHandler:(id)sender
{
//support us button
if(((NSButton*)sender).tag == BUTTON_SUPPORT_US)
{
//open URL
// invokes user's default browser
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:PATREON_URL]];
}
//more info button
else if(((NSButton*)sender).tag == BUTTON_MORE_INFO)
{
//open URL
// invokes user's default browser
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:PRODUCT_URL]];
}
return;
}
@end