forked from SelfControlApp/selfcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreferencesGeneralViewController.m
63 lines (53 loc) · 1.56 KB
/
PreferencesGeneralViewController.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
//
// PreferencesGeneralViewController.m
// SelfControl
//
// Created by Charles Stigler on 9/27/14.
//
//
#import "PreferencesGeneralViewController.h"
@interface PreferencesGeneralViewController ()
@end
@implementation PreferencesGeneralViewController
- (instancetype)init {
return [super initWithNibName: @"PreferencesGeneralViewController" bundle: nil];
}
- (IBAction)soundSelectionChanged:(id)sender {
// Map the tags used in interface builder to the sound
NSArray* systemSoundNames = @[@"Basso",
@"Blow",
@"Bottle",
@"Frog",
@"Funk",
@"Glass",
@"Hero",
@"Morse",
@"Ping",
@"Pop",
@"Purr",
@"Sosumi",
@"Submarine",
@"Tink"];
NSInteger blockSoundIndex = [[NSUserDefaults standardUserDefaults] integerForKey: @"BlockSound"];
NSSound* alertSound = [NSSound soundNamed: systemSoundNames[blockSoundIndex]];
if(!alertSound) {
NSLog(@"WARNING: Alert sound not found.");
NSError* err = [NSError errorWithDomain: @"SelfControlErrorDomain"
code: -901
userInfo: @{NSLocalizedDescriptionKey: @"Error -901: Selected sound not found."}];
[NSApp presentError: err];
} else {
[alertSound play];
}
}
#pragma mark MASPreferencesViewController
- (NSString*)identifier {
return @"GeneralPreferences";
}
- (NSImage *)toolbarItemImage {
return [NSImage imageNamed: NSImageNamePreferencesGeneral];
}
- (NSString *)toolbarItemLabel {
return NSLocalizedString(@"General", @"Toolbar item name for the General preference pane");
}
@end