Commit f95e46d6 authored by Felix Paul Kühne's avatar Felix Paul Kühne Committed by Marvin Scholz

macosx: rework renderer menu to match the Qt interface

Discovery automatically runs for 20s when opening the menu and is terminated afterwards. The state is no longer displayed as it is implicit.

Further, this removes the nib object singleton of the renderer menu controller as this way of initialization is discouraged in modern Cocoa.
parent 0ce737f3
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="16G1036" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="17E139j" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment version="1070" identifier="macosx"/>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="VLCMainMenu">
......@@ -106,6 +106,9 @@
<outlet property="rate_slowerLabel" destination="4600" id="vRN-S8-MSb"/>
<outlet property="rate_view" destination="4596" id="MPC-hG-6bj"/>
<outlet property="record" destination="5137" id="Ka3-jl-auY"/>
<outlet property="rendererMenu" destination="ODg-VN-8Tv" id="3Ox-BO-HyW"/>
<outlet property="rendererMenuItem" destination="wYl-A2-q30" id="obH-UF-FmA"/>
<outlet property="rendererNoneItem" destination="eE8-qf-9x9" id="Ol2-yz-0eF"/>
<outlet property="repeat" destination="5143" id="ulG-wD-gtG"/>
<outlet property="revealInFinder" destination="3945" id="z7n-A2-K5o"/>
<outlet property="save_playlist" destination="1599" id="spC-pk-6W4"/>
......@@ -487,26 +490,13 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Renderer" id="ODg-VN-8Tv">
<items>
<menuItem title="Renderer discovery off" enabled="NO" id="kZC-S6-b2M">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Enable renderer discovery" id="5gR-ec-KSL">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleRendererDiscovery:" target="GfD-zq-JqC" id="tGk-pM-MVQ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="sbF-Ji-lAl"/>
<menuItem title="No Renderer" state="on" id="eE8-qf-9x9">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="selectRenderer:" target="GfD-zq-JqC" id="JA3-zV-4I0"/>
<action selector="selectRenderer:" target="-2" id="80x-Dh-S0n"/>
</connections>
</menuItem>
</items>
<connections>
<outlet property="delegate" destination="GfD-zq-JqC" id="9Fg-VF-zbg"/>
</connections>
</menu>
</menuItem>
<menuItem title="Program" id="5150">
......@@ -1083,14 +1073,6 @@
</constraints>
<point key="canvasLocation" x="296.5" y="285.5"/>
</customView>
<customObject id="GfD-zq-JqC" customClass="VLCRendererMenuController">
<connections>
<outlet property="rendererDiscoveryState" destination="kZC-S6-b2M" id="Ur7-YL-R4x"/>
<outlet property="rendererDiscoveryToggle" destination="5gR-ec-KSL" id="CEI-18-tX4"/>
<outlet property="rendererMenu" destination="ODg-VN-8Tv" id="bMa-lk-ryz"/>
<outlet property="rendererNoneItem" destination="eE8-qf-9x9" id="p9J-VU-Dg9"/>
</connections>
</customObject>
<userDefaultsController representsSharedInstance="YES" id="uFO-sP-uo6"/>
</objects>
</document>
/*****************************************************************************
*MainMenu.h: MacOS X interface module
*****************************************************************************
*Copyright (C) 2011-2015 Felix Paul Kühne
*Copyright (C) 2011-2018 Felix Paul Kühne
*$Id$
*
*Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
......@@ -93,6 +93,9 @@
@property (readwrite, weak) IBOutlet NSMenuItem *fwd;
@property (readwrite, weak) IBOutlet NSMenuItem *bwd;
@property (readwrite, weak) IBOutlet NSMenuItem *jumpToTime;
@property (readwrite, weak) IBOutlet NSMenu *rendererMenu;
@property (readwrite, weak) IBOutlet NSMenuItem *rendererMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *rendererNoneItem;
@property (readwrite, weak) IBOutlet NSMenuItem *program;
@property (readwrite, weak) IBOutlet NSMenu *programMenu;
@property (readwrite, weak) IBOutlet NSMenuItem *title;
......@@ -251,6 +254,7 @@
- (IBAction)setPlaybackRate:(id)sender;
- (void)updatePlaybackRate;
- (IBAction)toggleAtoBloop:(id)sender;
- (IBAction)selectRenderer:(id)sender;
- (IBAction)toggleFullscreen:(id)sender;
- (IBAction)resizeVideoWindow:(id)sender;
......
/*****************************************************************************
*MainMenu.m: MacOS X interface module
*****************************************************************************
*Copyright (C) 2011-2015 Felix Paul Kühne
*Copyright (C) 2011-2018 Felix Paul Kühne
*$Id$
*
*Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
......@@ -50,21 +50,23 @@
#import "VLCAddonsWindowController.h"
#import "VLCTimeSelectionPanelController.h"
#import "NSScreen+VLCAdditions.h"
#import "VLCRendererMenuController.h"
#ifdef HAVE_SPARKLE
#import <Sparkle/Sparkle.h>
#endif
@interface VLCMainMenu()
@interface VLCMainMenu() <NSMenuDelegate>
{
VLCAboutWindowController *_aboutWindowController;
VLCHelpWindowController *_helpWindowController;
VLCAddonsWindowController *_addonsController;
VLCRendererMenuController *_rendererMenuController;
NSTimer *_cancelRendererDiscoveryTimer;
NSMenu *_playlistTableColumnsContextMenu;
__strong VLCTimeSelectionPanelController *_timeSelectionPanel;
}
@end
......@@ -206,6 +208,13 @@
[self setSubmenusEnabled: FALSE];
/* configure playback / controls menu */
self.controlsMenu.delegate = self;
[_rendererNoneItem setState:NSOnState];
_rendererMenuController = [[VLCRendererMenuController alloc] init];
_rendererMenuController.rendererNoneItem = _rendererNoneItem;
_rendererMenuController.rendererMenu = _rendererMenu;
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(refreshVoutDeviceMenu:)
name: NSApplicationDidChangeScreenParametersNotification
......@@ -394,6 +403,8 @@
[_fwd setTitle: _NS("Step Forward")];
[_bwd setTitle: _NS("Step Backward")];
[_jumpToTime setTitle: _NS("Jump to Time")];
[_rendererMenuItem setTitle:_NS("Renderer")];
[_rendererNoneItem setTitle:_NS("No renderer")];
[_program setTitle: _NS("Program")];
[_programMenu setTitle: _NS("Program")];
[_title setTitle: _NS("Title")];
......@@ -847,6 +858,11 @@
}
}
- (IBAction)selectRenderer:(id)sender
{
[_rendererMenuController selectRenderer:sender];
}
#pragma mark - audio menu
- (void)refreshAudioDeviceList
......@@ -1561,6 +1577,28 @@
}
}
#pragma mark - menu delegation
- (void)menuWillOpen:(NSMenu *)menu
{
[_cancelRendererDiscoveryTimer invalidate];
[_rendererMenuController startRendererDiscoveries];
}
- (void)menuDidClose:(NSMenu *)menu
{
_cancelRendererDiscoveryTimer = [NSTimer scheduledTimerWithTimeInterval:20.
target:self
selector:@selector(cancelRendererDiscovery)
userInfo:nil
repeats:NO];
}
- (void)cancelRendererDiscovery
{
[_rendererMenuController stopRendererDiscoveries];
}
@end
@implementation VLCMainMenu (NSMenuValidation)
......
......@@ -32,6 +32,7 @@
{
intf_thread_t *p_intf;
vlc_renderer_discovery_t *p_rd;
BOOL _isRunning;
}
- (void)handleItemAdded:(vlc_renderer_item_t *)item;
......@@ -77,6 +78,10 @@ static void renderer_event_item_removed(vlc_renderer_discovery_t *rd,
- (bool)startDiscovery
{
if (_isRunning) {
return YES;
}
struct vlc_renderer_discovery_owner owner =
{
(__bridge void *) self,
......@@ -91,10 +96,12 @@ static void renderer_event_item_removed(vlc_renderer_discovery_t *rd,
p_rd = vlc_rd_new(VLC_OBJECT(p_intf), _name.UTF8String, &owner);
if (!p_rd) {
_isRunning = NO;
msg_Err(p_intf, "Could not create '%s' renderer discovery service", _name.UTF8String);
return false;
}
_isRunning = YES;
return true;
}
......@@ -103,6 +110,7 @@ static void renderer_event_item_removed(vlc_renderer_discovery_t *rd,
if (p_rd != NULL) {
vlc_rd_release(p_rd);
p_rd = NULL;
_isRunning = NO;
}
}
......
......@@ -28,9 +28,11 @@
@interface VLCRendererMenuController : NSObject <VLCRendererDiscoveryDelegate>
@property (readwrite, weak) IBOutlet NSMenu *rendererMenu;
@property (readwrite, weak) IBOutlet NSMenuItem *rendererDiscoveryState;
@property (readwrite, weak) IBOutlet NSMenuItem *rendererDiscoveryToggle;
@property (readwrite, weak) IBOutlet NSMenuItem *rendererNoneItem;
@property (readwrite, weak) NSMenu *rendererMenu;
@property (readwrite, weak) NSMenuItem *rendererNoneItem;
- (void)startRendererDiscoveries;
- (void)stopRendererDiscoveries;
- (void)selectRenderer:(NSMenuItem *)sender;
@end
/*****************************************************************************
* VLCRendererMenuController.m: Controller class for the renderer menu
*****************************************************************************
* Copyright (C) 2016 VLC authors and VideoLAN
* Copyright (C) 2016-2018 VLC authors and VideoLAN
* $Id$
*
* Authors: Marvin Scholz <epirat07 at gmail dot com>
* Felix Paul Kühne <fkuehne -at- videolan -dot- org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -59,7 +60,6 @@
- (void)awakeFromNib
{
_selectedItem = _rendererNoneItem;
[self setupMenu];
}
- (void)dealloc
......@@ -67,17 +67,6 @@
[self stopRendererDiscoveries];
}
- (void)setupMenu
{
[_rendererDiscoveryState setTitle:_NS("Renderer discovery off")];
[_rendererDiscoveryState setEnabled:NO];
[_rendererDiscoveryToggle setTitle:_NS("Enable renderer discovery")];
[_rendererNoneItem setTitle:_NS("No renderer")];
[_rendererNoneItem setState:NSOnState];
}
- (void)loadRendererDiscoveries
{
playlist_t *playlist = pl_Get(p_intf);
......@@ -131,8 +120,6 @@
- (void)startRendererDiscoveries
{
_isDiscoveryEnabled = YES;
[_rendererDiscoveryState setTitle:_NS("Renderer discovery on")];
[_rendererDiscoveryToggle setTitle:_NS("Disable renderer discovery")];
for (VLCRendererDiscovery *dc in _rendererDiscoveries) {
[dc startDiscovery];
}
......@@ -141,8 +128,6 @@
- (void)stopRendererDiscoveries
{
_isDiscoveryEnabled = NO;
[_rendererDiscoveryState setTitle:_NS("Renderer discovery off")];
[_rendererDiscoveryToggle setTitle:_NS("Enable renderer discovery")];
for (VLCRendererDiscovery *dc in _rendererDiscoveries) {
[dc stopDiscovery];
}
......@@ -156,7 +141,7 @@
return [menuItem isEnabled];
}
- (IBAction)selectRenderer:(NSMenuItem *)sender
- (void)selectRenderer:(NSMenuItem *)sender
{
[_selectedItem setState:NSOffState];
[sender setState:NSOnState];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment