OSDN Git Service

2bb38bfc0fb3c877c1169b83a5746512cd4005a7
[handbrake-jp/handbrake-jp-git.git] / macosx / HBPreferencesController.m
1 /**
2  * @file
3  * Implementation of class HBPreferencesController.
4  */
5
6 #import "HBPreferencesController.h"
7
8 /**
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.
13  *
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).
17  */
18 @implementation HBPreferencesController
19
20 /**
21  * Registers default values to user defaults. This is called immediately
22  * when HandBrake starts, from [HBController init].
23  */
24 + (void)registerUserDefaults
25 {
26     NSString *desktopDirectory =  [@"~/Desktop" stringByExpandingTildeInPath];
27     
28     [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
29         @"YES",             @"CheckForUpdates",
30         @"English",         @"DefaultLanguage",
31         @"NO",              @"DefaultMpegName",
32         @"YES",             @"DefaultCrf",
33         @"NO",              @"DefaultDeinterlaceOn",
34         @"YES",             @"DefaultPicSizeAutoiPod",
35         @"NO",              @"PixelRatio",
36         @"",                @"DefAdvancedx264Flags",
37         @"YES",             @"DefaultPresetsDrawerShow",
38         desktopDirectory,   @"LastDestinationDirectory",
39         desktopDirectory,   @"LastSourceDirectory",
40         @"NO",              @"DefaultAutoNaming",
41         @"NO",              @"DefaultChapterMarkers",
42         @"NO",              @"ShowVerboseOutput",
43                 @"NO",              @"AllowLargeFiles",
44         nil]];
45 }
46
47 /**
48  * Initializes the preferences controller by loading Preferences.nib file.
49  */
50 - (id)init
51 {
52     if (self = [super initWithWindowNibName:@"Preferences"])
53     {
54         NSAssert([self window], @"[HBPreferencesController init] window outlet is not connected in Preferences.nib");
55     }
56     return self; 
57 }
58
59 /**
60  * Shows the preferences window in modal state.
61  */
62 - (IBAction)runModal:(id)sender
63 {
64     [NSApp runModalForWindow:[self window]];
65 }
66
67 /**
68  * Closes the window and stops modal state. Any changes made in field editor
69  * are saved by [NSWindow endEditingFor:] before closing the window.
70  */
71 - (IBAction)close:(id)sender
72 {
73     [[self window] endEditingFor:nil];
74     [[self window] orderOut:sender];
75     [NSApp stopModal];
76 }
77
78 @end