/
FRPreferenceController.m
109 lines (92 loc) · 3.16 KB
/
FRPreferenceController.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
//
// FRPreferenceController.m
// ThreadWatcher
//
// Created by Mr Freeze on 03/01/2010.
// Copyright 2010 Mr. Freeze. All rights reserved.
//
#import "FRPreferenceController.h"
// defaults strings
NSString *const FRAnimatedThumbsKey = @"AnimateThumbnails";
NSString *const FRResaveKey = @"ResaveImages";
NSString *const FRIntervalKey = @"WatchInterval";
NSString *const FRFinderCommentKey = @"WriteFinderComments";
NSString *const FRCommentTagPrefix = @"FinderTagPrefix";
NSString *const FRPostName = @"PostWithName";
NSString *const FRPostEmail = @"PostWithEmail";
NSString *const FRDumpBoard = @"DefaultDumpBoard";
NSString *const FRUserAgent = @"UserAgent";
NSString *const FRLastSaveLocation = @"LastSaveLocation";
NSString *const FRShowCloseWindowAlert = @"ShowCloseWindowAlert";
NSString *const FRShowQuitWindowAlert = @"ShowQuitAlert";
NSString *const FRAutomaticWatching = @"AutomaticThreadWatching";
@implementation FRPreferenceController
- (id)init
{
if (![super initWithWindowNibName:@"Preferences"])
return nil;
return self;
}
- (IBAction)changeResave:(id)sender
{
NSInteger state = [resaveToggleCheckBox state];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:state forKey:FRResaveKey];
}
- (IBAction)changeAnimatedThumbs:(id)sender
{
NSInteger state = [animatedThumbsToggle state];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:state forKey:FRAnimatedThumbsKey];
}
- (IBAction)changeFinderComment:(id)sender
{
NSInteger state = [finderCommentCheckBox state];
if (state == 1)
{
// warn user about problems using spotlight comments
NSInteger result = NSRunAlertPanel(@"Spotlight Comments",
@"Comments will not appear in Get Info windows in the Finder, however they will still be searchable using Spotlight and viewable with other file browsers. See the documentation for more info.",
@"Enable", @"Cancel", nil);
if (result == NSAlertDefaultReturn)
[finderCommentCheckBox setState:YES];
else
[finderCommentCheckBox setState:NO];
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:[finderCommentCheckBox state] forKey:FRFinderCommentKey];
}
- (IBAction)changeAutomatingWatching:(id)sender
{
NSInteger state = [sender state];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:state forKey:FRAutomaticWatching];
}
- (BOOL)animate
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:FRAnimatedThumbsKey];
}
- (BOOL)resave
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:FRResaveKey];
}
- (BOOL)finderComment
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:FRFinderCommentKey];
}
- (BOOL)watching
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:FRAutomaticWatching];
}
- (void)windowDidLoad
{
[resaveToggleCheckBox setState:[self resave]];
[animatedThumbsToggle setState:[self animate]];
[finderCommentCheckBox setState:[self finderComment]];
[automaticWatchingCheckBox setState:[self watching]];
}
@end