forked from gonzoua/AudioBookBinder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PrefsController.m
103 lines (85 loc) · 2.73 KB
/
PrefsController.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
//
// PrefsController.m
// AudioBookBinder
//
// Created by Oleksandr Tymoshenko on 10-03-29.
// Copyright 2010 Bluezbox Software. All rights reserved.
//
#import "PrefsController.h"
#import "Sparkle/SUUpdater.h"
#define DESTINATION_FOLDER 0
#define DESTINATION_ITUNES 2
@implementation PrefsController
- (void) awakeFromNib
{
[_folderPopUp selectItemAtIndex:0];
#ifdef notyet
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[_folderPopUp selectItemAtIndex: [defaults boolForKey: @"DestinationiTunes"] ? DESTINATION_ITUNES : DESTINATION_FOLDER];
#endif
#ifdef APP_STORE_BUILD
[updateLabel setHidden:YES];
[updateButton setHidden:YES];
#else
[updateButton bind:@"value" toObject:[SUUpdater sharedUpdater] withKeyPath:@"automaticallyChecksForUpdates" options:nil];
#endif
}
- (void) folderSheetShow: (id) sender
{
NSOpenPanel * panel = [NSOpenPanel openPanel];
[panel setPrompt: NSLocalizedString(@"Select", "Preferences -> Open panel prompt")];
[panel setAllowsMultipleSelection: NO];
[panel setCanChooseFiles: NO];
[panel setCanChooseDirectories: YES];
[panel setCanCreateDirectories: YES];
[panel beginSheetForDirectory: nil file: nil types: nil
modalForWindow: [self window] modalDelegate: self didEndSelector:
@selector(folderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
}
- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (code == NSOKButton)
{
[_folderPopUp selectItemAtIndex:DESTINATION_FOLDER];
NSString * folder = [[openPanel filenames] objectAtIndex:0];
[defaults setObject:folder forKey: @"DestinationFolder"];
#ifdef notyet
[defaults setBool:NO forKey: @"DestinationiTunes"];
#endif
}
else
{
//reset if cancelled
[_folderPopUp selectItemAtIndex:DESTINATION_FOLDER];
#ifdef notyet
[defaults boolForKey:@"DestinationiTunes"] ? DESTINATION_ITUNES : DESTINATION_FOLDER];
#endif
}
}
- (void) destinationiTunes: (id) sender
{
[[NSUserDefaults standardUserDefaults]
setBool:([_folderPopUp indexOfSelectedItem] == DESTINATION_ITUNES ? YES : NO)
forKey: @"DestinationiTunes"];
}
@end
@implementation VolumeLengthTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
- (id)transformedValue:(id)value {
if (value != nil)
{
NSInteger len = [value intValue];
if (len == 25)
return @"--";
else
return [NSString stringWithFormat:@"%d", len];
}
return @"";
}
@end