[vlc-commits] macosx/statusbaritem: minor optimization

Felix Paul Kühne git at videolan.org
Wed Jan 30 10:33:31 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Jan 30 10:26:47 2019 +0100| [08de2d0890c20d22d3709c0b089a6a48e95f01bc] | committer: Felix Paul Kühne

macosx/statusbaritem: minor optimization

Re-use an existing string instead of creating a new one and hide the path action item if there is no action to perform

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

 modules/gui/macosx/VLCStatusBarIcon.m | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/modules/gui/macosx/VLCStatusBarIcon.m b/modules/gui/macosx/VLCStatusBarIcon.m
index fcc77026af..8d543ad995 100644
--- a/modules/gui/macosx/VLCStatusBarIcon.m
+++ b/modules/gui/macosx/VLCStatusBarIcon.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * VLCStatusBarIcon.m: Status bar icon controller/delegate
  *****************************************************************************
- * Copyright (C) 2016 VLC authors and VideoLAN
+ * Copyright (C) 2016-2019 VLC authors and VideoLAN
  *
  * Authors: Goran Dokic <vlc at 8hz dot com>
  *
@@ -21,21 +21,14 @@
  *****************************************************************************/
 
 #import "VLCStatusBarIcon.h"
-
-#import "VLCMainMenu.h"
 #import "VLCMain.h"
+#import "VLCCoreInteraction.h"
+#import "NSString+Helpers.h"
 
 #import <vlc_common.h>
 #import <vlc_playlist_legacy.h>
 #import <vlc_input.h>
 
-#import "CompatibilityFixes.h"
-#import "VLCCoreInteraction.h"
-#import "VLCStringUtility.h"
-#import "NSString+Helpers.h"
-
-#import "VLCApplication.h"
-
 @interface VLCStatusBarIcon ()
 {
     NSMenuItem *_vlcStatusBarMenuItem;
@@ -77,12 +70,9 @@
 - (instancetype)init
 {
     self = [super init];
-
     if (self) {
-        msg_Dbg(getIntf(), "Loading VLCStatusBarIcon");
         [[NSBundle mainBundle] loadNibNamed:@"VLCStatusBarIconMainMenu" owner:self topLevelObjects:nil];
     }
-
     return self;
 }
 
@@ -391,14 +381,15 @@
 - (void)updateDynamicMenuItemText
 {
     if (!_currentPlaybackUrl) {
-        [pathActionItem setTitle:_NS("Path/URL Action")];
+        pathActionItem.hidden = YES;
         return;
     }
 
     NSURL *itemURI = [NSURL URLWithString:_currentPlaybackUrl];
+    pathActionItem.hidden = NO;
 
     if ([itemURI.scheme isEqualToString:@"file"]) {
-        [pathActionItem setTitle:_NS("Select File In Finder")];
+        [pathActionItem setTitle:_NS("Reveal in Finder")];
     } else {
         [pathActionItem setTitle:_NS("Copy URL to clipboard")];
     }
@@ -415,8 +406,6 @@
     [randButton setState:(random) ? NSOnState : NSOffState];
 }
 
-
-
 #pragma mark -
 #pragma mark Utility functions
 
@@ -453,7 +442,6 @@
     [totalField setEnabled:enabled];
 }
 
-
 /* Returns VLC playlist status
  * Check for constants:
  *   PLAYLIST_RUNNING, PLAYLIST_STOPPED, PLAYLIST_PAUSED
@@ -470,7 +458,6 @@
     return res;
 }
 
-
 #pragma mark -
 #pragma mark Menu item Actions
 
@@ -502,7 +489,7 @@
 // Action: Show VLC main window
 - (IBAction)restoreMainWindow:(id)sender
 {
-    [[VLCApplication sharedApplication] activateIgnoringOtherApps:YES];
+    [[NSApp sharedApplication] activateIgnoringOtherApps:YES];
     [[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:sender];
 }
 



More information about the vlc-commits mailing list