[vlc-commits] macosx/main menu: iterate on dynamic menu activation and creation

Felix Paul Kühne git at videolan.org
Thu Apr 11 19:26:40 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Apr 10 18:53:06 2019 +0200| [4569ba9ee8f3d0abe0d52acacc47c704d1d1a69a] | committer: Felix Paul Kühne

macosx/main menu: iterate on dynamic menu activation and creation

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

 .../gui/macosx/coreinteraction/VLCInputManager.m   |  3 ---
 modules/gui/macosx/menus/VLCMainMenu.h             |  2 --
 modules/gui/macosx/menus/VLCMainMenu.m             | 25 +++++++++++-----------
 3 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/modules/gui/macosx/coreinteraction/VLCInputManager.m b/modules/gui/macosx/coreinteraction/VLCInputManager.m
index 1688ba9499..8882560448 100644
--- a/modules/gui/macosx/coreinteraction/VLCInputManager.m
+++ b/modules/gui/macosx/coreinteraction/VLCInputManager.m
@@ -242,8 +242,6 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
     }
 
     if (state != PLAYING_S) {
-        [[o_main mainMenu] setSubmenusEnabled: FALSE];
-
         if (state == END_S || state == -1) {
             /* continue playback where you left off */
             if (p_current_input)
@@ -266,7 +264,6 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 
 - (void)updateMainMenu
 {
-    [[o_main mainMenu] setupMenus];
 }
 
 - (BOOL)hasInput
diff --git a/modules/gui/macosx/menus/VLCMainMenu.h b/modules/gui/macosx/menus/VLCMainMenu.h
index ac10b030c6..cf9fb9b73e 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.h
+++ b/modules/gui/macosx/menus/VLCMainMenu.h
@@ -211,8 +211,6 @@
 
 - (void)releaseRepresentedObjects:(NSMenu *)the_menu;
 
-- (void)setupMenus;
-- (void)setSubmenusEnabled:(BOOL)b_enabled;
 - (void)setRateControlsEnabled:(BOOL)b_enabled;
 - (void)updateSidebarMenuItem:(BOOL)show;
 
diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index 08caa7bd32..01607c23c2 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -118,16 +118,16 @@
     [self initStrings];
     [self setupKeyboardShortcuts];
 
-    [self setSubmenusEnabled: YES];
-
     /* configure playback / controls menu */
     self.controlsMenu.delegate = self;
     [_rendererNoneItem setState:NSOnState];
     _rendererMenuController = [[VLCRendererMenuController alloc] init];
     _rendererMenuController.rendererNoneItem = _rendererNoneItem;
     _rendererMenuController.rendererMenu = _rendererMenu;
-    [self updateTrackHandlingMenus:nil];
+
+    [self mediaItemChanged:nil];
     [self updateTitleAndChapterMenus:nil];
+    [self updateProgramMenu:nil];
 
     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
     [notificationCenter addObserver:self
@@ -159,10 +159,6 @@
                                name:VLCPlayerTrackListChanged
                              object:nil];
     [notificationCenter addObserver:self
-                           selector:@selector(updateTrackHandlingMenus:)
-                               name:VLCPlayerCurrentMediaItemChanged
-                             object:nil];
-    [notificationCenter addObserver:self
                            selector:@selector(updateTitleAndChapterMenus:)
                                name:VLCPlayerTitleListChanged
                              object:nil];
@@ -182,6 +178,10 @@
                            selector:@selector(updateProgramMenu:)
                                name:VLCPlayerProgramSelectionChanged
                              object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(mediaItemChanged:)
+                               name:VLCPlaylistCurrentItemChanged
+                             object:nil];
 
     [self setupVarMenuItem:_add_intf
                     target:VLC_OBJECT(getIntf())
@@ -578,8 +578,10 @@
 
 #pragma mark - Interface update
 
-- (void)setupMenus
+- (void)mediaItemChanged:(NSNotification *)aNotification
 {
+    [self updateTrackHandlingMenus:aNotification];
+
     input_item_t *p_mediaItem = _playerController.currentMedia;
 
     if (p_mediaItem != NULL) {
@@ -612,9 +614,11 @@
             [self refreshVoutDeviceMenu:nil];
         }
         [_postprocessing setEnabled:YES];
+        [self setSubmenusEnabled:YES];
         input_item_Release(p_mediaItem);
     } else {
         [_postprocessing setEnabled:NO];
+        [self setSubmenusEnabled:NO];
     }
 }
 
@@ -1725,7 +1729,6 @@
     if (mi == _stop || mi == _voutMenustop || mi == _dockMenustop) {
         if (!inputItem)
             enabled = NO;
-        [self setupMenus]; /* Make sure input menu is up to date */
     } else if (mi == _previous          ||
                mi == _voutMenuprev      ||
                mi == _dockMenuprevious) {
@@ -1753,7 +1756,6 @@
         enabled = _playerController.seekable;
     } else if (mi == _mute || mi == _dockMenumute || mi == _voutMenumute) {
         [mi setState: _playerController.mute ? NSOnState : NSOffState];
-        [self setupMenus]; /* Make sure audio menu is up to date */
         [self refreshAudioDeviceList];
     } else if (mi == _half_window           ||
                mi == _normal_window         ||
@@ -1779,11 +1781,8 @@
             vout_Release(p_vout);
         }
 
-        [self setupMenus]; /* Make sure video menu is up to date */
-
     } else if (mi == _openSubtitleFile) {
         enabled = YES;
-        [self setupMenus]; /* Make sure subtitles menu is up to date */
     } else {
         NSMenuItem *_parent = [mi parentItem];
         if (_parent == _subtitle_size || mi == _subtitle_size           ||



More information about the vlc-commits mailing list