]> granicus.if.org Git - handbrake/commitdiff
Moved initialization of default preferences from [PrefsController awakeFromNib] to...
authorcleaner <mika.ryynanen@gmail.com>
Tue, 5 Jun 2007 20:09:13 +0000 (20:09 +0000)
committercleaner <mika.ryynanen@gmail.com>
Tue, 5 Jun 2007 20:09:13 +0000 (20:09 +0000)
This fixes problem with preferences when using HB for the first time, or after deleting the user defaults file.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@599 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.mm
macosx/PrefsController.h
macosx/PrefsController.m

index b3feb406c75aa1cd669355cb795da190e912fe04..e2fac51ab55dbc62390d056960594b1d0abd910f 100644 (file)
@@ -7,6 +7,7 @@
 #include "Controller.h"
 #include "a52dec/a52.h"
 #import "HBOutputPanelController.h"
+#import "PrefsController.h"
 
 #define _(a) NSLocalizedString(a,NULL)
 
@@ -35,9 +36,10 @@ static int FormatSettings[3][4] =
 
 - init
 {
-    self    = [super init];
+    self = [super init];
+    [PrefsController registerUserDefaults];
     fHandle = NULL;
-       outputPanel = [[HBOutputPanelController alloc] init];
+    outputPanel = [[HBOutputPanelController alloc] init];
     return self;
 }
 
@@ -3387,8 +3389,7 @@ id theRecord, theValue;
 
 - (IBAction)showDebugOutputPanel:(id)sender
 {
-       [outputPanel showOutputPanel:nil];
+    [outputPanel showOutputPanel:nil];
 }
 
-
 @end
index c6a66be62f660156993bb792f783127856ee1829..af5a7b6fe8448d9ae58b35a1bc21a2f91dd5d415 100644 (file)
@@ -1,4 +1,7 @@
-/* PrefsController */
+/**
+ * @file
+ * Interface of class PrefsController.
+ */
 
 #include <Cocoa/Cocoa.h>
 
@@ -21,6 +24,8 @@
 
 }
 
++ (void)registerUserDefaults;
+
 - (IBAction) OpenPanel:    (id) sender;
 - (IBAction) ClosePanel:   (id) sender;
 - (IBAction) CheckChanged: (id) sender;
index 09414e1db21e9fc85402548e02b7b4f2333e8d4e..7a6e6cbc375da6f9100166e00b3248820ef6b46a 100644 (file)
@@ -1,23 +1,21 @@
+/**
+ * @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"] ?