[vlc-commits] macosx: audio effects panel: small fixes for eq presets management

David Fuhrmann git at videolan.org
Fri Jan 4 21:45:17 CET 2013


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Fri Jan  4 18:26:53 2013 +0100| [ebce4183b6ace5a42dd8e6a0252f6272d7d33072] | committer: David Fuhrmann

macosx: audio effects panel: small fixes for eq presets management

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ebce4183b6ace5a42dd8e6a0252f6272d7d33072
---

 modules/gui/macosx/AudioEffects.m |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/AudioEffects.m b/modules/gui/macosx/AudioEffects.m
index 706e474..8476387 100644
--- a/modules/gui/macosx/AudioEffects.m
+++ b/modules/gui/macosx/AudioEffects.m
@@ -476,35 +476,42 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
 
 - (void)updatePresetSelector
 {
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+    NSArray *presets = [defaults objectForKey:@"EQNames"];
+
     [o_eq_presets_popup removeAllItems];
     [o_eq_presets_popup addItemsWithTitles:[[NSUserDefaults standardUserDefaults] objectForKey:@"EQTitles"]];
     [[o_eq_presets_popup menu] addItem:[NSMenuItem separatorItem]];
     [o_eq_presets_popup addItemWithTitle:_NS("Add new Preset...")];
     [[o_eq_presets_popup lastItem] setTarget: self];
     [[o_eq_presets_popup lastItem] setAction: @selector(addPresetAction:)];
-    [o_eq_presets_popup addItemWithTitle:_NS("Organize Presets...")];
-    [[o_eq_presets_popup lastItem] setTarget: self];
-    [[o_eq_presets_popup lastItem] setAction: @selector(deletePresetAction:)];
+
+    if ([presets count] > 1) {
+        [o_eq_presets_popup addItemWithTitle:_NS("Organize Presets...")];
+        [[o_eq_presets_popup lastItem] setTarget: self];
+        [[o_eq_presets_popup lastItem] setAction: @selector(deletePresetAction:)];
+    }
 
     vlc_object_t *p_object = VLC_OBJECT(getAout());
     if (p_object == NULL)
         p_object = vlc_object_hold(pl_Get(p_intf));
 
-    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    NSArray *presets = [defaults objectForKey:@"EQNames"];
     NSString *currentPreset = [NSString stringWithFormat:@"%s",var_GetNonEmptyString(p_object, "equalizer-preset")];
-    NSInteger currentPresetIndex = 0;
+    vlc_object_release(p_object);
+
+    NSUInteger currentPresetIndex = 0;
     if ([currentPreset length] > 0) {
         currentPresetIndex = [presets indexOfObjectPassingTest:^(id obj, NSUInteger idx, BOOL *stop) {
             return [obj isEqualToString:currentPreset];
         }];
-    }
+
+        if (currentPresetIndex == NSNotFound)
+            currentPresetIndex = [presets count] - 1;
+    }    
 
     [o_eq_presets_popup selectItemAtIndex:currentPresetIndex];
     [o_eq_preamp_sld setFloatValue:[[[defaults objectForKey:@"EQPreampValues"] objectAtIndex:currentPresetIndex] floatValue]];
     [self setBandSliderValuesForPreset:currentPresetIndex];
-
-    vlc_object_release(p_object);
 }
 
 - (void)equalizerUpdated



More information about the vlc-commits mailing list