[vlc-commits] macosx/main menu: reimplement program selection

Felix Paul Kühne git at videolan.org
Tue Apr 9 22:53:55 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Tue Apr  9 22:50:32 2019 +0200| [e4dfdb0ff4ab94afbf54bbbb39c5f64d3c2d61d9] | committer: Felix Paul Kühne

macosx/main menu: reimplement program selection

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

 modules/gui/macosx/menus/VLCMainMenu.m | 40 ++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index 8d3046c0f4..08caa7bd32 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -174,6 +174,14 @@
                            selector:@selector(updateTitleAndChapterMenus:)
                                name:VLCPlayerChapterSelectionChanged
                              object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(updateProgramMenu:)
+                               name:VLCPlayerProgramListChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(updateProgramMenu:)
+                               name:VLCPlayerProgramSelectionChanged
+                             object:nil];
 
     [self setupVarMenuItem:_add_intf
                     target:VLC_OBJECT(getIntf())
@@ -575,9 +583,6 @@
     input_item_t *p_mediaItem = _playerController.currentMedia;
 
     if (p_mediaItem != NULL) {
-/*        [self setupVarMenuItem:_program target: (vlc_object_t *)p_input
-                                 var:"program" selector: @selector(toggleVar:)];*/
-
         audio_output_t *p_aout = [_playerController mainAudioOutput];
         if (p_aout != NULL) {
             [self setupVarMenuItem:_channels target:VLC_OBJECT(p_aout)
@@ -643,7 +648,6 @@
 
 - (void)setSubmenusEnabled:(BOOL)b_enabled
 {
-    [_program setEnabled: b_enabled];
     [_visual setEnabled: b_enabled];
     [_channels setEnabled: b_enabled];
     [_deinterlace setEnabled: b_enabled];
@@ -976,6 +980,34 @@
     _playerController.selectedChapterIndex = [sender tag];
 }
 
+#pragma mark - program handling
+- (void)updateProgramMenu:(NSNotification *)notification
+{
+    [_programMenu removeAllItems];
+
+    size_t count = [_playerController numberOfPrograms];
+    for (size_t x = 0; x < count; x++) {
+        VLCProgramMetaData *program = [_playerController programAtIndex:x];
+        if (program == nil) {
+            break;
+        }
+        NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:program.name
+                                                          action:@selector(selectProgram:)
+                                                   keyEquivalent:@""];
+        [menuItem setTarget:self];
+        [menuItem setRepresentedObject:program];
+        [menuItem setEnabled:YES];
+        [menuItem setState:program.selected ? NSOnState : NSOffState];
+        [_programMenu addItem:menuItem];
+    }
+    _program.enabled = count > 0 ? YES : NO;
+}
+
+- (void)selectProgram:(NSMenuItem *)sender
+{
+    [_playerController selectProgram:[sender representedObject]];
+}
+
 #pragma mark - audio menu
 
 - (void)refreshAudioDeviceList



More information about the vlc-commits mailing list