]> granicus.if.org Git - handbrake/commitdiff
MacGui: toggle the Advanced tab when the prefs setting changes.
authorritsuka <damiog@gmail.com>
Mon, 25 Aug 2014 09:19:31 +0000 (09:19 +0000)
committerritsuka <damiog@gmail.com>
Mon, 25 Aug 2014 09:19:31 +0000 (09:19 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6355 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.m

index be9e3ca31f24b3b7a559cc02d5f3e377deeefc13..f75d50b86249ea701ee1b2a6365d41091e654701 100644 (file)
@@ -671,14 +671,47 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     fVideoController.fHBController = self;
        [fVideoTab setView:[fVideoController view]];
 
+    [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
+                                                              forKeyPath:@"values.HBShowAdvancedTab"
+                                                                 options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial
+                                                                 context:NULL];
+
     [fWindow recalculateKeyViewLoop];
 
     // Presets initialization
     [self checkBuiltInsForUpdates];
     [self buildPresetsMenu];
+
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(buildPresetsMenu) name:HBPresetsChangedNotification object:nil];
 }
 
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+    if (context == NULL)
+    {
+        if ([keyPath isEqualToString:@"values.HBShowAdvancedTab"])
+        {
+            if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"])
+            {
+                if (![[fMainTabView tabViewItems] containsObject:fAdvancedTab])
+                {
+                    [fMainTabView insertTabViewItem:fAdvancedTab atIndex:3];
+                    [fAdvancedTab release];
+                }
+            }
+            else
+            {
+                [fAdvancedTab retain];
+                [fMainTabView removeTabViewItem:fAdvancedTab];
+            }
+        }
+    }
+    else
+    {
+        [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+    }
+}
+
 - (void) enableUI: (BOOL) b
 {
     NSControl * controls[] =