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
|
/**
* @file
* Implementation of class HBPreferencesController.
*/
#import "HBPreferencesController.h"
/**
* This class controls the preferences window of HandBrake. Default values for
* all preferences and user defaults are specified in class method
* @c registerUserDefaults. The preferences window is loaded from
* Preferences.nib file when HBPreferencesController is initialized.
*
* All preferences are bound to user defaults in Interface Builder, therefore
* no getter/setter code is needed in this file (unless more complicated
* preference settings are added that cannot be handled with Cocoa bindings).
*/
@implementation HBPreferencesController
/**
* Registers default values to user defaults. This is called immediately
* when HandBrake starts, from [HBController init].
*/
+ (void)registerUserDefaults
{
NSString *desktopDirectory = [@"~/Desktop" stringByExpandingTildeInPath];
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
@"YES", @"CheckForUpdates",
@"English", @"DefaultLanguage",
@"NO", @"DefaultMpegName",
@"YES", @"DefaultCrf",
@"NO", @"DefaultDeinterlaceOn",
@"YES", @"DefaultPicSizeAutoiPod",
@"NO", @"PixelRatio",
@"", @"DefAdvancedx264Flags",
@"YES", @"DefaultPresetsDrawerShow",
desktopDirectory, @"LastDestinationDirectory",
desktopDirectory, @"LastSourceDirectory",
@"NO", @"DefaultAutoNaming",
@"NO", @"DefaultChapterMarkers",
@"NO", @"ShowVerboseOutput",
nil]];
}
/**
* Initializes the preferences controller by loading Preferences.nib file.
*/
- (id)init
{
if (self = [super initWithWindowNibName:@"Preferences"])
{
NSAssert([self window], @"[HBPreferencesController init] window outlet is not connected in Preferences.nib");
}
return self;
}
/**
* Shows the preferences window in modal state.
*/
- (IBAction)runModal:(id)sender
{
[NSApp runModalForWindow:[self window]];
}
/**
* Closes the window and stops modal state. Any changes made in field editor
* are saved by [NSWindow endEditingFor:] before closing the window.
*/
- (IBAction)close:(id)sender
{
[[self window] endEditingFor:nil];
[[self window] orderOut:sender];
[NSApp stopModal];
}
@end
|