This repository has been archived by the owner on Aug 26, 2020. It is now read-only.
/
ISI_SchedulingPrefController.m
130 lines (104 loc) · 2.74 KB
/
ISI_SchedulingPrefController.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//
// ISI_SchedulingPrefController.m
// iSyncIt
//
// See 'LICENSE' for copyright and licensing.
//
#import "ISI_SchedulingPrefController.h"
@implementation ISI_SchedulingPrefController
- (void)awakeFromNib
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"ISI_EnableScheduling"]) {
[pref_Out_SchedulingCombo setEnabled:NO];
enableScheduling = NO;
} else {
[pref_Out_SchedulingCombo setEnabled:YES];
enableScheduling = YES;
}
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"ISI_EnableTimedScheduling"]) {
[pref_Out_SchedulingTime setEnabled:NO];
enableTimedScheduling = NO;
} else {
[pref_Out_SchedulingTime setEnabled:YES];
enableTimedScheduling = YES;
}
}
- (IBAction)pref_Act_ActivateSchedule:(id)sender
{
if (!enableScheduling) {
[pref_Out_SchedulingCombo setEnabled:YES];
enableScheduling = YES;
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"ISI_SchedulingSettings"] == nil) {
[[NSUserDefaults standardUserDefaults] setObject:@"15" forKey:@"ISI_SchedulingSettings"];
}
[[NSUserDefaults standardUserDefaults] synchronize];
} else {
[pref_Out_SchedulingCombo setEnabled:NO];
enableScheduling = NO;
}
}
- (IBAction)pref_Act_ActivateTimedSchedule:(id)sender
{
if (!enableTimedScheduling) {
[pref_Out_SchedulingTime setEnabled:YES];
enableTimedScheduling = YES;
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"ISI_TimedSchedulingSettings"] == nil) {
// Code to set the user default for time if it doesn't exist.
}
[[NSUserDefaults standardUserDefaults] synchronize];
} else {
[pref_Out_SchedulingTime setEnabled:NO];
enableTimedScheduling = NO;
}
}
- (IBAction)pref_Act_ChangeSchedule:(id)sender
{
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (IBAction)pref_Act_ChangeTimedSchedule:(id)sender
{
[[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSArray *)preferencePanes
{
return [NSArray arrayWithObjects:[[[ISI_SchedulingPrefController alloc] init] autorelease], nil];
}
- (NSView *)paneView
{
BOOL loaded = YES;
if (!prefsView) {
loaded = [NSBundle loadNibNamed:@"ISI_SchedulingView" owner:self];
}
if (loaded) {
return prefsView;
}
return nil;
}
- (NSString *)paneName
{
return @"Scheduling";
}
- (NSImage *)paneIcon
{
return [[[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"ISI_Scheduling"]] autorelease];
}
- (NSString *)paneToolTip
{
return @"Scheduling Preferences";
}
- (BOOL)allowsHorizontalResizing
{
return NO;
}
- (BOOL)allowsVerticalResizing
{
return NO;
}
- (void)dealloc
{
[pref_Out_SchedulingCombo release];
[pref_Out_SchedulingTime release];
[prefsView release];
[super dealloc];
}
@end