[vlc-commits] macosx: Cleanup code, use var_InheritBool for controls bar config

David Fuhrmann git at videolan.org
Sat Jul 1 12:58:39 CEST 2017


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jul  1 12:25:58 2017 +0200| [a8a2a275f45e46130885f73828e95b76d1d672ae] | committer: David Fuhrmann

macosx: Cleanup code, use var_InheritBool for controls bar config

Use var_InheritBool for all appearance settings affecting the
controls bar. Cleanup code and remove unnecessary variables.

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

 modules/gui/macosx/VLCMainMenu.m              | 16 +++++++-------
 modules/gui/macosx/VLCMainWindow.m            |  2 +-
 modules/gui/macosx/VLCMainWindowControlsBar.h |  1 -
 modules/gui/macosx/VLCMainWindowControlsBar.m | 32 ++++++---------------------
 4 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index c6dc30fbfb..38b572ee56 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -366,13 +366,13 @@
 
     [_viewMenu setTitle: _NS("View")];
     [_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")];
-    [_toggleJumpButtons setState: config_GetInt(getIntf(), "macosx-show-playback-buttons")];
+    [_toggleJumpButtons setState: var_InheritBool(getIntf(), "macosx-show-playback-buttons")];
     [_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
-    [_togglePlaymodeButtons setState: config_GetInt(getIntf(), "macosx-show-playmode-buttons")];
+    [_togglePlaymodeButtons setState: var_InheritBool(getIntf(), "macosx-show-playmode-buttons")];
     [_toggleEffectsButton setTitle: _NS("Show Audio Effects Button")];
-    [_toggleEffectsButton setState: config_GetInt(getIntf(), "macosx-show-effects-button")];
+    [_toggleEffectsButton setState: var_InheritBool(getIntf(), "macosx-show-effects-button")];
     [_toggleSidebar setTitle: _NS("Show Sidebar")];
-    [_toggleSidebar setState: config_GetInt(getIntf(), "macosx-show-sidebar")];
+    [_toggleSidebar setState: var_InheritBool(getIntf(), "macosx-show-sidebar")];
     [_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
 
     [_controlsMenu setTitle: _NS("Playback")];
@@ -659,7 +659,7 @@
 
 - (IBAction)toggleEffectsButton:(id)sender
 {
-    BOOL b_value = !config_GetInt(getIntf(), "macosx-show-effects-button");
+    BOOL b_value = !var_InheritBool(getIntf(), "macosx-show-effects-button");
     config_PutInt(getIntf(), "macosx-show-effects-button", b_value);
     [(VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleEffectsButton];
     [_toggleEffectsButton setState: b_value];
@@ -667,7 +667,7 @@
 
 - (IBAction)toggleJumpButtons:(id)sender
 {
-    BOOL b_value = !config_GetInt(getIntf(), "macosx-show-playback-buttons");
+    BOOL b_value = !var_InheritBool(getIntf(), "macosx-show-playback-buttons");
     config_PutInt(getIntf(), "macosx-show-playback-buttons", b_value);
 
     [(VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] mainWindow] controlsBar] toggleJumpButtons];
@@ -680,7 +680,7 @@
 
 - (IBAction)togglePlaymodeButtons:(id)sender
 {
-    BOOL b_value = !config_GetInt(getIntf(), "macosx-show-playmode-buttons");
+    BOOL b_value = !var_InheritBool(getIntf(), "macosx-show-playmode-buttons");
     config_PutInt(getIntf(), "macosx-show-playmode-buttons", b_value);
     [(VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] mainWindow] controlsBar] togglePlaymodeButtons];
     [_togglePlaymodeButtons setState: b_value];
@@ -693,7 +693,7 @@
 
 - (void)updateSidebarMenuItem
 {
-    [_toggleSidebar setState: config_GetInt(getIntf(), "macosx-show-sidebar")];
+    [_toggleSidebar setState: var_InheritBool(getIntf(), "macosx-show-sidebar")];
 }
 
 #pragma mark - Playback
diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index 5fed2473fd..fadf07f662 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -284,7 +284,7 @@ static const float f_min_window_height = 307.;
     /* restore split view */
     f_lastLeftSplitViewWidth = 200;
     /* trick NSSplitView implementation, which pretends to know better than us */
-    if (!config_GetInt(getIntf(), "macosx-show-sidebar"))
+    if (!var_InheritBool(getIntf(), "macosx-show-sidebar"))
         [self performSelector:@selector(toggleLeftSubSplitView) withObject:nil afterDelay:0.05];
 }
 
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.h b/modules/gui/macosx/VLCMainWindowControlsBar.h
index f78dc26196..5010c50e7b 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.h
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.h
@@ -68,7 +68,6 @@
 - (IBAction)repeat:(id)sender;
 
 - (void)setShuffle;
-- (IBAction)shuffle:(id)sender;
 
 - (IBAction)togglePlaylist:(id)sender;
 
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.m b/modules/gui/macosx/VLCMainWindowControlsBar.m
index f76c567331..8a9d70676a 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.m
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.m
@@ -48,17 +48,8 @@
     NSImage * _pressedShuffleImage;
     NSImage * _shuffleOnImage;
     NSImage * _pressedShuffleOnImage;
-
-    BOOL b_show_jump_buttons;
-    BOOL b_show_playmode_buttons;
-
-    NSLayoutConstraint *_hidePrevButtonConstraint;
-    NSLayoutConstraint *_hideNextButtonConstraint;
 }
 
-- (void)addPlaymodeButtons:(BOOL)withAnimation;
-- (void)removePlaymodeButtons:(BOOL)withAnimation;
-
 @end
 
 @implementation VLCMainWindowControlsBar
@@ -194,12 +185,10 @@
     if (!var_InheritBool(getIntf(), "macosx-show-effects-button"))
         [self removeEffectsButton:NO];
 
-    b_show_playmode_buttons = var_InheritBool(getIntf(), "macosx-show-playmode-buttons");
-    if (!b_show_playmode_buttons)
+    if (!var_InheritBool(getIntf(), "macosx-show-playmode-buttons"))
         [self removePlaymodeButtons:NO];
 
-    b_show_jump_buttons = var_InheritBool(getIntf(), "macosx-show-playback-buttons");
-    if (!b_show_jump_buttons)
+    if (!var_InheritBool(getIntf(), "macosx-show-playback-buttons"))
         [self removeJumpButtons:NO];
 
     [[[VLCMain sharedInstance] playlist] playbackModeUpdated];
@@ -228,7 +217,7 @@
 
 - (void)toggleEffectsButton
 {
-    if (config_GetInt(getIntf(), "macosx-show-effects-button"))
+    if (var_InheritBool(getIntf(), "macosx-show-effects-button"))
         [self addEffectsButton:YES];
     else
         [self removeEffectsButton:YES];
@@ -272,9 +261,7 @@
 
 - (void)toggleJumpButtons
 {
-    b_show_jump_buttons = config_GetInt(getIntf(), "macosx-show-playback-buttons");
-
-    if (b_show_jump_buttons)
+    if (var_InheritBool(getIntf(), "macosx-show-playback-buttons"))
         [self addJumpButtons:YES];
     else
         [self removeJumpButtons:YES];
@@ -330,9 +317,7 @@
 
 - (void)togglePlaymodeButtons
 {
-    b_show_playmode_buttons = config_GetInt(getIntf(), "macosx-show-playmode-buttons");
-
-    if (b_show_playmode_buttons)
+    if (var_InheritBool(getIntf(), "macosx-show-playmode-buttons"))
         [self addPlaymodeButtons:YES];
     else
         [self removePlaymodeButtons:YES];
@@ -528,11 +513,8 @@
     }
 
     [self.stopButton setEnabled: b_input];
-
-    if (b_show_jump_buttons) {
-        [self.prevButton setEnabled: (b_seekable || b_plmul || b_chapters)];
-        [self.nextButton setEnabled: (b_seekable || b_plmul || b_chapters)];
-    }
+    [self.prevButton setEnabled: (b_seekable || b_plmul || b_chapters)];
+    [self.nextButton setEnabled: (b_seekable || b_plmul || b_chapters)];
 
     [[[VLCMain sharedInstance] mainMenu] setRateControlsEnabled: b_control];
 }



More information about the vlc-commits mailing list