1
mirror of https://code.videolan.org/videolan/vlc synced 2024-08-18 23:45:06 +02:00

macosx/main menu: reimplement program selection

This commit is contained in:
Felix Paul Kühne 2019-04-09 22:50:32 +02:00
parent 53abf4bbba
commit e4dfdb0ff4

View File

@ -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