forked from radix1980/Mac-Linux-USB-Loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RHNotificationViewController.m
executable file
·73 lines (58 loc) · 2.17 KB
/
RHNotificationViewController.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
//
// RHAboutViewController.m
// RHPreferencesTester
//
// Originally created by Richard Heard on 23/05/12. Subsequently modified by SevenBits.
// Copyright (c) 2012-2013 SevenBits. All rights reserved.
//
#import "RHNotificationViewController.h"
@interface RHNotificationViewController ()
@end
@implementation RHNotificationViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:@"RHNotificationViewController" bundle:nibBundleOrNil];
if (self) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults synchronize];
if ([defaults boolForKey:@"ShowNotifications"] == YES) {
[_displayNotificationsCheckbox setState:NSOnState];
} else {
[_displayNotificationsCheckbox setState:NSOffState];
}
}
return self;
}
- (IBAction)showNotificationCenter:(NSButton*)sender {
NSProcessInfo *pinfo = [NSProcessInfo processInfo];
NSArray *myarr = [[pinfo operatingSystemVersionString] componentsSeparatedByString:@" "];
NSString *version = myarr[1];
// Ensure that we are running 10.8 before we display the preferences as we still support Lion, which does not have
// notifications.
if ([version rangeOfString:@"10.8"].location == NSNotFound) {
[sender setEnabled:NO];
} else {
[[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/Notifications.prefPane"];
}
}
- (IBAction)setShowNotifications:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
#ifdef DEBUG
NSLog(@"Setting show notifications to %@", [defaults valueForKey:@"ShowNotifications"]);
#endif
//[defaults setBool:showNotifications forKey:@"ShowNotifications"];
[defaults synchronize];
}
#pragma mark - RHPreferencesViewControllerProtocol
- (NSString*)identifier {
return NSStringFromClass(self.class);
}
- (NSImage*)toolbarItemImage {
return [NSImage imageNamed:@"Notifications"];
}
- (NSString*)toolbarItemLabel {
return NSLocalizedString(@"Notifications", @"AboutToolbarItemLabel");
}
- (NSView*)initialKeyView{
return nil;
}
@end