#include "Controller.h"
#include "a52dec/a52.h"
#import "HBOutputPanelController.h"
+#import "PrefsController.h"
#define _(a) NSLocalizedString(a,NULL)
- init
{
- self = [super init];
+ self = [super init];
+ [PrefsController registerUserDefaults];
fHandle = NULL;
- outputPanel = [[HBOutputPanelController alloc] init];
+ outputPanel = [[HBOutputPanelController alloc] init];
return self;
}
- (IBAction)showDebugOutputPanel:(id)sender
{
- [outputPanel showOutputPanel:nil];
+ [outputPanel showOutputPanel:nil];
}
-
@end
+/**
+ * @file
+ * Implementation of class PrefsController.
+ */
+
#import "PrefsController.h"
@implementation PrefsController
-- (void) awakeFromNib
+/**
+ * Registers default values to user defaults. This is called immediately
+ * when HandBrake starts, from [HBController init].
+ */
++ (void)registerUserDefaults
{
- NSUserDefaults * defaults;
- NSDictionary * appDefaults;
+ NSString *desktopDirectory = [@"~/Desktop" stringByExpandingTildeInPath];
- /* Unless the user specified otherwise, default is to check
- for update DefAdvancedx264Flags*/
- defaults = [NSUserDefaults standardUserDefaults];
-
- NSString *defDestDirectory = @"~/Desktop";
- defDestDirectory = [defDestDirectory stringByExpandingTildeInPath];
-
- NSString *defSrcDirectory = @"~/Desktop";
- defSrcDirectory = [defSrcDirectory stringByExpandingTildeInPath];
-
- appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
+ [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
@"YES", @"CheckForUpdates",
@"English", @"DefaultLanguage",
@"NO", @"DefaultMpegName",
@"NO", @"DefAdvancedx264FlagsShow",
@"", @"DefAdvancedx264Flags",
@"YES", @"DefaultPresetsDrawerShow",
- defDestDirectory, @"LastDestinationDirectory",
- defSrcDirectory, @"LastSourceDirectory",
+ desktopDirectory, @"LastDestinationDirectory",
+ desktopDirectory, @"LastSourceDirectory",
@"NO", @"DefaultAutoNaming",
@"NO", @"DefaultChapterMarkers",
@"NO", @"ShowVerboseOutput",
- nil];
-
- [defaults registerDefaults: appDefaults];
+ nil]];
+}
+
+- (void) awakeFromNib
+{
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
/* fUpdateCheck Check or uncheck according to the preferences */
[fUpdateCheck setState: [defaults boolForKey:@"CheckForUpdates"] ?