3 * Implementation of class HBPreferencesController.
6 #import "HBPreferencesController.h"
9 * This class controls the preferences window of HandBrake. Default values for
10 * all preferences and user defaults are specified in class method
11 * @c registerUserDefaults. The preferences window is loaded from
12 * Preferences.nib file when HBPreferencesController is initialized.
14 * All preferences are bound to user defaults in Interface Builder, therefore
15 * no getter/setter code is needed in this file (unless more complicated
16 * preference settings are added that cannot be handled with Cocoa bindings).
18 @implementation HBPreferencesController
21 * Registers default values to user defaults. This is called immediately
22 * when HandBrake starts, from [HBController init].
24 + (void)registerUserDefaults
26 NSString *desktopDirectory = [@"~/Desktop" stringByExpandingTildeInPath];
28 [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
29 @"YES", @"CheckForUpdates",
30 @"English", @"DefaultLanguage",
31 @"NO", @"DefaultMpegName",
32 @"YES", @"DefaultCrf",
33 @"NO", @"DefaultDeinterlaceOn",
34 @"YES", @"DefaultPicSizeAutoiPod",
36 @"", @"DefAdvancedx264Flags",
37 @"YES", @"DefaultPresetsDrawerShow",
38 desktopDirectory, @"LastDestinationDirectory",
39 desktopDirectory, @"LastSourceDirectory",
40 @"NO", @"DefaultAutoNaming",
41 @"NO", @"DefaultChapterMarkers",
42 @"NO", @"ShowVerboseOutput",
43 @"NO", @"AllowLargeFiles",
44 @"NO", @"DisableDvdAutoDetect",
49 * Initializes the preferences controller by loading Preferences.nib file.
53 if (self = [super initWithWindowNibName:@"Preferences"])
55 NSAssert([self window], @"[HBPreferencesController init] window outlet is not connected in Preferences.nib");
61 * Shows the preferences window in modal state.
63 - (IBAction)runModal:(id)sender
65 [NSApp runModalForWindow:[self window]];
69 * Closes the window and stops modal state. Any changes made in field editor
70 * are saved by [NSWindow endEditingFor:] before closing the window.
72 - (IBAction)close:(id)sender
74 [[self window] endEditingFor:nil];
75 [[self window] orderOut:sender];