Commit db62975c authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: split main interface class

parent 6916c8d1
...@@ -1240,6 +1240,9 @@ ...@@ -1240,6 +1240,9 @@
7D3F652718805297005776C4 /* BWQuincyManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyManager.m; path = ../../../modules/gui/macosx/BWQuincyManager.m; sourceTree = SOURCE_ROOT; }; 7D3F652718805297005776C4 /* BWQuincyManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyManager.m; path = ../../../modules/gui/macosx/BWQuincyManager.m; sourceTree = SOURCE_ROOT; };
7D3F652818805297005776C4 /* BWQuincyUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BWQuincyUI.h; path = ../../../modules/gui/macosx/BWQuincyUI.h; sourceTree = SOURCE_ROOT; }; 7D3F652818805297005776C4 /* BWQuincyUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BWQuincyUI.h; path = ../../../modules/gui/macosx/BWQuincyUI.h; sourceTree = SOURCE_ROOT; };
7D3F652918805297005776C4 /* BWQuincyUI.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyUI.m; path = ../../../modules/gui/macosx/BWQuincyUI.m; sourceTree = SOURCE_ROOT; }; 7D3F652918805297005776C4 /* BWQuincyUI.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyUI.m; path = ../../../modules/gui/macosx/BWQuincyUI.m; sourceTree = SOURCE_ROOT; };
7D871D371B5E6844000B56C0 /* intf-prefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "intf-prefs.h"; path = "../../../modules/gui/macosx/intf-prefs.h"; sourceTree = "<group>"; };
7D871D381B5E6844000B56C0 /* intf-prefs.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "intf-prefs.m"; path = "../../../modules/gui/macosx/intf-prefs.m"; sourceTree = "<group>"; };
7D871D391B5E684D000B56C0 /* helpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = helpers.h; path = ../../../modules/gui/macosx/helpers.h; sourceTree = "<group>"; };
7D8BB0B318302AC000FAE9B7 /* DebugMessageVisualizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DebugMessageVisualizer.h; path = ../../../modules/gui/macosx/DebugMessageVisualizer.h; sourceTree = SOURCE_ROOT; }; 7D8BB0B318302AC000FAE9B7 /* DebugMessageVisualizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DebugMessageVisualizer.h; path = ../../../modules/gui/macosx/DebugMessageVisualizer.h; sourceTree = SOURCE_ROOT; };
7D8BB0B418302AC000FAE9B7 /* DebugMessageVisualizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = DebugMessageVisualizer.m; path = ../../../modules/gui/macosx/DebugMessageVisualizer.m; sourceTree = SOURCE_ROOT; }; 7D8BB0B418302AC000FAE9B7 /* DebugMessageVisualizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = DebugMessageVisualizer.m; path = ../../../modules/gui/macosx/DebugMessageVisualizer.m; sourceTree = SOURCE_ROOT; };
7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; }; 7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; };
...@@ -1810,6 +1813,7 @@ ...@@ -1810,6 +1813,7 @@
08FB77AFFE84173DC02AAC07 /* Classes */ = { 08FB77AFFE84173DC02AAC07 /* Classes */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
7D871D391B5E684D000B56C0 /* helpers.h */,
8EE1AF9F044465080059A3A7 /* about.h */, 8EE1AF9F044465080059A3A7 /* about.h */,
8EE1AFA0044465080059A3A7 /* about.m */, 8EE1AFA0044465080059A3A7 /* about.m */,
7DF0435E1972E26A0022B534 /* AddonListDataSource.h */, 7DF0435E1972E26A0022B534 /* AddonListDataSource.h */,
...@@ -1845,6 +1849,8 @@ ...@@ -1845,6 +1849,8 @@
2AEF857709A5FEC900130822 /* fspanel.m */, 2AEF857709A5FEC900130822 /* fspanel.m */,
8ED6C27C03E2EB1C0059A3A7 /* intf.h */, 8ED6C27C03E2EB1C0059A3A7 /* intf.h */,
8ED6C27D03E2EB1C0059A3A7 /* intf.m */, 8ED6C27D03E2EB1C0059A3A7 /* intf.m */,
7D871D371B5E6844000B56C0 /* intf-prefs.h */,
7D871D381B5E6844000B56C0 /* intf-prefs.m */,
7DF812ED1B555A340052293C /* InputManager.h */, 7DF812ED1B555A340052293C /* InputManager.h */,
7DF812EE1B555A340052293C /* InputManager.m */, 7DF812EE1B555A340052293C /* InputManager.m */,
7DF812EF1B555C8E0052293C /* KeyboardBacklight.h */, 7DF812EF1B555C8E0052293C /* KeyboardBacklight.h */,
......
...@@ -80,30 +80,34 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4; ...@@ -80,30 +80,34 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
- (id)init - (id)init
{ {
_openInExclusiveMode = YES; self = [super init];
queue = NULL; if (self) {
hidDeviceInterface = NULL; _openInExclusiveMode = YES;
NSMutableDictionary * mutableCookieToButtonMapping = [[NSMutableDictionary alloc] init]; queue = NULL;
hidDeviceInterface = NULL;
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Plus] forKey:@"33_31_30_21_20_2_"]; NSMutableDictionary * mutableCookieToButtonMapping = [[NSMutableDictionary alloc] init];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Minus] forKey:@"33_32_30_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"33_22_21_20_2_33_22_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Plus] forKey:@"33_31_30_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"33_23_21_20_2_33_23_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Minus] forKey:@"33_32_30_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"33_24_21_20_2_33_24_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"33_22_21_20_2_33_22_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"33_25_21_20_2_33_25_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"33_23_21_20_2_33_23_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"33_21_20_14_12_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"33_24_21_20_2_33_24_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"33_21_20_13_12_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"33_25_21_20_2_33_25_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"33_21_20_2_33_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"33_21_20_14_12_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"37_33_21_20_2_37_33_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"33_21_20_13_12_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"33_21_20_2_33_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"37_33_21_20_2_37_33_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"42_33_23_21_20_2_33_23_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
_cookieToButtonMapping = [[NSDictionary alloc] initWithDictionary: mutableCookieToButtonMapping]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"42_33_23_21_20_2_33_23_21_20_2_"];
/* defaults */ _cookieToButtonMapping = [[NSDictionary alloc] initWithDictionary: mutableCookieToButtonMapping];
_simulatesPlusMinusHold = YES;
_maximumClickCountTimeDifference = DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE; /* defaults */
_simulatesPlusMinusHold = YES;
_maximumClickCountTimeDifference = DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE;
}
return self;
} }
- (void) dealloc { - (void) dealloc {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import "CoreInteraction.h" #import "CoreInteraction.h"
#import "MainMenu.h" #import "MainMenu.h"
#import "fspanel.h" #import "fspanel.h"
#import "playlist.h"
#import "CompatibilityFixes.h" #import "CompatibilityFixes.h"
/***************************************************************************** /*****************************************************************************
...@@ -632,7 +633,7 @@ frame.origin.x = f_width + frame.origin.x; \ ...@@ -632,7 +633,7 @@ frame.origin.x = f_width + frame.origin.x; \
if (!config_GetInt(VLCIntf, "macosx-show-effects-button")) if (!config_GetInt(VLCIntf, "macosx-show-effects-button"))
[self removeEffectsButton:YES]; [self removeEffectsButton:YES];
[[VLCMain sharedInstance] playbackModeUpdated]; [[[VLCMain sharedInstance] playlist] playbackModeUpdated];
} }
......
/***************************************************************************** /*****************************************************************************
* CoreInteraction.h: MacOS X interface module * CoreInteraction.h: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2011-2014 Felix Paul Kühne * Copyright (C) 2011-2015 Felix Paul Kühne
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org> * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
...@@ -66,6 +66,8 @@ ...@@ -66,6 +66,8 @@
- (void)volumeUp; - (void)volumeUp;
- (void)volumeDown; - (void)volumeDown;
- (void)toggleMute; - (void)toggleMute;
- (void)startListeningWithAppleRemote;
- (void)stopListeningWithAppleRemote;
- (void)addSubtitlesToCurrentInput:(NSArray *)paths; - (void)addSubtitlesToCurrentInput:(NSArray *)paths;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender; - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
...@@ -80,4 +82,7 @@ ...@@ -80,4 +82,7 @@
- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter string: (const char *)psz_value; - (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter string: (const char *)psz_value;
- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter boolean: (BOOL)b_value; - (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter boolean: (BOOL)b_value;
- (void)updateCurrentlyUsedHotkeys;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
@end @end
This diff is collapsed.
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
@class VLCMain; @class VLCMain;
@interface InputManager : NSObject @interface VLCInputManager : NSObject
- (id)initWithMain:(VLCMain *)o_mainObj; - (id)initWithMain:(VLCMain *)o_mainObj;
......
...@@ -41,7 +41,7 @@ static int InputThreadChanged(vlc_object_t *p_this, const char *psz_var, ...@@ -41,7 +41,7 @@ static int InputThreadChanged(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param) vlc_value_t oldval, vlc_value_t new_val, void *param)
{ {
@autoreleasepool { @autoreleasepool {
InputManager *inputManager = (__bridge InputManager *)param; VLCInputManager *inputManager = (__bridge VLCInputManager *)param;
[inputManager performSelectorOnMainThread:@selector(inputThreadChanged) withObject:nil waitUntilDone:NO]; [inputManager performSelectorOnMainThread:@selector(inputThreadChanged) withObject:nil waitUntilDone:NO];
} }
...@@ -53,7 +53,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -53,7 +53,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param) vlc_value_t oldval, vlc_value_t new_val, void *param)
{ {
@autoreleasepool { @autoreleasepool {
InputManager *inputManager = (__bridge InputManager *)param; VLCInputManager *inputManager = (__bridge VLCInputManager *)param;
switch (new_val.i_int) { switch (new_val.i_int) {
case INPUT_EVENT_STATE: case INPUT_EVENT_STATE:
...@@ -131,9 +131,8 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -131,9 +131,8 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
#pragma mark - #pragma mark -
#pragma mark InputManager implementation #pragma mark InputManager implementation
@interface InputManager() @interface VLCInputManager()
{ {
intf_thread_t *p_intf;
VLCMain *o_main; VLCMain *o_main;
input_thread_t *p_current_input; input_thread_t *p_current_input;
...@@ -150,13 +149,12 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -150,13 +149,12 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
} }
@end @end
@implementation InputManager @implementation VLCInputManager
- (id)initWithMain:(VLCMain *)o_mainObj - (id)initWithMain:(VLCMain *)o_mainObj
{ {
self = [super init]; self = [super init];
if(self) { if(self) {
p_intf = VLCIntf;
o_main = o_mainObj; o_main = o_mainObj;
var_AddCallback(pl_Get(VLCIntf), "input-current", InputThreadChanged, (__bridge void *)self); var_AddCallback(pl_Get(VLCIntf), "input-current", InputThreadChanged, (__bridge void *)self);
...@@ -168,6 +166,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -168,6 +166,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
- (void)dealloc - (void)dealloc
{ {
intf_thread_t *p_intf = VLCIntf;
if (p_current_input) { if (p_current_input) {
/* continue playback where you left off */ /* continue playback where you left off */
[[o_main playlist] storePlaybackPositionForItem:p_current_input]; [[o_main playlist] storePlaybackPositionForItem:p_current_input];
...@@ -177,7 +176,8 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -177,7 +176,8 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
p_current_input = NULL; p_current_input = NULL;
} }
var_DelCallback(pl_Get(VLCIntf), "input-current", InputThreadChanged, (__bridge void *)self); if (p_intf)
var_DelCallback(p_intf, "input-current", InputThreadChanged, (__bridge void *)self);
dispatch_release(informInputChangedQueue); dispatch_release(informInputChangedQueue);
} }
...@@ -230,7 +230,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -230,7 +230,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
* The serial queue ensures that changed inputs are propagated in the same order as they arrive. * The serial queue ensures that changed inputs are propagated in the same order as they arrive.
*/ */
dispatch_async(informInputChangedQueue, ^{ dispatch_async(informInputChangedQueue, ^{
[[ExtensionsManager getInstance:p_intf] inputChanged:p_input_changed]; [[ExtensionsManager getInstance:VLCIntf] inputChanged:p_input_changed];
if (p_input_changed) if (p_input_changed)
vlc_object_release(p_input_changed); vlc_object_release(p_input_changed);
}); });
...@@ -239,6 +239,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -239,6 +239,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
- (void)playbackStatusUpdated - (void)playbackStatusUpdated
{ {
intf_thread_t *p_intf = VLCIntf;
int state = -1; int state = -1;
if (p_current_input) { if (p_current_input) {
state = var_GetInteger(p_current_input, "state"); state = var_GetInteger(p_current_input, "state");
...@@ -363,6 +364,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -363,6 +364,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
- (void)resumeItunesPlayback:(id)sender - (void)resumeItunesPlayback:(id)sender
{ {
intf_thread_t *p_intf = VLCIntf;
if (var_InheritInteger(p_intf, "macosx-control-itunes") > 1) { if (var_InheritInteger(p_intf, "macosx-control-itunes") > 1) {
if (b_has_itunes_paused) { if (b_has_itunes_paused) {
iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
......
...@@ -100,7 +100,7 @@ static VLCMainWindow *sharedInstance = nil; ...@@ -100,7 +100,7 @@ static VLCMainWindow *sharedInstance = nil;
defer:flag]; defer:flag];
}); });
[[VLCMain sharedInstance] updateTogglePlaylistState]; [[[VLCMain sharedInstance] playlist] updateTogglePlaylistState];
return sharedInstance; return sharedInstance;
} }
...@@ -146,7 +146,7 @@ static VLCMainWindow *sharedInstance = nil; ...@@ -146,7 +146,7 @@ static VLCMainWindow *sharedInstance = nil;
else else
b_force = YES; b_force = YES;
return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] || return [[VLCCoreInteraction sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
[(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event]; [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
} }
......
...@@ -18,6 +18,7 @@ EXTRA_LTLIBRARIES = libmacosx_plugin.la ...@@ -18,6 +18,7 @@ EXTRA_LTLIBRARIES = libmacosx_plugin.la
gui_LTLIBRARIES = $(LTLIBmacosx) gui_LTLIBRARIES = $(LTLIBmacosx)
libmacosx_plugin_la_SOURCES = \ libmacosx_plugin_la_SOURCES = \
helpers.h \
about.h about.m \ about.h about.m \
AddonListDataSource.h AddonListDataSource.m \ AddonListDataSource.h AddonListDataSource.m \
AddonsWindowController.h AddonsWindowController.m \ AddonsWindowController.h AddonsWindowController.m \
...@@ -38,6 +39,7 @@ libmacosx_plugin_la_SOURCES = \ ...@@ -38,6 +39,7 @@ libmacosx_plugin_la_SOURCES = \
ExtensionsManager.h ExtensionsManager.m \ ExtensionsManager.h ExtensionsManager.m \
eyetv.h eyetv.m \ eyetv.h eyetv.m \
fspanel.h fspanel.m \ fspanel.h fspanel.m \
intf-prefs.h intf-prefs.m \
intf.h intf.m \ intf.h intf.m \
InputManager.h InputManager.m \ InputManager.h InputManager.m \
iTunes.h \ iTunes.h \
......
...@@ -32,6 +32,10 @@ ...@@ -32,6 +32,10 @@
@interface VLCVoutWindowController : NSObject @interface VLCVoutWindowController : NSObject
+ (VLCVoutWindowController *)sharedInstance;
@property (readonly, atomic) NSLock *lock;
@property (readonly, nonatomic) NSInteger currentStatusWindowLevel; @property (readonly, nonatomic) NSInteger currentStatusWindowLevel;
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition; - (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <vlc_vout_display.h>
#import "CompatibilityFixes.h" #import "CompatibilityFixes.h"
#import "VLCVoutWindowController.h" #import "VLCVoutWindowController.h"
#import "intf.h" #import "intf.h"
...@@ -36,6 +38,162 @@ ...@@ -36,6 +38,162 @@
#import "ResumeDialogController.h" #import "ResumeDialogController.h"
#import "playlist.h" #import "playlist.h"
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
static int WindowControl(vout_window_t *, int i_query, va_list);
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
@autoreleasepool {
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
return VLC_EGENERIC;
msg_Dbg(p_wnd, "Opening video window");
if (!atomic_load(&b_intf_starting)) {
msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
return VLC_EGENERIC;
}
NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
if (!voutController) {
return VLC_EGENERIC;
}
[voutController.lock lock];
SEL sel = @selector(setupVoutForWindow:withProposedVideoViewPosition:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
[inv setTarget:voutController];
[inv setSelector:sel];
[inv setArgument:&p_wnd atIndex:2]; // starting at 2!
[inv setArgument:&proposedVideoViewPosition atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:YES];
VLCVoutView *videoView = nil;
[inv getReturnValue:&videoView];
// this method is not supposed to fail
assert(videoView != nil);
msg_Dbg(VLCIntf, "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView);
[voutController.lock unlock];
p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
p_wnd->control = WindowControl;
return VLC_SUCCESS;
}
}
static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
{
@autoreleasepool {
VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
if (!voutController) {
return VLC_EGENERIC;
}
[voutController.lock lock];
switch(i_query) {
case VOUT_WINDOW_SET_STATE:
{
unsigned i_state = va_arg(args, unsigned);
if (i_state & VOUT_WINDOW_STATE_BELOW)
{
msg_Dbg(p_wnd, "Ignore change to VOUT_WINDOW_STATE_BELOW");
goto out;
}
NSInteger i_cooca_level = NSNormalWindowLevel;
if (i_state & VOUT_WINDOW_STATE_ABOVE)
i_cooca_level = NSStatusWindowLevel;
SEL sel = @selector(setWindowLevel:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
[inv setTarget:voutController];
[inv setSelector:sel];
[inv setArgument:&i_cooca_level atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
break;
}
case VOUT_WINDOW_SET_SIZE:
{
unsigned int i_width = va_arg(args, unsigned int);
unsigned int i_height = va_arg(args, unsigned int);
NSSize newSize = NSMakeSize(i_width, i_height);
SEL sel = @selector(setNativeVideoSize:forWindow:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
[inv setTarget:voutController];
[inv setSelector:sel];
[inv setArgument:&newSize atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
break;
}
case VOUT_WINDOW_SET_FULLSCREEN:
{
if (var_InheritBool(VLCIntf, "video-wallpaper")) {
msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
goto out;
}
int i_full = va_arg(args, int);
BOOL b_animation = YES;
SEL sel = @selector(setFullscreen:forWindow:withAnimation:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
[inv setTarget:voutController];
[inv setSelector:sel];
[inv setArgument:&i_full atIndex:2]; // starting at 2!
[inv setArgument:&p_wnd atIndex:3];
[inv setArgument:&b_animation atIndex:4];
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
waitUntilDone:NO];
break;
}
default:
{
msg_Warn(p_wnd, "unsupported control query");
[voutController.lock unlock];
return VLC_EGENERIC;
}
}
out:
[voutController.lock unlock];
return VLC_SUCCESS;
}
}
void WindowClose(vout_window_t *p_wnd)
{
@autoreleasepool {
VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
if (!voutController) {
return;
}
[voutController.lock lock];
[voutController performSelectorOnMainThread:@selector(removeVoutforDisplay:) withObject:[NSValue valueWithPointer:p_wnd] waitUntilDone:NO];
[voutController.lock unlock];
}
}
@interface VLCVoutWindowController () @interface VLCVoutWindowController ()
{ {
NSMutableDictionary *o_vout_dict; NSMutableDictionary *o_vout_dict;
...@@ -53,13 +211,28 @@ ...@@ -53,13 +211,28 @@
@implementation VLCVoutWindowController @implementation VLCVoutWindowController
+ (VLCVoutWindowController *)sharedInstance
{
static VLCVoutWindowController *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCVoutWindowController new];
});
return sharedInstance;
}
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
o_vout_dict = [[NSMutableDictionary alloc] init]; if (self) {
o_keyboard_backlight = [[KeyboardBacklight alloc] init]; atomic_store(&b_intf_starting, true);
i_currentWindowLevel = NSNormalWindowLevel; o_vout_dict = [[NSMutableDictionary alloc] init];
_currentStatusWindowLevel = NSFloatingWindowLevel; o_keyboard_backlight = [[KeyboardBacklight alloc] init];
i_currentWindowLevel = NSNormalWindowLevel;
_currentStatusWindowLevel = NSFloatingWindowLevel;
}
return self; return self;
} }
......
/***************************************************************************** /*****************************************************************************
* coredialogs.m: Mac OS X Core Dialogs * coredialogs.m: Mac OS X Core Dialogs
***************************************************************************** *****************************************************************************
* Copyright (C) 2005-2012 VLC authors and VideoLAN * Copyright (C) 2005-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Derk-Jan Hartman <hartman at videolan dot org> * Authors: Derk-Jan Hartman <hartman at videolan dot org>
...@@ -29,9 +29,56 @@ ...@@ -29,9 +29,56 @@
/* for the icon in our custom error panel */ /* for the icon in our custom error panel */
#import <ApplicationServices/ApplicationServices.h> #import <ApplicationServices/ApplicationServices.h>
/***************************************************************************** static void updateProgressPanel (void *, const char *, float);
* VLCCoreDialogProvider implementation static bool checkProgressPanel (void *);
*****************************************************************************/ static void destroyProgressPanel (void *);
static int DialogCallback(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
{
@autoreleasepool {
if ([[NSString stringWithUTF8String:type] isEqualToString: @"dialog-progress-bar"]) {
/* the progress panel needs to update itself and therefore wants special treatment within this context */
dialog_progress_bar_t *p_dialog = (dialog_progress_bar_t *)value.p_address;
p_dialog->pf_update = updateProgressPanel;
p_dialog->pf_check = checkProgressPanel;
p_dialog->pf_destroy = destroyProgressPanel;
p_dialog->p_sys = VLCIntf->p_libvlc;
}
NSValue *o_value = [NSValue valueWithPointer:value.p_address];
[[VLCCoreDialogProvider sharedInstance] performEventWithObject: o_value ofType: type];
return VLC_SUCCESS;
}
}
void updateProgressPanel (void *priv, const char *text, float value)
{
@autoreleasepool {
NSString *o_txt = toNSStr(text);
dispatch_async(dispatch_get_main_queue(), ^{
[[VLCCoreDialogProvider sharedInstance] updateProgressPanelWithText: o_txt andNumber: (double)(value * 1000.)];
});
}
}
void destroyProgressPanel (void *priv)
{
@autoreleasepool {
if ([[NSApplication sharedApplication] isRunning])
[[VLCCoreDialogProvider sharedInstance] performSelectorOnMainThread:@selector(destroyProgressPanel) withObject:nil waitUntilDone:YES];
}
}
bool checkProgressPanel (void *priv)
{
@autoreleasepool {
return [[VLCCoreDialogProvider sharedInstance] progressCancelled];
}
}
@interface VLCCoreDialogProvider() @interface VLCCoreDialogProvider()
{ {
ErrorWindowController *o_error_panel; ErrorWindowController *o_error_panel;
...@@ -52,6 +99,39 @@ ...@@ -52,6 +99,39 @@
return sharedInstance; return sharedInstance;
} }
- (instancetype)init
{
self = [super init];
if (self) {
intf_thread_t *p_intf = VLCIntf;
/* subscribe to various interactive dialogues */
var_Create(p_intf, "dialog-error", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-error", DialogCallback, (__bridge void *)self);
var_Create(p_intf, "dialog-critical", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-critical", DialogCallback, (__bridge void *)self);
var_Create(p_intf, "dialog-login", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-login", DialogCallback, (__bridge void *)self);
var_Create(p_intf, "dialog-question", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-question", DialogCallback, (__bridge void *)self);
var_Create(p_intf, "dialog-progress-bar", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-progress-bar", DialogCallback, (__bridge void *)self);
dialog_Register(p_intf);
}
return self;
}
- (void)dealloc
{
intf_thread_t *p_intf = VLCIntf;
dialog_Unregister(p_intf);
var_DelCallback(p_intf, "dialog-error", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-critical", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-login", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-question", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-progress-bar", DialogCallback, (__bridge void *)self);
}
-(void)awakeFromNib -(void)awakeFromNib
{ {
_progressCancelled = NO; _progressCancelled = NO;
......
/*****************************************************************************
* helpers.h
*****************************************************************************
* Copyright (C) 2009-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan org>
* Felix Paul Kühne <fkuehne at videolan dot org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "intf.h"
#import "VideoView.h"
static inline input_thread_t *getInput(void)
{
intf_thread_t *p_intf = VLCIntf;
if (!p_intf)
return NULL;
return pl_CurrentInput(p_intf);
}
static inline vout_thread_t *getVout(void)
{
input_thread_t *p_input = getInput();
if (!p_input)
return NULL;
vout_thread_t *p_vout = input_GetVout(p_input);
vlc_object_release(p_input);
return p_vout;
}
static inline vout_thread_t *getVoutForActiveWindow(void)
{
vout_thread_t *p_vout = nil;
id currentWindow = [NSApp keyWindow];
if ([currentWindow respondsToSelector:@selector(videoView)]) {
VLCVoutView *videoView = [currentWindow videoView];
if (videoView) {
p_vout = [videoView voutThread];
}
}
if (!p_vout)
p_vout = getVout();
return p_vout;
}
static inline audio_output_t *getAout(void)
{
intf_thread_t *p_intf = VLCIntf;
if (!p_intf)
return NULL;
return playlist_GetAout(pl_Get(p_intf));
}
/*****************************************************************************
* intf-prefs.h
*****************************************************************************
* Copyright (C) 2001-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "intf.h"
@interface VLCMain (OldPrefs)
- (void)private_resetAndReinitializeUserDefaults;
- (void)removeOldPreferences;
@end
/*****************************************************************************
* intf-prefs.m
*****************************************************************************
* Copyright (C) 2001-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan org>
* Felix Paul Kühne <fkuehne at videolan dot org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "intf-prefs.h"
#import "CoreInteraction.h"
@implementation VLCMain(OldPrefs)
static NSString * kVLCPreferencesVersion = @"VLCPreferencesVersion";
static const int kCurrentPreferencesVersion = 3;
+ (void)initialize
{
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCurrentPreferencesVersion]
forKey:kVLCPreferencesVersion];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
}
- (void)private_resetAndReinitializeUserDefaults
{
// note that [NSUserDefaults resetStandardUserDefaults] will NOT correctly reset to the defaults
NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];
// set correct version to avoid question about outdated config
[[NSUserDefaults standardUserDefaults] setInteger:kCurrentPreferencesVersion forKey:kVLCPreferencesVersion];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)removeOldPreferences
{
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
int version = [defaults integerForKey:kVLCPreferencesVersion];
/*
* Store version explicitely in file, for ease of debugging.
* Otherwise, the value will be just defined at app startup,
* as initialized above.
*/
[defaults setInteger:version forKey:kVLCPreferencesVersion];
if (version >= kCurrentPreferencesVersion)
return;
if (version == 1) {
[defaults setInteger:kCurrentPreferencesVersion forKey:kVLCPreferencesVersion];
[defaults synchronize];
if (![[VLCCoreInteraction sharedInstance] fixPreferences])
return;
else
config_SaveConfigFile(VLCIntf); // we need to do manually, since we won't quit libvlc cleanly
} else if (version == 2) {
/* version 2 (used by VLC 2.0.x and early versions of 2.1) can lead to exceptions within 2.1 or later
* so we reset the OS X specific prefs here - in practice, no user will notice */
[self resetAndReinitializeUserDefaults];
} else {
NSArray *libraries = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);
if (!libraries || [libraries count] == 0) return;
NSString * preferences = [[libraries firstObject] stringByAppendingPathComponent:@"Preferences"];
int res = NSRunInformationalAlertPanel(_NS("Remove old preferences?"),
_NS("We just found an older version of VLC's preferences files."),
_NS("Move To Trash and Relaunch VLC"), _NS("Ignore"), nil, nil);
if (res != NSOKButton) {
[defaults setInteger:kCurrentPreferencesVersion forKey:kVLCPreferencesVersion];
return;
}
// Do NOT add the current plist file here as this would conflict with caching.
// Instead, just reset below.
NSArray * ourPreferences = [NSArray arrayWithObjects:@"org.videolan.vlc", @"VLC", nil];
/* Move the file to trash one by one. Using above array the method would stop after first file
not found. */
for (NSString *file in ourPreferences) {
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:preferences destination:@"" files:[NSArray arrayWithObject:file] tag:nil];
}
[self resetAndReinitializeUserDefaults];
}
/* Relaunch now */
const char * path = [[[NSBundle mainBundle] executablePath] UTF8String];
/* For some reason we need to fork(), not just execl(), which reports a ENOTSUP then. */
if (fork() != 0) {
exit(0);
}
execl(path, path, NULL);
}
@end
\ No newline at end of file
/***************************************************************************** /*****************************************************************************
* intf.h: MacOS X interface module * intf.h: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2014 VLC authors and VideoLAN * Copyright (C) 2002-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Derk-Jan Hartman <hartman at videolan dot org>
* Derk-Jan Hartman <hartman at videolan dot org>
* Felix Paul Kühne <fkuehne at videolan dot org> * Felix Paul Kühne <fkuehne at videolan dot org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com> * David Fuhrmann <david dot fuhrmann at googlemail dot com>
* Pierre d'Herbemont <pdherbemont # videolan org> * Pierre d'Herbemont <pdherbemont # videolan org>
...@@ -36,9 +35,9 @@ ...@@ -36,9 +35,9 @@
#import <vlc_aout.h> #import <vlc_aout.h>
#import <vlc_input.h> #import <vlc_input.h>
#import <vlc_vout_window.h> #import <vlc_vout_window.h>
#import <vlc_atomic.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "SPMediaKeyTap.h" /* for the media key support */
#import "misc.h" #import "misc.h"
#import "MainWindow.h" #import "MainWindow.h"
#import "VLCVoutWindowController.h" #import "VLCVoutWindowController.h"
...@@ -49,12 +48,6 @@ ...@@ -49,12 +48,6 @@
*****************************************************************************/ *****************************************************************************/
#define VLCIntf [[VLCMain sharedInstance] intf] #define VLCIntf [[VLCMain sharedInstance] intf]
// You need to release those objects after use
input_thread_t *getInput(void);
vout_thread_t *getVout(void);
vout_thread_t *getVoutForActiveWindow(void);
audio_output_t *getAout(void);
static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
/***************************************************************************** /*****************************************************************************
...@@ -65,8 +58,14 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -65,8 +58,14 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCControls; @class VLCControls;
@class VLCMainMenu; @class VLCMainMenu;
@class VLCPlaylist; @class VLCPlaylist;
@class InputManager; @class VLCInputManager;
@class ResumeDialogController; @class ResumeDialogController;
@class VLCSimplePrefs;
@class VLCPrefs;
@class VLCCoreDialogProvider;
@class VLCEyeTVController;
@class VLCBookmarks;
@class VLCOpen;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{ {
...@@ -86,32 +85,23 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -86,32 +85,23 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCMainMenu *)mainMenu; - (VLCMainMenu *)mainMenu;
- (VLCMainWindow *)mainWindow; - (VLCMainWindow *)mainWindow;
- (id)controls; - (VLCControls *)controls;
- (id)bookmarks; - (VLCBookmarks *)bookmarks;
- (id)open; - (VLCOpen *)open;
- (id)simplePreferences; - (VLCSimplePrefs *)simplePreferences;
- (id)preferences; - (VLCPrefs *)preferences;
- (VLCPlaylist *)playlist; - (VLCPlaylist *)playlist;
- (id)coreDialogProvider; - (VLCCoreDialogProvider *)coreDialogProvider;
- (ResumeDialogController *)resumeDialog; - (ResumeDialogController *)resumeDialog;
- (id)eyeTVController; - (VLCEyeTVController *)eyeTVController;
- (id)appleRemoteController; - (VLCInputManager *)inputManager;
- (void)setActiveVideoPlayback:(BOOL)b_value; - (void)setActiveVideoPlayback:(BOOL)b_value;
- (BOOL)activeVideoPlayback; - (BOOL)activeVideoPlayback;
- (void)applicationWillTerminate:(NSNotification *)notification; - (void)applicationWillTerminate:(NSNotification *)notification;
- (void)updateCurrentlyUsedHotkeys; - (void)resetAndReinitializeUserDefaults;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
- (void)plItemUpdated;
- (void)playbackModeUpdated;
- (void)showFullscreenController; - (void)showFullscreenController;
- (void)updateTogglePlaylistState;
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
- (void)resetAndReinitializeUserDefaults;
- (BOOL)isTerminating; - (BOOL)isTerminating;
@end @end
...@@ -124,3 +114,5 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -124,3 +114,5 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@interface VLCApplication : NSApplication @interface VLCApplication : NSApplication
@end @end
#import "helpers.h"
This diff is collapsed.
...@@ -75,6 +75,8 @@ ...@@ -75,6 +75,8 @@
- (IBAction)searchItem:(id)sender; - (IBAction)searchItem:(id)sender;
- (void)playlistUpdated; - (void)playlistUpdated;
- (void)playbackModeUpdated;
- (void)updateTogglePlaylistState;
- (void)outlineViewSelectionDidChange:(NSNotification *)notification; - (void)outlineViewSelectionDidChange:(NSNotification *)notification;
- (void)sortNode:(int)i_mode; - (void)sortNode:(int)i_mode;
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#import "open.h" #import "open.h"
#import "MainMenu.h" #import "MainMenu.h"
#import "CoreInteraction.h" #import "CoreInteraction.h"
#import "ControlsBar.h"
#import "ResumeDialogController.h" #import "ResumeDialogController.h"
...@@ -57,6 +58,61 @@ ...@@ -57,6 +58,61 @@
#import <vlc_interface.h> #import <vlc_interface.h>
#include <vlc_url.h> #include <vlc_url.h>
static int PLItemUpdated(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@autoreleasepool {
[[[VLCMain sharedInstance] playlist] performSelectorOnMainThread:@selector(plItemUpdated) withObject:nil waitUntilDone:NO];
return VLC_SUCCESS;
}
}
static int PLItemAppended(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@autoreleasepool {
playlist_add_t *p_add = new_val.p_address;
NSArray *o_val = [NSArray arrayWithObjects:[NSNumber numberWithInt:p_add->i_node], [NSNumber numberWithInt:p_add->i_item], nil];
[[[VLCMain sharedInstance] playlist] performSelectorOnMainThread:@selector(plItemAppended:) withObject:o_val waitUntilDone:NO];
return VLC_SUCCESS;
}
}
static int PLItemRemoved(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@autoreleasepool {
NSNumber *o_val = [NSNumber numberWithInt:new_val.i_int];
[[[VLCMain sharedInstance] playlist] performSelectorOnMainThread:@selector(plItemRemoved:) withObject:o_val waitUntilDone:NO];
return VLC_SUCCESS;
}
}
static int PlaybackModeUpdated(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@autoreleasepool {
[[[VLCMain sharedInstance] playlist] performSelectorOnMainThread:@selector(playbackModeUpdated) withObject:nil waitUntilDone:NO];
return VLC_SUCCESS;
}
}
static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@autoreleasepool {
dispatch_async(dispatch_get_main_queue(), ^{
[[[VLCMain sharedInstance] mainWindow] updateVolumeSlider];
});
return VLC_SUCCESS;
}
}
/***************************************************************************** /*****************************************************************************
* VLCPlaylistView implementation * VLCPlaylistView implementation
*****************************************************************************/ *****************************************************************************/
...@@ -179,6 +235,36 @@ ...@@ -179,6 +235,36 @@
[defaults registerDefaults:appDefaults]; [defaults registerDefaults:appDefaults];
} }
- (instancetype)init
{
self = [super init];
if (self) {
playlist_t *p_playlist = pl_Get(VLCIntf);
var_AddCallback(p_playlist, "item-change", PLItemUpdated, (__bridge void *)self);
var_AddCallback(p_playlist, "playlist-item-append", PLItemAppended, (__bridge void *)self);
var_AddCallback(p_playlist, "playlist-item-deleted", PLItemRemoved, (__bridge void *)self);
var_AddCallback(p_playlist, "random", PlaybackModeUpdated, (__bridge void *)self);
var_AddCallback(p_playlist, "repeat", PlaybackModeUpdated, (__bridge void *)self);
var_AddCallback(p_playlist, "loop", PlaybackModeUpdated, (__bridge void *)self);
var_AddCallback(p_playlist, "volume", VolumeUpdated, (__bridge void *)self);
var_AddCallback(p_playlist, "mute", VolumeUpdated, (__bridge void *)self);
}
return self;
}
- (void)dealloc
{
playlist_t *p_playlist = pl_Get(VLCIntf);
var_DelCallback(p_playlist, "item-change", PLItemUpdated, (__bridge void *)self);
var_DelCallback(p_playlist, "playlist-item-append", PLItemAppended, (__bridge void *)self);
var_DelCallback(p_playlist, "playlist-item-deleted", PLItemRemoved, (__bridge void *)self);
var_DelCallback(p_playlist, "random", PlaybackModeUpdated, (__bridge void *)self);
var_DelCallback(p_playlist, "repeat", PlaybackModeUpdated, (__bridge void *)self);
var_DelCallback(p_playlist, "loop", PlaybackModeUpdated, (__bridge void *)self);
var_DelCallback(p_playlist, "volume", VolumeUpdated, (__bridge void *)self);
var_DelCallback(p_playlist, "mute", VolumeUpdated, (__bridge void *)self);
}
- (PLModel *)model - (PLModel *)model
{ {
return o_model; return o_model;
...@@ -284,6 +370,73 @@ ...@@ -284,6 +370,73 @@
[o_outline_view reloadData]; [o_outline_view reloadData];
} }
- (void)plItemAppended:(NSArray *)o_val
{
int i_node = [[o_val firstObject] intValue];
int i_item = [[o_val objectAtIndex:1] intValue];
[[self model] addItem:i_item withParentNode:i_node];
// update badge in sidebar
[[[VLCMain sharedInstance] mainWindow] updateWindow];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
}
- (void)plItemRemoved:(NSNumber *)o_val
{
int i_item = [o_val intValue];
[[self model] removeItem:i_item];
[self deletionCompleted];
// update badge in sidebar
[[[VLCMain sharedInstance] mainWindow] updateWindow];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged"
object: nil
userInfo: nil];
}
- (void)plItemUpdated
{
VLCMain *instance = [VLCMain sharedInstance];
[[instance mainWindow] updateName];
[[VLCInfo sharedInstance] updateMetadata];
}
- (void)playbackModeUpdated
{
playlist_t * p_playlist = pl_Get(VLCIntf);
bool loop = var_GetBool(p_playlist, "loop");
bool repeat = var_GetBool(p_playlist, "repeat");
VLCMainWindowControlsBar *controlsBar = (VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] mainWindow] controlsBar];
VLCMainMenu *mainMenu = [[VLCMain sharedInstance] mainMenu];
if (repeat) {
[controlsBar setRepeatOne];
[mainMenu setRepeatOne];
} else if (loop) {
[controlsBar setRepeatAll];
[mainMenu setRepeatAll];
} else {
[controlsBar setRepeatOff];
[mainMenu setRepeatOff];
}
[controlsBar setShuffle];
[mainMenu setShuffle];
}
- (void)updateTogglePlaylistState
{
[self outlineViewSelectionDidChange: NULL];
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification - (void)outlineViewSelectionDidChange:(NSNotification *)notification
{ {
// // FIXME: unsafe // // FIXME: unsafe
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#import <vlc_config_cat.h> #import <vlc_config_cat.h>
#import "misc.h" #import "misc.h"
#import "intf.h" #import "intf.h"
#import "intf-prefs.h"
#import "AppleRemote.h" #import "AppleRemote.h"
#import "CoreInteraction.h" #import "CoreInteraction.h"
...@@ -948,9 +949,9 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha ...@@ -948,9 +949,9 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
/* activate stuff without restart */ /* activate stuff without restart */
if ([_intf_appleremoteCheckbox state] == YES) if ([_intf_appleremoteCheckbox state] == YES)
[[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]]; [[VLCCoreInteraction sharedInstance] startListeningWithAppleRemote];
else else
[[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]]; [[VLCCoreInteraction sharedInstance] stopListeningWithAppleRemote];
_intfSettingChanged = NO; _intfSettingChanged = NO;
} }
......
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