macosx: rename to VLCCoreInteraction
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Mon, 8 Aug 2016 16:25:06 +0000 (18:25 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Mon, 8 Aug 2016 16:47:29 +0000 (18:47 +0200)
23 files changed:
extras/package/macosx/vlc.xcodeproj/project.pbxproj
modules/gui/macosx/ControlsBar.m
modules/gui/macosx/CoreInteraction.h [deleted file]
modules/gui/macosx/CoreInteraction.m [deleted file]
modules/gui/macosx/MainWindowTitle.m
modules/gui/macosx/Makefile.am
modules/gui/macosx/VLCCoreInteraction.h [new file with mode: 0644]
modules/gui/macosx/VLCCoreInteraction.m [new file with mode: 0644]
modules/gui/macosx/VLCInputManager.m
modules/gui/macosx/VLCMainMenu.m
modules/gui/macosx/VLCMainWindow.m
modules/gui/macosx/VLCStatusBarIcon.m
modules/gui/macosx/VLCTrackSynchronizationWindowController.m
modules/gui/macosx/VLCVideoEffectsWindowController.m
modules/gui/macosx/VideoView.m
modules/gui/macosx/Windows.m
modules/gui/macosx/applescript.m
modules/gui/macosx/fspanel.m
modules/gui/macosx/intf-prefs.m
modules/gui/macosx/intf.m
modules/gui/macosx/misc.m
modules/gui/macosx/prefs.m
modules/gui/macosx/simple_prefs.m

index f7848e8..30c772c 100644 (file)
                1CCB5F631A62A724004C3E90 /* VLCConvertAndSaveWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0663351566C34C003A411C /* VLCConvertAndSaveWindowController.m */; };
                1CCB5F641A62A724004C3E90 /* VLCCoreDialogProvider.h in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */; };
                1CCB5F651A62A724004C3E90 /* VLCCoreDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */; };
-               1CCB5F661A62A724004C3E90 /* CoreInteraction.h in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6013B68A0B009F72E0 /* CoreInteraction.h */; };
-               1CCB5F671A62A724004C3E90 /* CoreInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6113B68A0B009F72E0 /* CoreInteraction.m */; };
+               1CCB5F661A62A724004C3E90 /* VLCCoreInteraction.h in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6013B68A0B009F72E0 /* VLCCoreInteraction.h */; };
+               1CCB5F671A62A724004C3E90 /* VLCCoreInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */; };
                1CCB5F681A62A724004C3E90 /* VLCDebugMessageWindowController.h in Sources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B318302AC000FAE9B7 /* VLCDebugMessageWindowController.h */; };
                1CCB5F691A62A724004C3E90 /* VLCDebugMessageWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B418302AC000FAE9B7 /* VLCDebugMessageWindowController.m */; };
                1CCB5F6A1A62A724004C3E90 /* ExtensionsDialogProvider.h in Sources */ = {isa = PBXBuildFile; fileRef = 5CCED71014C0D4A90057F8D1 /* ExtensionsDialogProvider.h */; };
                CC426FD01020D44F00A32659 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = ../../../contrib/Sparkle.framework; sourceTree = "<absolute>"; };
                CC448A5A13B61D49009F72E0 /* VLCMainMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCMainMenu.h; path = ../../../modules/gui/macosx/VLCMainMenu.h; sourceTree = SOURCE_ROOT; };
                CC448A5B13B61D49009F72E0 /* VLCMainMenu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCMainMenu.m; path = ../../../modules/gui/macosx/VLCMainMenu.m; sourceTree = SOURCE_ROOT; };
-               CC448A6013B68A0B009F72E0 /* CoreInteraction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CoreInteraction.h; path = ../../../modules/gui/macosx/CoreInteraction.h; sourceTree = SOURCE_ROOT; };
-               CC448A6113B68A0B009F72E0 /* CoreInteraction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CoreInteraction.m; path = ../../../modules/gui/macosx/CoreInteraction.m; sourceTree = SOURCE_ROOT; };
+               CC448A6013B68A0B009F72E0 /* VLCCoreInteraction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCCoreInteraction.h; path = ../../../modules/gui/macosx/VLCCoreInteraction.h; sourceTree = SOURCE_ROOT; };
+               CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCCoreInteraction.m; path = ../../../modules/gui/macosx/VLCCoreInteraction.m; sourceTree = SOURCE_ROOT; };
                CC448A6213B68A0B009F72E0 /* VLCMainWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCMainWindow.h; path = ../../../modules/gui/macosx/VLCMainWindow.h; sourceTree = SOURCE_ROOT; };
                CC448A6313B68A0B009F72E0 /* VLCMainWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCMainWindow.m; path = ../../../modules/gui/macosx/VLCMainWindow.m; sourceTree = SOURCE_ROOT; };
                CC461F6C160078340022423C /* SharedDialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = SharedDialogs.h; path = ../../../modules/gui/macosx/SharedDialogs.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
                                CC0663351566C34C003A411C /* VLCConvertAndSaveWindowController.m */,
                                CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */,
                                CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */,
-                               CC448A6013B68A0B009F72E0 /* CoreInteraction.h */,
-                               CC448A6113B68A0B009F72E0 /* CoreInteraction.m */,
+                               CC448A6013B68A0B009F72E0 /* VLCCoreInteraction.h */,
+                               CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */,
                                7D8BB0B318302AC000FAE9B7 /* VLCDebugMessageWindowController.h */,
                                7D8BB0B418302AC000FAE9B7 /* VLCDebugMessageWindowController.m */,
                                5CCED71014C0D4A90057F8D1 /* ExtensionsDialogProvider.h */,
                                1CCB5F631A62A724004C3E90 /* VLCConvertAndSaveWindowController.m in Sources */,
                                1CCB5F641A62A724004C3E90 /* VLCCoreDialogProvider.h in Sources */,
                                1CCB5F651A62A724004C3E90 /* VLCCoreDialogProvider.m in Sources */,
-                               1CCB5F661A62A724004C3E90 /* CoreInteraction.h in Sources */,
+                               1CCB5F661A62A724004C3E90 /* VLCCoreInteraction.h in Sources */,
                                6BBBB8AA1D108A17001BD9BA /* VLCRendererDialog.m in Sources */,
-                               1CCB5F671A62A724004C3E90 /* CoreInteraction.m in Sources */,
+                               1CCB5F671A62A724004C3E90 /* VLCCoreInteraction.m in Sources */,
                                1CCB5F681A62A724004C3E90 /* VLCDebugMessageWindowController.h in Sources */,
                                1CCB5F691A62A724004C3E90 /* VLCDebugMessageWindowController.m in Sources */,
                                6B846FE51CF5D88C00112E54 /* VLCHUDCheckboxCell.m in Sources */,
index 8eba56f..28f8a8b 100644 (file)
@@ -24,7 +24,7 @@
 
 #import "ControlsBar.h"
 #import "intf.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCMainMenu.h"
 #import "fspanel.h"
 #import "VLCPlaylist.h"
diff --git a/modules/gui/macosx/CoreInteraction.h b/modules/gui/macosx/CoreInteraction.h
deleted file mode 100644 (file)
index f00cef2..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************************
- * CoreInteraction.h: MacOS X interface module
- *****************************************************************************
- * Copyright (C) 2011-2015 Felix Paul Kühne
- * $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 <Cocoa/Cocoa.h>
-
-@interface VLCCoreInteraction : NSObject
-
-+ (VLCCoreInteraction *)sharedInstance;
-@property (readwrite) int volume;
-@property (readonly, nonatomic) float maxVolume;
-@property (readwrite) int playbackRate;
-@property (nonatomic, readwrite) BOOL aspectRatioIsLocked;
-@property (readonly) int durationOfCurrentPlaylistItem;
-@property (readonly) NSURL * URLOfCurrentPlaylistItem;
-@property (readonly) NSString * nameOfCurrentPlaylistItem;
-@property (nonatomic, readwrite) BOOL mute;
-
-- (void)playOrPause;
-- (void)pause;
-- (void)stop;
-- (void)faster;
-- (void)slower;
-- (void)normalSpeed;
-- (void)toggleRecord;
-- (void)next;
-- (void)previous;
-- (void)forward;        //LEGACY SUPPORT
-- (void)backward;       //LEGACY SUPPORT
-- (void)forwardExtraShort;
-- (void)backwardExtraShort;
-- (void)forwardShort;
-- (void)backwardShort;
-- (void)forwardMedium;
-- (void)backwardMedium;
-- (void)forwardLong;
-- (void)backwardLong;
-
-- (void)repeatOne;
-- (void)repeatAll;
-- (void)repeatOff;
-- (void)shuffle;
-- (void)setAtoB;
-- (void)resetAtoB;
-- (void)updateAtoB;
-
-- (void)volumeUp;
-- (void)volumeDown;
-- (void)toggleMute;
-- (void)showPosition;
-- (void)startListeningWithAppleRemote;
-- (void)stopListeningWithAppleRemote;
-
-- (void)menuFocusActivate;
-- (void)moveMenuFocusLeft;
-- (void)moveMenuFocusRight;
-- (void)moveMenuFocusUp;
-- (void)moveMenuFocusDown;
-
-- (void)addSubtitlesToCurrentInput:(NSArray *)paths;
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
-
-- (void)toggleFullscreen;
-
-- (BOOL)fixPreferences;
-
-- (void)setVideoFilter: (const char *)psz_name on:(BOOL)b_on;
-- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter integer: (int)i_value;
-- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter float: (float)f_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;
-
-- (BOOL)keyEvent:(NSEvent *)o_event;
-- (void)updateCurrentlyUsedHotkeys;
-- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
-
-@end
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
deleted file mode 100644 (file)
index 78e8946..0000000
+++ /dev/null
@@ -1,1359 +0,0 @@
-/*****************************************************************************
- * CoreInteraction.m: MacOS X interface module
- *****************************************************************************
- * Copyright (C) 2011-2015 Felix Paul Kühne
- * $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 "CoreInteraction.h"
-#import "intf.h"
-#import "open.h"
-#import "VLCPlaylist.h"
-#import <math.h>
-#import <vlc_playlist.h>
-#import <vlc_input.h>
-#import <vlc_keys.h>
-#import <vlc_vout.h>
-#import <vlc_vout_osd.h>
-#import <vlc/vlc.h>
-#import <vlc_strings.h>
-#import <vlc_url.h>
-#import <vlc_modules.h>
-#import <vlc_charset.h>
-#include <vlc_plugin.h>
-#import "SPMediaKeyTap.h"
-#import "AppleRemote.h"
-#import "VLCInputManager.h"
-
-static int BossCallback(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(), ^{
-            [[VLCCoreInteraction sharedInstance] pause];
-            [[NSApplication sharedApplication] hide:nil];
-        });
-
-        return VLC_SUCCESS;
-    }
-}
-
-@interface VLCCoreInteraction ()
-{
-    int i_currentPlaybackRate;
-    mtime_t timeA, timeB;
-
-    float f_maxVolume;
-
-    /* media key support */
-    BOOL b_mediaKeySupport;
-    BOOL b_mediakeyJustJumped;
-    SPMediaKeyTap *_mediaKeyController;
-    BOOL b_mediaKeyTrapEnabled;
-
-    AppleRemote *_remote;
-    BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
-
-    NSArray *_usedHotkeys;
-}
-@end
-
-@implementation VLCCoreInteraction
-
-#pragma mark - Initialization
-
-+ (VLCCoreInteraction *)sharedInstance
-{
-    static VLCCoreInteraction *sharedInstance = nil;
-    static dispatch_once_t pred;
-
-    dispatch_once(&pred, ^{
-        sharedInstance = [VLCCoreInteraction new];
-    });
-
-    return sharedInstance;
-}
-
-- (instancetype)init
-{
-    self = [super init];
-    if (self) {
-        intf_thread_t *p_intf = getIntf();
-
-        /* init media key support */
-        b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
-        if (b_mediaKeySupport) {
-            _mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
-            [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
-                                                                     [SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
-                                                                     nil]];
-        }
-        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
-
-        /* init Apple Remote support */
-        _remote = [[AppleRemote alloc] init];
-        [_remote setClickCountEnabledButtons: kRemoteButtonPlay];
-        [_remote setDelegate: self];
-
-        var_AddCallback(p_intf->obj.libvlc, "intf-boss", BossCallback, (__bridge void *)self);
-    }
-    return self;
-}
-
-- (void)dealloc
-{
-    intf_thread_t *p_intf = getIntf();
-    var_DelCallback(p_intf->obj.libvlc, "intf-boss", BossCallback, (__bridge void *)self);
-    [[NSNotificationCenter defaultCenter] removeObserver: self];
-}
-
-
-#pragma mark - Playback Controls
-
-- (void)playOrPause
-{
-    input_thread_t *p_input = pl_CurrentInput(getIntf());
-    playlist_t *p_playlist = pl_Get(getIntf());
-
-    if (p_input) {
-        playlist_TogglePause(p_playlist);
-        vlc_object_release(p_input);
-
-    } else {
-        PLRootType root = [[[[VLCMain sharedInstance] playlist] model] currentRootType];
-        if ([[[VLCMain sharedInstance] playlist] isSelectionEmpty] && (root == ROOT_TYPE_PLAYLIST || root == ROOT_TYPE_MEDIALIBRARY))
-            [[[VLCMain sharedInstance] open] openFileGeneric];
-        else
-            [[[VLCMain sharedInstance] playlist] playItem:nil];
-    }
-}
-
-- (void)pause
-{
-    playlist_t *p_playlist = pl_Get(getIntf());
-
-    playlist_Pause(p_playlist);
-}
-
-- (void)stop
-{
-    playlist_Stop(pl_Get(getIntf()));
-}
-
-- (void)faster
-{
-    var_TriggerCallback(pl_Get(getIntf()), "rate-faster");
-}
-
-- (void)slower
-{
-    var_TriggerCallback(pl_Get(getIntf()), "rate-slower");
-}
-
-- (void)normalSpeed
-{
-    var_SetFloat(pl_Get(getIntf()), "rate", 1.);
-}
-
-- (void)toggleRecord
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    input_thread_t * p_input;
-    p_input = pl_CurrentInput(p_intf);
-    if (p_input) {
-        var_ToggleBool(p_input, "record");
-        vlc_object_release(p_input);
-    }
-}
-
-- (void)setPlaybackRate:(int)i_value
-{
-    playlist_t * p_playlist = pl_Get(getIntf());
-
-    double speed = pow(2, (double)i_value / 17);
-    int rate = INPUT_RATE_DEFAULT / speed;
-    if (i_currentPlaybackRate != rate)
-        var_SetFloat(p_playlist, "rate", (float)INPUT_RATE_DEFAULT / (float)rate);
-    i_currentPlaybackRate = rate;
-}
-
-- (int)playbackRate
-{
-    float f_rate;
-
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return 0;
-
-    input_thread_t * p_input;
-    p_input = pl_CurrentInput(p_intf);
-    if (p_input) {
-        f_rate = var_GetFloat(p_input, "rate");
-        vlc_object_release(p_input);
-    }
-    else
-    {
-        playlist_t * p_playlist = pl_Get(getIntf());
-        f_rate = var_GetFloat(p_playlist, "rate");
-    }
-
-    double value = 17 * log(f_rate) / log(2.);
-    int returnValue = (int) ((value > 0) ? value + .5 : value - .5);
-
-    if (returnValue < -34)
-        returnValue = -34;
-    else if (returnValue > 34)
-        returnValue = 34;
-
-    i_currentPlaybackRate = returnValue;
-    return returnValue;
-}
-
-- (void)previous
-{
-    playlist_Prev(pl_Get(getIntf()));
-}
-
-- (void)next
-{
-    playlist_Next(pl_Get(getIntf()));
-}
-
-- (int)durationOfCurrentPlaylistItem
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return 0;
-
-    input_thread_t * p_input = pl_CurrentInput(p_intf);
-    int64_t i_duration = -1;
-    if (!p_input)
-        return i_duration;
-
-    input_Control(p_input, INPUT_GET_LENGTH, &i_duration);
-    vlc_object_release(p_input);
-
-    return (int)(i_duration / 1000000);
-}
-
-- (NSURL*)URLOfCurrentPlaylistItem
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return nil;
-
-    input_thread_t *p_input = pl_CurrentInput(p_intf);
-    if (!p_input)
-        return nil;
-
-    input_item_t *p_item = input_GetItem(p_input);
-    if (!p_item) {
-        vlc_object_release(p_input);
-        return nil;
-    }
-
-    char *psz_uri = input_item_GetURI(p_item);
-    if (!psz_uri) {
-        vlc_object_release(p_input);
-        return nil;
-    }
-
-    NSURL *o_url;
-    o_url = [NSURL URLWithString:toNSStr(psz_uri)];
-    vlc_object_release(p_input);
-
-    return o_url;
-}
-
-- (NSString*)nameOfCurrentPlaylistItem
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return nil;
-
-    input_thread_t *p_input = pl_CurrentInput(p_intf);
-    if (!p_input)
-        return nil;
-
-    input_item_t *p_item = input_GetItem(p_input);
-    if (!p_item) {
-        vlc_object_release(p_input);
-        return nil;
-    }
-
-    char *psz_uri = input_item_GetURI(p_item);
-    if (!psz_uri) {
-        vlc_object_release(p_input);
-        return nil;
-    }
-
-    NSString *o_name = @"";
-    char *format = var_InheritString(getIntf(), "input-title-format");
-    if (format) {
-        char *formated = vlc_strfinput(p_input, format);
-        free(format);
-        o_name = toNSStr(formated);
-        free(formated);
-    }
-
-    NSURL * o_url = [NSURL URLWithString:toNSStr(psz_uri)];
-    free(psz_uri);
-
-    if ([o_name isEqualToString:@""]) {
-        if ([o_url isFileURL])
-            o_name = [[NSFileManager defaultManager] displayNameAtPath:[o_url path]];
-        else
-            o_name = [o_url absoluteString];
-    }
-    vlc_object_release(p_input);
-    return o_name;
-}
-
-- (void)forward
-{
-    //LEGACY SUPPORT
-    [self forwardShort];
-}
-
-- (void)backward
-{
-    //LEGACY SUPPORT
-    [self backwardShort];
-}
-
-- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value
-{
-    input_thread_t *p_input = pl_CurrentInput(getIntf());
-    if (!p_input)
-        return;
-
-    int i_interval = var_InheritInteger( p_input, p_value );
-    if (i_interval > 0) {
-        mtime_t val = CLOCK_FREQ * i_interval;
-        if (!b_value)
-            val = val * -1;
-        var_SetInteger( p_input, "time-offset", val );
-    }
-    vlc_object_release(p_input);
-}
-
-- (void)forwardExtraShort
-{
-    [self jumpWithValue:"extrashort-jump-size" forward:YES];
-}
-
-- (void)backwardExtraShort
-{
-    [self jumpWithValue:"extrashort-jump-size" forward:NO];
-}
-
-- (void)forwardShort
-{
-    [self jumpWithValue:"short-jump-size" forward:YES];
-}
-
-- (void)backwardShort
-{
-    [self jumpWithValue:"short-jump-size" forward:NO];
-}
-
-- (void)forwardMedium
-{
-    [self jumpWithValue:"medium-jump-size" forward:YES];
-}
-
-- (void)backwardMedium
-{
-    [self jumpWithValue:"medium-jump-size" forward:NO];
-}
-
-- (void)forwardLong
-{
-    [self jumpWithValue:"long-jump-size" forward:YES];
-}
-
-- (void)backwardLong
-{
-    [self jumpWithValue:"long-jump-size" forward:NO];
-}
-
-- (void)shuffle
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    vlc_value_t val;
-    playlist_t * p_playlist = pl_Get(p_intf);
-    vout_thread_t *p_vout = getVout();
-
-    var_Get(p_playlist, "random", &val);
-    val.b_bool = !val.b_bool;
-    var_Set(p_playlist, "random", val);
-    if (val.b_bool) {
-        if (p_vout) {
-            vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Random On"));
-            vlc_object_release(p_vout);
-        }
-        config_PutInt(p_playlist, "random", 1);
-    }
-    else
-    {
-        if (p_vout) {
-            vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Random Off"));
-            vlc_object_release(p_vout);
-        }
-        config_PutInt(p_playlist, "random", 0);
-    }
-}
-
-- (void)repeatAll
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_t * p_playlist = pl_Get(p_intf);
-
-    var_SetBool(p_playlist, "repeat", NO);
-    var_SetBool(p_playlist, "loop", YES);
-    config_PutInt(p_playlist, "repeat", NO);
-    config_PutInt(p_playlist, "loop", YES);
-
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Repeat All"));
-        vlc_object_release(p_vout);
-    }
-}
-
-- (void)repeatOne
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_t * p_playlist = pl_Get(p_intf);
-
-    var_SetBool(p_playlist, "repeat", YES);
-    var_SetBool(p_playlist, "loop", NO);
-    config_PutInt(p_playlist, "repeat", YES);
-    config_PutInt(p_playlist, "loop", NO);
-
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Repeat One"));
-        vlc_object_release(p_vout);
-    }
-}
-
-- (void)repeatOff
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_t * p_playlist = pl_Get(p_intf);
-
-    var_SetBool(p_playlist, "repeat", NO);
-    var_SetBool(p_playlist, "loop", NO);
-    config_PutInt(p_playlist, "repeat", NO);
-    config_PutInt(p_playlist, "loop", NO);
-
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Repeat Off"));
-        vlc_object_release(p_vout);
-    }
-}
-
-- (void)setAtoB
-{
-    if (!timeA) {
-        input_thread_t * p_input = pl_CurrentInput(getIntf());
-        if (p_input) {
-            timeA = var_GetInteger(p_input, "time");
-            vlc_object_release(p_input);
-        }
-    } else if (!timeB) {
-        input_thread_t * p_input = pl_CurrentInput(getIntf());
-        if (p_input) {
-            timeB = var_GetInteger(p_input, "time");
-            vlc_object_release(p_input);
-        }
-    } else
-        [self resetAtoB];
-}
-
-- (void)resetAtoB
-{
-    timeA = 0;
-    timeB = 0;
-}
-
-- (void)updateAtoB
-{
-    if (timeB) {
-        input_thread_t * p_input = pl_CurrentInput(getIntf());
-        if (p_input) {
-            mtime_t currentTime = var_GetInteger(p_input, "time");
-            if ( currentTime >= timeB || currentTime < timeA)
-                var_SetInteger(p_input, "time", timeA);
-            vlc_object_release(p_input);
-        }
-    }
-}
-
-- (void)volumeUp
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_VolumeUp(pl_Get(p_intf), 1, NULL);
-}
-
-- (void)volumeDown
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_VolumeDown(pl_Get(p_intf), 1, NULL);
-}
-
-- (void)toggleMute
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_MuteToggle(pl_Get(p_intf));
-}
-
-- (BOOL)mute
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return NO;
-
-    BOOL b_is_muted = NO;
-    b_is_muted = playlist_MuteGet(pl_Get(p_intf)) > 0;
-
-    return b_is_muted;
-}
-
-- (int)volume
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return 0;
-
-    float volume = playlist_VolumeGet(pl_Get(p_intf));
-
-    return lroundf(volume * AOUT_VOLUME_DEFAULT);
-}
-
-- (void)setVolume: (int)i_value
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    if (i_value >= self.maxVolume)
-        i_value = self.maxVolume;
-
-    float f_value = i_value / (float)AOUT_VOLUME_DEFAULT;
-
-    playlist_VolumeSet(pl_Get(p_intf), f_value);
-}
-
-- (float)maxVolume
-{
-    if (f_maxVolume == 0.) {
-        f_maxVolume = (float)var_InheritInteger(getIntf(), "macosx-max-volume") / 100. * AOUT_VOLUME_DEFAULT;
-    }
-
-    return f_maxVolume;
-}
-
-- (void)addSubtitlesToCurrentInput:(NSArray *)paths
-{
-    input_thread_t * p_input = pl_CurrentInput(getIntf());
-    if (!p_input)
-        return;
-
-    NSUInteger count = [paths count];
-
-    for (int i = 0; i < count ; i++) {
-        const char *path = [[[paths objectAtIndex:i] path] UTF8String];
-        msg_Dbg(getIntf(), "loading subs from %s", path);
-
-        int i_result = input_AddSubtitleOSD(p_input, path, true, true);
-        if (i_result != VLC_SUCCESS)
-            msg_Warn(getIntf(), "unable to load subtitles from '%s'", path);
-    }
-    vlc_object_release(p_input);
-}
-
-- (void)showPosition
-{
-    input_thread_t *p_input = pl_CurrentInput(getIntf());
-    if (p_input != NULL) {
-        vout_thread_t *p_vout = input_GetVout(p_input);
-        if (p_vout != NULL) {
-            var_SetInteger(getIntf()->obj.libvlc, "key-action", ACTIONID_POSITION);
-            vlc_object_release(p_vout);
-        }
-        vlc_object_release(p_input);
-    }
-}
-
-#pragma mark - Drop support for files into the video, controls bar or drop box
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
-{
-    NSArray *items = [[[VLCMain sharedInstance] playlist] createItemsFromExternalPasteboard:[sender draggingPasteboard]];
-
-    if (items.count == 0)
-        return NO;
-
-    // Try to add file as a subtitle
-    input_thread_t *p_input = pl_CurrentInput(getIntf());
-    if (items.count == 1 && p_input) {
-        NSString *url = [[items firstObject] valueForKey:@"ITEM_URL"];
-        char *path = vlc_uri2path([url UTF8String]);
-
-        if (path) {
-            int i_result = input_AddSubtitleOSD(p_input, path, true, true);
-            free(path);
-            if (i_result == VLC_SUCCESS) {
-                vlc_object_release(p_input);
-                return YES;
-            }
-        }
-    }
-
-    if (p_input)
-        vlc_object_release(p_input);
-
-    [[[VLCMain sharedInstance] playlist] addPlaylistItems:items];
-    return YES;
-}
-
-#pragma mark - video output stuff
-
-- (void)setAspectRatioIsLocked:(BOOL)b_value
-{
-    config_PutInt(getIntf(), "macosx-lock-aspect-ratio", b_value);
-}
-
-- (BOOL)aspectRatioIsLocked
-{
-    return config_GetInt(getIntf(), "macosx-lock-aspect-ratio");
-}
-
-- (void)toggleFullscreen
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    vout_thread_t *p_vout = getVoutForActiveWindow();
-    if (p_vout) {
-        BOOL b_fs = var_ToggleBool(p_vout, "fullscreen");
-        var_SetBool(pl_Get(p_intf), "fullscreen", b_fs);
-        vlc_object_release(p_vout);
-    } else { // e.g. lion fullscreen toggle
-        BOOL b_fs = var_ToggleBool(pl_Get(p_intf), "fullscreen");
-        [[[VLCMain sharedInstance] voutController] setFullscreen:b_fs forWindow:nil withAnimation:YES];
-    }
-}
-
-#pragma mark - uncommon stuff
-
-- (BOOL)fixPreferences
-{
-    NSMutableString * o_workString;
-    NSRange returnedRange;
-    NSRange fullRange;
-    BOOL b_needsRestart = NO;
-
-    #define fixpref(pref) \
-    o_workString = [[NSMutableString alloc] initWithFormat:@"%s", config_GetPsz(getIntf(), pref)]; \
-    if ([o_workString length] > 0) \
-    { \
-        returnedRange = [o_workString rangeOfString:@"macosx" options: NSCaseInsensitiveSearch]; \
-        if (returnedRange.location != NSNotFound) \
-        { \
-            if ([o_workString isEqualToString:@"macosx"]) \
-                [o_workString setString:@""]; \
-            fullRange = NSMakeRange(0, [o_workString length]); \
-            [o_workString replaceOccurrencesOfString:@":macosx" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
-            fullRange = NSMakeRange(0, [o_workString length]); \
-            [o_workString replaceOccurrencesOfString:@"macosx:" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
-            \
-            config_PutPsz(getIntf(), pref, [o_workString UTF8String]); \
-            b_needsRestart = YES; \
-        } \
-    }
-
-    fixpref("control");
-    fixpref("extraintf");
-    #undef fixpref
-
-    return b_needsRestart;
-}
-
-#pragma mark - video filter handling
-
-- (const char *)getFilterType:(const char *)psz_name
-{
-    module_t *p_obj = module_find(psz_name);
-    if (!p_obj) {
-        return NULL;
-    }
-
-    if (module_provides(p_obj, "video splitter")) {
-        return "video-splitter";
-    } else if (module_provides(p_obj, "video filter2")) {
-        return "video-filter";
-    } else if (module_provides(p_obj, "sub source")) {
-        return "sub-source";
-    } else if (module_provides(p_obj, "sub filter")) {
-        return "sub-filter";
-    } else {
-        msg_Err(getIntf(), "Unknown video filter type.");
-        return NULL;
-    }
-}
-
-- (void)setVideoFilter: (const char *)psz_name on:(BOOL)b_on
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-    char *psz_string, *psz_parser;
-
-    const char *psz_filter_type = [self getFilterType:psz_name];
-    if (!psz_filter_type) {
-        msg_Err(p_intf, "Unable to find filter module \"%s\".", psz_name);
-        return;
-    }
-
-    msg_Dbg(p_intf, "will set filter '%s'", psz_name);
-
-
-    psz_string = config_GetPsz(p_intf, psz_filter_type);
-
-    if (b_on) {
-        if (psz_string == NULL) {
-            psz_string = strdup(psz_name);
-        } else if (strstr(psz_string, psz_name) == NULL) {
-            char *psz_tmp = strdup([[NSString stringWithFormat: @"%s:%s", psz_string, psz_name] UTF8String]);
-            free(psz_string);
-            psz_string = psz_tmp;
-        }
-    } else {
-        if (!psz_string)
-            return;
-
-        psz_parser = strstr(psz_string, psz_name);
-        if (psz_parser) {
-            if (*(psz_parser + strlen(psz_name)) == ':') {
-                memmove(psz_parser, psz_parser + strlen(psz_name) + 1,
-                        strlen(psz_parser + strlen(psz_name) + 1) + 1);
-            } else {
-                *psz_parser = '\0';
-            }
-
-            /* Remove trailing : : */
-            if (strlen(psz_string) > 0 && *(psz_string + strlen(psz_string) -1) == ':')
-                *(psz_string + strlen(psz_string) -1) = '\0';
-        } else {
-            free(psz_string);
-            return;
-        }
-    }
-    config_PutPsz(p_intf, psz_filter_type, psz_string);
-
-    /* Try to set on the fly */
-    if (!strcmp(psz_filter_type, "video-splitter")) {
-        playlist_t *p_playlist = pl_Get(p_intf);
-        var_SetString(p_playlist, psz_filter_type, psz_string);
-    } else {
-        vout_thread_t *p_vout = getVout();
-        if (p_vout) {
-            var_SetString(p_vout, psz_filter_type, psz_string);
-            vlc_object_release(p_vout);
-        }
-    }
-
-    free(psz_string);
-}
-
-- (void)restartFilterIfNeeded: (const char *)psz_filter option: (const char *)psz_name
-{
-    vout_thread_t *p_vout = getVout();
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    if (p_vout == NULL)
-        return;
-    else
-        vlc_object_release(p_vout);
-
-    vlc_object_t *p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
-    if (p_filter) {
-
-        /* we cannot rely on the p_filter existence.
-         This filter might be just
-         disabled, but the object still exists. Therefore, the string
-         is checked, additionally.
-         */
-        const char *psz_filter_type = [self getFilterType:psz_filter];
-        if (!psz_filter_type) {
-            msg_Err(p_intf, "Unable to find filter module \"%s\".", psz_name);
-            goto out;
-        }
-
-        char *psz_string = config_GetPsz(p_intf, psz_filter_type);
-        if (!psz_string) {
-            goto out;
-        }
-        if (strstr(psz_string, psz_filter) == NULL) {
-            free(psz_string);
-            goto out;
-        }
-        free(psz_string);
-
-        int i_type;
-        i_type = var_Type(p_filter, psz_name);
-        if (i_type == 0)
-            i_type = config_GetType(p_intf, psz_name);
-
-        if (!(i_type & VLC_VAR_ISCOMMAND)) {
-            msg_Warn(p_intf, "Brute-restarting filter '%s', because the last changed option isn't a command", psz_name);
-
-            [self setVideoFilter: psz_filter on: NO];
-            [self setVideoFilter: psz_filter on: YES];
-        } else
-            msg_Dbg(p_intf, "restart not needed");
-
-        out:
-        vlc_object_release(p_filter);
-    }
-}
-
-- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter integer: (int)i_value
-{
-    vout_thread_t *p_vout = getVout();
-    vlc_object_t *p_filter;
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    config_PutInt(p_intf, psz_name, i_value);
-
-    if (p_vout) {
-        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
-
-        if (!p_filter) {
-            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
-            vlc_object_release(p_vout);
-            return;
-        }
-        var_SetInteger(p_filter, psz_name, i_value);
-        vlc_object_release(p_vout);
-        vlc_object_release(p_filter);
-
-        [self restartFilterIfNeeded: psz_filter option: psz_name];
-    }
-}
-
-- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter float: (float)f_value
-{
-    vout_thread_t *p_vout = getVout();
-    vlc_object_t *p_filter;
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    config_PutFloat(p_intf, psz_name, f_value);
-
-    if (p_vout) {
-        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
-
-        if (!p_filter) {
-            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
-            vlc_object_release(p_vout);
-            return;
-        }
-        var_SetFloat(p_filter, psz_name, f_value);
-        vlc_object_release(p_vout);
-        vlc_object_release(p_filter);
-
-        [self restartFilterIfNeeded: psz_filter option: psz_name];
-    }
-}
-
-- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter string: (const char *)psz_value
-{
-    char *psz_new_value = strdup(psz_value);
-    vout_thread_t *p_vout = getVout();
-    vlc_object_t *p_filter;
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    config_PutPsz(p_intf, psz_name, EnsureUTF8(psz_new_value));
-
-    if (p_vout) {
-        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
-
-        if (!p_filter) {
-            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
-            vlc_object_release(p_vout);
-            return;
-        }
-        var_SetString(p_filter, psz_name, EnsureUTF8(psz_new_value));
-        vlc_object_release(p_vout);
-        vlc_object_release(p_filter);
-
-        [self restartFilterIfNeeded: psz_filter option: psz_name];
-    }
-
-    free(psz_new_value);
-}
-
-- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter boolean: (BOOL)b_value
-{
-    vout_thread_t *p_vout = getVout();
-    vlc_object_t *p_filter;
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    config_PutInt(p_intf, psz_name, b_value);
-
-    if (p_vout) {
-        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
-
-        if (!p_filter) {
-            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
-            vlc_object_release(p_vout);
-            return;
-        }
-        var_SetBool(p_filter, psz_name, b_value);
-        vlc_object_release(p_vout);
-        vlc_object_release(p_filter);
-    }
-}
-
-#pragma mark -
-#pragma mark Media Key support
-
-- (void)resetMediaKeyJump
-{
-    b_mediakeyJustJumped = NO;
-}
-
-- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
-    if (b_mediaKeySupport && !_mediaKeyController)
-        _mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
-
-    VLCMain *main = [VLCMain sharedInstance];
-    if (b_mediaKeySupport && ([[[main playlist] model] hasChildren] ||
-                              [[main inputManager] hasInput])) {
-        if (!b_mediaKeyTrapEnabled) {
-            b_mediaKeyTrapEnabled = YES;
-            msg_Dbg(p_intf, "Enable media key support");
-            [_mediaKeyController startWatchingMediaKeys];
-        }
-    } else {
-        if (b_mediaKeyTrapEnabled) {
-            b_mediaKeyTrapEnabled = NO;
-            msg_Dbg(p_intf, "Disable media key support");
-            [_mediaKeyController stopWatchingMediaKeys];
-        }
-    }
-}
-
--(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event
-{
-    if (b_mediaKeySupport) {
-        assert([event type] == NSSystemDefined && [event subtype] == SPSystemDefinedEventMediaKeys);
-
-        int keyCode = (([event data1] & 0xFFFF0000) >> 16);
-        int keyFlags = ([event data1] & 0x0000FFFF);
-        int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
-        int keyRepeat = (keyFlags & 0x1);
-
-        if (keyCode == NX_KEYTYPE_PLAY && keyState == 0)
-            [self playOrPause];
-
-        if ((keyCode == NX_KEYTYPE_FAST || keyCode == NX_KEYTYPE_NEXT) && !b_mediakeyJustJumped) {
-            if (keyState == 0 && keyRepeat == 0)
-                [self next];
-            else if (keyRepeat == 1) {
-                [self forwardShort];
-                b_mediakeyJustJumped = YES;
-                [self performSelector:@selector(resetMediaKeyJump)
-                           withObject: NULL
-                           afterDelay:0.25];
-            }
-        }
-
-        if ((keyCode == NX_KEYTYPE_REWIND || keyCode == NX_KEYTYPE_PREVIOUS) && !b_mediakeyJustJumped) {
-            if (keyState == 0 && keyRepeat == 0)
-                [self previous];
-            else if (keyRepeat == 1) {
-                [self backwardShort];
-                b_mediakeyJustJumped = YES;
-                [self performSelector:@selector(resetMediaKeyJump)
-                           withObject: NULL
-                           afterDelay:0.25];
-            }
-        }
-    }
-}
-
-#pragma mark -
-#pragma mark Apple Remote Control
-
-- (void)startListeningWithAppleRemote
-{
-    [_remote startListening: self];
-}
-
-- (void)stopListeningWithAppleRemote
-{
-    [_remote stopListening:self];
-}
-
-#pragma mark - menu navigation
-- (void)menuFocusActivate
-{
-    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
-    if (p_input_thread == NULL)
-        return;
-
-    input_Control(p_input_thread, INPUT_NAV_ACTIVATE, NULL );
-    vlc_object_release(p_input_thread);
-}
-
-- (void)moveMenuFocusLeft
-{
-    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
-    if (p_input_thread == NULL)
-        return;
-
-    input_Control(p_input_thread, INPUT_NAV_LEFT, NULL );
-    vlc_object_release(p_input_thread);
-}
-
-- (void)moveMenuFocusRight
-{
-    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
-    if (p_input_thread == NULL)
-        return;
-
-    input_Control(p_input_thread, INPUT_NAV_RIGHT, NULL );
-    vlc_object_release(p_input_thread);
-}
-
-- (void)moveMenuFocusUp
-{
-    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
-    if (p_input_thread == NULL)
-        return;
-
-    input_Control(p_input_thread, INPUT_NAV_UP, NULL );
-    vlc_object_release(p_input_thread);
-}
-
-- (void)moveMenuFocusDown
-{
-    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
-    if (p_input_thread == NULL)
-        return;
-
-    input_Control(p_input_thread, INPUT_NAV_DOWN, NULL );
-    vlc_object_release(p_input_thread);
-}
-
-/* Helper method for the remote control interface in order to trigger forward/backward and volume
- increase/decrease as long as the user holds the left/right, plus/minus button */
-- (void) executeHoldActionForRemoteButton: (NSNumber*) buttonIdentifierNumber
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    if (b_remote_button_hold) {
-        switch([buttonIdentifierNumber intValue]) {
-            case kRemoteButtonRight_Hold:
-                [self forward];
-                break;
-            case kRemoteButtonLeft_Hold:
-                [self backward];
-                break;
-            case kRemoteButtonVolume_Plus_Hold:
-                if (p_intf)
-                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_UP);
-                break;
-            case kRemoteButtonVolume_Minus_Hold:
-                if (p_intf)
-                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_DOWN);
-                break;
-        }
-        if (b_remote_button_hold) {
-            /* trigger event */
-            [self performSelector:@selector(executeHoldActionForRemoteButton:)
-                       withObject:buttonIdentifierNumber
-                       afterDelay:0.25];
-        }
-    }
-}
-
-/* Apple Remote callback */
-- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier
-               pressedDown: (BOOL) pressedDown
-                clickCount: (unsigned int) count
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    switch(buttonIdentifier) {
-        case k2009RemoteButtonFullscreen:
-            [self toggleFullscreen];
-            break;
-        case k2009RemoteButtonPlay:
-            [self playOrPause];
-            break;
-        case kRemoteButtonPlay:
-            if (count >= 2)
-                [self toggleFullscreen];
-            else
-                [self playOrPause];
-            break;
-        case kRemoteButtonVolume_Plus:
-            if (config_GetInt(getIntf(), "macosx-appleremote-sysvol"))
-                [NSSound increaseSystemVolume];
-            else
-                if (p_intf)
-                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_UP);
-            break;
-        case kRemoteButtonVolume_Minus:
-            if (config_GetInt(getIntf(), "macosx-appleremote-sysvol"))
-                [NSSound decreaseSystemVolume];
-            else
-                if (p_intf)
-                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_DOWN);
-            break;
-        case kRemoteButtonRight:
-            if (config_GetInt(getIntf(), "macosx-appleremote-prevnext"))
-                [self forward];
-            else
-                [self next];
-            break;
-        case kRemoteButtonLeft:
-            if (config_GetInt(getIntf(), "macosx-appleremote-prevnext"))
-                [self backward];
-            else
-                [self previous];
-            break;
-        case kRemoteButtonRight_Hold:
-        case kRemoteButtonLeft_Hold:
-        case kRemoteButtonVolume_Plus_Hold:
-        case kRemoteButtonVolume_Minus_Hold:
-            /* simulate an event as long as the user holds the button */
-            b_remote_button_hold = pressedDown;
-            if (pressedDown) {
-                NSNumber* buttonIdentifierNumber = [NSNumber numberWithInt:buttonIdentifier];
-                [self performSelector:@selector(executeHoldActionForRemoteButton:)
-                           withObject:buttonIdentifierNumber];
-            }
-            break;
-        case kRemoteButtonMenu:
-            [self showPosition];
-            break;
-        case kRemoteButtonPlay_Sleep:
-        {
-            NSAppleScript * script = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to sleep"];
-            [script executeAndReturnError:nil];
-            break;
-        }
-        default:
-            /* Add here whatever you want other buttons to do */
-            break;
-    }
-}
-
-#pragma mark -
-#pragma mark Key Shortcuts
-
-/*****************************************************************************
- * hasDefinedShortcutKey: Check to see if the key press is a defined VLC
- * shortcut key.  If it is, pass it off to VLC for handling and return YES,
- * otherwise ignore it and return NO (where it will get handled by Cocoa).
- *****************************************************************************/
-
-- (BOOL)keyEvent:(NSEvent *)o_event
-{
-    BOOL eventHandled = NO;
-    NSString * characters = [o_event charactersIgnoringModifiers];
-    if ([characters length] > 0) {
-        unichar key = [characters characterAtIndex: 0];
-
-        if (key) {
-            input_thread_t * p_input = pl_CurrentInput(getIntf());
-            if (p_input != NULL) {
-                vout_thread_t *p_vout = input_GetVout(p_input);
-
-                if (p_vout != NULL) {
-                    /* Escape */
-                    if (key == (unichar) 0x1b) {
-                        if (var_GetBool(p_vout, "fullscreen")) {
-                            [self toggleFullscreen];
-                            eventHandled = YES;
-                        }
-                    }
-                    vlc_object_release(p_vout);
-                }
-                vlc_object_release(p_input);
-            }
-        }
-    }
-    return eventHandled;
-}
-
-- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force
-{
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return NO;
-
-    unichar key = 0;
-    vlc_value_t val;
-    unsigned int i_pressed_modifiers = 0;
-
-    val.i_int = 0;
-    i_pressed_modifiers = [o_event modifierFlags];
-
-    if (i_pressed_modifiers & NSControlKeyMask)
-        val.i_int |= KEY_MODIFIER_CTRL;
-
-    if (i_pressed_modifiers & NSAlternateKeyMask)
-        val.i_int |= KEY_MODIFIER_ALT;
-
-    if (i_pressed_modifiers & NSShiftKeyMask)
-        val.i_int |= KEY_MODIFIER_SHIFT;
-
-    if (i_pressed_modifiers & NSCommandKeyMask)
-        val.i_int |= KEY_MODIFIER_COMMAND;
-
-    NSString * characters = [o_event charactersIgnoringModifiers];
-    if ([characters length] > 0) {
-        key = [[characters lowercaseString] characterAtIndex: 0];
-
-        /* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */
-        if (key == 'f' && i_pressed_modifiers & NSControlKeyMask && i_pressed_modifiers & NSCommandKeyMask) {
-            [self toggleFullscreen];
-            return YES;
-        }
-
-        if (!b_force) {
-            switch(key) {
-                case NSDeleteCharacter:
-                case NSDeleteFunctionKey:
-                case NSDeleteCharFunctionKey:
-                case NSBackspaceCharacter:
-                case NSUpArrowFunctionKey:
-                case NSDownArrowFunctionKey:
-                case NSEnterCharacter:
-                case NSCarriageReturnCharacter:
-                    return NO;
-            }
-        }
-
-        val.i_int |= CocoaKeyToVLC(key);
-
-        BOOL b_found_key = NO;
-        for (NSUInteger i = 0; i < [_usedHotkeys count]; i++) {
-            NSString *str = [_usedHotkeys objectAtIndex:i];
-            unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa: str];
-
-            if ([[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: str]] &&
-                (i_keyModifiers & NSShiftKeyMask)     == (i_pressed_modifiers & NSShiftKeyMask) &&
-                (i_keyModifiers & NSControlKeyMask)   == (i_pressed_modifiers & NSControlKeyMask) &&
-                (i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) &&
-                (i_keyModifiers & NSCommandKeyMask)   == (i_pressed_modifiers & NSCommandKeyMask)) {
-                b_found_key = YES;
-                break;
-            }
-        }
-
-        if (b_found_key) {
-            var_SetInteger(p_intf->obj.libvlc, "key-pressed", val.i_int);
-            return YES;
-        }
-    }
-
-    return NO;
-}
-
-- (void)updateCurrentlyUsedHotkeys
-{
-    NSMutableArray *mutArray = [[NSMutableArray alloc] init];
-    /* Get the main Module */
-    module_t *p_main = module_get_main();
-    assert(p_main);
-    unsigned confsize;
-    module_config_t *p_config;
-
-    p_config = module_config_get (p_main, &confsize);
-
-    for (size_t i = 0; i < confsize; i++) {
-        module_config_t *p_item = p_config + i;
-
-        if (CONFIG_ITEM(p_item->i_type) && p_item->psz_name != NULL
-            && !strncmp(p_item->psz_name , "key-", 4)
-            && !EMPTY_STR(p_item->psz_text)) {
-            if (p_item->value.psz)
-                [mutArray addObject:toNSStr(p_item->value.psz)];
-        }
-    }
-    module_config_free (p_config);
-
-    _usedHotkeys = [[NSArray alloc] initWithArray:mutArray copyItems:YES];
-}
-
-@end
index 7c7997a..74ab4f3 100644 (file)
@@ -24,7 +24,7 @@
 #import <vlc_common.h>
 #import "intf.h"
 #import "MainWindowTitle.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "CompatibilityFixes.h"
 #import <SystemConfiguration/SystemConfiguration.h> // for the revealInFinder clone
 
index d69962b..afe9112 100644 (file)
@@ -30,7 +30,7 @@ libmacosx_plugin_la_SOURCES = \
        CompatibilityFixes.h \
        ControlsBar.m ControlsBar.h \
        VLCConvertAndSaveWindowController.h VLCConvertAndSaveWindowController.m \
-       CoreInteraction.h CoreInteraction.m \
+       VLCCoreInteraction.h VLCCoreInteraction.m \
        ExtensionsDialogProvider.h ExtensionsDialogProvider.m \
        ExtensionsManager.h ExtensionsManager.m \
        fspanel.h fspanel.m \
diff --git a/modules/gui/macosx/VLCCoreInteraction.h b/modules/gui/macosx/VLCCoreInteraction.h
new file mode 100644 (file)
index 0000000..f00cef2
--- /dev/null
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * CoreInteraction.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2011-2015 Felix Paul Kühne
+ * $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 <Cocoa/Cocoa.h>
+
+@interface VLCCoreInteraction : NSObject
+
++ (VLCCoreInteraction *)sharedInstance;
+@property (readwrite) int volume;
+@property (readonly, nonatomic) float maxVolume;
+@property (readwrite) int playbackRate;
+@property (nonatomic, readwrite) BOOL aspectRatioIsLocked;
+@property (readonly) int durationOfCurrentPlaylistItem;
+@property (readonly) NSURL * URLOfCurrentPlaylistItem;
+@property (readonly) NSString * nameOfCurrentPlaylistItem;
+@property (nonatomic, readwrite) BOOL mute;
+
+- (void)playOrPause;
+- (void)pause;
+- (void)stop;
+- (void)faster;
+- (void)slower;
+- (void)normalSpeed;
+- (void)toggleRecord;
+- (void)next;
+- (void)previous;
+- (void)forward;        //LEGACY SUPPORT
+- (void)backward;       //LEGACY SUPPORT
+- (void)forwardExtraShort;
+- (void)backwardExtraShort;
+- (void)forwardShort;
+- (void)backwardShort;
+- (void)forwardMedium;
+- (void)backwardMedium;
+- (void)forwardLong;
+- (void)backwardLong;
+
+- (void)repeatOne;
+- (void)repeatAll;
+- (void)repeatOff;
+- (void)shuffle;
+- (void)setAtoB;
+- (void)resetAtoB;
+- (void)updateAtoB;
+
+- (void)volumeUp;
+- (void)volumeDown;
+- (void)toggleMute;
+- (void)showPosition;
+- (void)startListeningWithAppleRemote;
+- (void)stopListeningWithAppleRemote;
+
+- (void)menuFocusActivate;
+- (void)moveMenuFocusLeft;
+- (void)moveMenuFocusRight;
+- (void)moveMenuFocusUp;
+- (void)moveMenuFocusDown;
+
+- (void)addSubtitlesToCurrentInput:(NSArray *)paths;
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
+
+- (void)toggleFullscreen;
+
+- (BOOL)fixPreferences;
+
+- (void)setVideoFilter: (const char *)psz_name on:(BOOL)b_on;
+- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter integer: (int)i_value;
+- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter float: (float)f_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;
+
+- (BOOL)keyEvent:(NSEvent *)o_event;
+- (void)updateCurrentlyUsedHotkeys;
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
+
+@end
diff --git a/modules/gui/macosx/VLCCoreInteraction.m b/modules/gui/macosx/VLCCoreInteraction.m
new file mode 100644 (file)
index 0000000..9e13808
--- /dev/null
@@ -0,0 +1,1359 @@
+/*****************************************************************************
+ * CoreInteraction.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2011-2015 Felix Paul Kühne
+ * $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 "VLCCoreInteraction.h"
+#import "intf.h"
+#import "open.h"
+#import "VLCPlaylist.h"
+#import <math.h>
+#import <vlc_playlist.h>
+#import <vlc_input.h>
+#import <vlc_keys.h>
+#import <vlc_vout.h>
+#import <vlc_vout_osd.h>
+#import <vlc/vlc.h>
+#import <vlc_strings.h>
+#import <vlc_url.h>
+#import <vlc_modules.h>
+#import <vlc_charset.h>
+#include <vlc_plugin.h>
+#import "SPMediaKeyTap.h"
+#import "AppleRemote.h"
+#import "VLCInputManager.h"
+
+static int BossCallback(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(), ^{
+            [[VLCCoreInteraction sharedInstance] pause];
+            [[NSApplication sharedApplication] hide:nil];
+        });
+
+        return VLC_SUCCESS;
+    }
+}
+
+@interface VLCCoreInteraction ()
+{
+    int i_currentPlaybackRate;
+    mtime_t timeA, timeB;
+
+    float f_maxVolume;
+
+    /* media key support */
+    BOOL b_mediaKeySupport;
+    BOOL b_mediakeyJustJumped;
+    SPMediaKeyTap *_mediaKeyController;
+    BOOL b_mediaKeyTrapEnabled;
+
+    AppleRemote *_remote;
+    BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
+
+    NSArray *_usedHotkeys;
+}
+@end
+
+@implementation VLCCoreInteraction
+
+#pragma mark - Initialization
+
++ (VLCCoreInteraction *)sharedInstance
+{
+    static VLCCoreInteraction *sharedInstance = nil;
+    static dispatch_once_t pred;
+
+    dispatch_once(&pred, ^{
+        sharedInstance = [VLCCoreInteraction new];
+    });
+
+    return sharedInstance;
+}
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        intf_thread_t *p_intf = getIntf();
+
+        /* init media key support */
+        b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
+        if (b_mediaKeySupport) {
+            _mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
+            [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
+                                                                     [SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers], kMediaKeyUsingBundleIdentifiersDefaultsKey,
+                                                                     nil]];
+        }
+        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
+
+        /* init Apple Remote support */
+        _remote = [[AppleRemote alloc] init];
+        [_remote setClickCountEnabledButtons: kRemoteButtonPlay];
+        [_remote setDelegate: self];
+
+        var_AddCallback(p_intf->obj.libvlc, "intf-boss", BossCallback, (__bridge void *)self);
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    intf_thread_t *p_intf = getIntf();
+    var_DelCallback(p_intf->obj.libvlc, "intf-boss", BossCallback, (__bridge void *)self);
+    [[NSNotificationCenter defaultCenter] removeObserver: self];
+}
+
+
+#pragma mark - Playback Controls
+
+- (void)playOrPause
+{
+    input_thread_t *p_input = pl_CurrentInput(getIntf());
+    playlist_t *p_playlist = pl_Get(getIntf());
+
+    if (p_input) {
+        playlist_TogglePause(p_playlist);
+        vlc_object_release(p_input);
+
+    } else {
+        PLRootType root = [[[[VLCMain sharedInstance] playlist] model] currentRootType];
+        if ([[[VLCMain sharedInstance] playlist] isSelectionEmpty] && (root == ROOT_TYPE_PLAYLIST || root == ROOT_TYPE_MEDIALIBRARY))
+            [[[VLCMain sharedInstance] open] openFileGeneric];
+        else
+            [[[VLCMain sharedInstance] playlist] playItem:nil];
+    }
+}
+
+- (void)pause
+{
+    playlist_t *p_playlist = pl_Get(getIntf());
+
+    playlist_Pause(p_playlist);
+}
+
+- (void)stop
+{
+    playlist_Stop(pl_Get(getIntf()));
+}
+
+- (void)faster
+{
+    var_TriggerCallback(pl_Get(getIntf()), "rate-faster");
+}
+
+- (void)slower
+{
+    var_TriggerCallback(pl_Get(getIntf()), "rate-slower");
+}
+
+- (void)normalSpeed
+{
+    var_SetFloat(pl_Get(getIntf()), "rate", 1.);
+}
+
+- (void)toggleRecord
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    input_thread_t * p_input;
+    p_input = pl_CurrentInput(p_intf);
+    if (p_input) {
+        var_ToggleBool(p_input, "record");
+        vlc_object_release(p_input);
+    }
+}
+
+- (void)setPlaybackRate:(int)i_value
+{
+    playlist_t * p_playlist = pl_Get(getIntf());
+
+    double speed = pow(2, (double)i_value / 17);
+    int rate = INPUT_RATE_DEFAULT / speed;
+    if (i_currentPlaybackRate != rate)
+        var_SetFloat(p_playlist, "rate", (float)INPUT_RATE_DEFAULT / (float)rate);
+    i_currentPlaybackRate = rate;
+}
+
+- (int)playbackRate
+{
+    float f_rate;
+
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return 0;
+
+    input_thread_t * p_input;
+    p_input = pl_CurrentInput(p_intf);
+    if (p_input) {
+        f_rate = var_GetFloat(p_input, "rate");
+        vlc_object_release(p_input);
+    }
+    else
+    {
+        playlist_t * p_playlist = pl_Get(getIntf());
+        f_rate = var_GetFloat(p_playlist, "rate");
+    }
+
+    double value = 17 * log(f_rate) / log(2.);
+    int returnValue = (int) ((value > 0) ? value + .5 : value - .5);
+
+    if (returnValue < -34)
+        returnValue = -34;
+    else if (returnValue > 34)
+        returnValue = 34;
+
+    i_currentPlaybackRate = returnValue;
+    return returnValue;
+}
+
+- (void)previous
+{
+    playlist_Prev(pl_Get(getIntf()));
+}
+
+- (void)next
+{
+    playlist_Next(pl_Get(getIntf()));
+}
+
+- (int)durationOfCurrentPlaylistItem
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return 0;
+
+    input_thread_t * p_input = pl_CurrentInput(p_intf);
+    int64_t i_duration = -1;
+    if (!p_input)
+        return i_duration;
+
+    input_Control(p_input, INPUT_GET_LENGTH, &i_duration);
+    vlc_object_release(p_input);
+
+    return (int)(i_duration / 1000000);
+}
+
+- (NSURL*)URLOfCurrentPlaylistItem
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return nil;
+
+    input_thread_t *p_input = pl_CurrentInput(p_intf);
+    if (!p_input)
+        return nil;
+
+    input_item_t *p_item = input_GetItem(p_input);
+    if (!p_item) {
+        vlc_object_release(p_input);
+        return nil;
+    }
+
+    char *psz_uri = input_item_GetURI(p_item);
+    if (!psz_uri) {
+        vlc_object_release(p_input);
+        return nil;
+    }
+
+    NSURL *o_url;
+    o_url = [NSURL URLWithString:toNSStr(psz_uri)];
+    vlc_object_release(p_input);
+
+    return o_url;
+}
+
+- (NSString*)nameOfCurrentPlaylistItem
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return nil;
+
+    input_thread_t *p_input = pl_CurrentInput(p_intf);
+    if (!p_input)
+        return nil;
+
+    input_item_t *p_item = input_GetItem(p_input);
+    if (!p_item) {
+        vlc_object_release(p_input);
+        return nil;
+    }
+
+    char *psz_uri = input_item_GetURI(p_item);
+    if (!psz_uri) {
+        vlc_object_release(p_input);
+        return nil;
+    }
+
+    NSString *o_name = @"";
+    char *format = var_InheritString(getIntf(), "input-title-format");
+    if (format) {
+        char *formated = vlc_strfinput(p_input, format);
+        free(format);
+        o_name = toNSStr(formated);
+        free(formated);
+    }
+
+    NSURL * o_url = [NSURL URLWithString:toNSStr(psz_uri)];
+    free(psz_uri);
+
+    if ([o_name isEqualToString:@""]) {
+        if ([o_url isFileURL])
+            o_name = [[NSFileManager defaultManager] displayNameAtPath:[o_url path]];
+        else
+            o_name = [o_url absoluteString];
+    }
+    vlc_object_release(p_input);
+    return o_name;
+}
+
+- (void)forward
+{
+    //LEGACY SUPPORT
+    [self forwardShort];
+}
+
+- (void)backward
+{
+    //LEGACY SUPPORT
+    [self backwardShort];
+}
+
+- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value
+{
+    input_thread_t *p_input = pl_CurrentInput(getIntf());
+    if (!p_input)
+        return;
+
+    int i_interval = var_InheritInteger( p_input, p_value );
+    if (i_interval > 0) {
+        mtime_t val = CLOCK_FREQ * i_interval;
+        if (!b_value)
+            val = val * -1;
+        var_SetInteger( p_input, "time-offset", val );
+    }
+    vlc_object_release(p_input);
+}
+
+- (void)forwardExtraShort
+{
+    [self jumpWithValue:"extrashort-jump-size" forward:YES];
+}
+
+- (void)backwardExtraShort
+{
+    [self jumpWithValue:"extrashort-jump-size" forward:NO];
+}
+
+- (void)forwardShort
+{
+    [self jumpWithValue:"short-jump-size" forward:YES];
+}
+
+- (void)backwardShort
+{
+    [self jumpWithValue:"short-jump-size" forward:NO];
+}
+
+- (void)forwardMedium
+{
+    [self jumpWithValue:"medium-jump-size" forward:YES];
+}
+
+- (void)backwardMedium
+{
+    [self jumpWithValue:"medium-jump-size" forward:NO];
+}
+
+- (void)forwardLong
+{
+    [self jumpWithValue:"long-jump-size" forward:YES];
+}
+
+- (void)backwardLong
+{
+    [self jumpWithValue:"long-jump-size" forward:NO];
+}
+
+- (void)shuffle
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    vlc_value_t val;
+    playlist_t * p_playlist = pl_Get(p_intf);
+    vout_thread_t *p_vout = getVout();
+
+    var_Get(p_playlist, "random", &val);
+    val.b_bool = !val.b_bool;
+    var_Set(p_playlist, "random", val);
+    if (val.b_bool) {
+        if (p_vout) {
+            vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Random On"));
+            vlc_object_release(p_vout);
+        }
+        config_PutInt(p_playlist, "random", 1);
+    }
+    else
+    {
+        if (p_vout) {
+            vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Random Off"));
+            vlc_object_release(p_vout);
+        }
+        config_PutInt(p_playlist, "random", 0);
+    }
+}
+
+- (void)repeatAll
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    playlist_t * p_playlist = pl_Get(p_intf);
+
+    var_SetBool(p_playlist, "repeat", NO);
+    var_SetBool(p_playlist, "loop", YES);
+    config_PutInt(p_playlist, "repeat", NO);
+    config_PutInt(p_playlist, "loop", YES);
+
+    vout_thread_t *p_vout = getVout();
+    if (p_vout) {
+        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Repeat All"));
+        vlc_object_release(p_vout);
+    }
+}
+
+- (void)repeatOne
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    playlist_t * p_playlist = pl_Get(p_intf);
+
+    var_SetBool(p_playlist, "repeat", YES);
+    var_SetBool(p_playlist, "loop", NO);
+    config_PutInt(p_playlist, "repeat", YES);
+    config_PutInt(p_playlist, "loop", NO);
+
+    vout_thread_t *p_vout = getVout();
+    if (p_vout) {
+        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Repeat One"));
+        vlc_object_release(p_vout);
+    }
+}
+
+- (void)repeatOff
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    playlist_t * p_playlist = pl_Get(p_intf);
+
+    var_SetBool(p_playlist, "repeat", NO);
+    var_SetBool(p_playlist, "loop", NO);
+    config_PutInt(p_playlist, "repeat", NO);
+    config_PutInt(p_playlist, "loop", NO);
+
+    vout_thread_t *p_vout = getVout();
+    if (p_vout) {
+        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, "%s", _("Repeat Off"));
+        vlc_object_release(p_vout);
+    }
+}
+
+- (void)setAtoB
+{
+    if (!timeA) {
+        input_thread_t * p_input = pl_CurrentInput(getIntf());
+        if (p_input) {
+            timeA = var_GetInteger(p_input, "time");
+            vlc_object_release(p_input);
+        }
+    } else if (!timeB) {
+        input_thread_t * p_input = pl_CurrentInput(getIntf());
+        if (p_input) {
+            timeB = var_GetInteger(p_input, "time");
+            vlc_object_release(p_input);
+        }
+    } else
+        [self resetAtoB];
+}
+
+- (void)resetAtoB
+{
+    timeA = 0;
+    timeB = 0;
+}
+
+- (void)updateAtoB
+{
+    if (timeB) {
+        input_thread_t * p_input = pl_CurrentInput(getIntf());
+        if (p_input) {
+            mtime_t currentTime = var_GetInteger(p_input, "time");
+            if ( currentTime >= timeB || currentTime < timeA)
+                var_SetInteger(p_input, "time", timeA);
+            vlc_object_release(p_input);
+        }
+    }
+}
+
+- (void)volumeUp
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    playlist_VolumeUp(pl_Get(p_intf), 1, NULL);
+}
+
+- (void)volumeDown
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    playlist_VolumeDown(pl_Get(p_intf), 1, NULL);
+}
+
+- (void)toggleMute
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    playlist_MuteToggle(pl_Get(p_intf));
+}
+
+- (BOOL)mute
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return NO;
+
+    BOOL b_is_muted = NO;
+    b_is_muted = playlist_MuteGet(pl_Get(p_intf)) > 0;
+
+    return b_is_muted;
+}
+
+- (int)volume
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return 0;
+
+    float volume = playlist_VolumeGet(pl_Get(p_intf));
+
+    return lroundf(volume * AOUT_VOLUME_DEFAULT);
+}
+
+- (void)setVolume: (int)i_value
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    if (i_value >= self.maxVolume)
+        i_value = self.maxVolume;
+
+    float f_value = i_value / (float)AOUT_VOLUME_DEFAULT;
+
+    playlist_VolumeSet(pl_Get(p_intf), f_value);
+}
+
+- (float)maxVolume
+{
+    if (f_maxVolume == 0.) {
+        f_maxVolume = (float)var_InheritInteger(getIntf(), "macosx-max-volume") / 100. * AOUT_VOLUME_DEFAULT;
+    }
+
+    return f_maxVolume;
+}
+
+- (void)addSubtitlesToCurrentInput:(NSArray *)paths
+{
+    input_thread_t * p_input = pl_CurrentInput(getIntf());
+    if (!p_input)
+        return;
+
+    NSUInteger count = [paths count];
+
+    for (int i = 0; i < count ; i++) {
+        const char *path = [[[paths objectAtIndex:i] path] UTF8String];
+        msg_Dbg(getIntf(), "loading subs from %s", path);
+
+        int i_result = input_AddSubtitleOSD(p_input, path, true, true);
+        if (i_result != VLC_SUCCESS)
+            msg_Warn(getIntf(), "unable to load subtitles from '%s'", path);
+    }
+    vlc_object_release(p_input);
+}
+
+- (void)showPosition
+{
+    input_thread_t *p_input = pl_CurrentInput(getIntf());
+    if (p_input != NULL) {
+        vout_thread_t *p_vout = input_GetVout(p_input);
+        if (p_vout != NULL) {
+            var_SetInteger(getIntf()->obj.libvlc, "key-action", ACTIONID_POSITION);
+            vlc_object_release(p_vout);
+        }
+        vlc_object_release(p_input);
+    }
+}
+
+#pragma mark - Drop support for files into the video, controls bar or drop box
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
+{
+    NSArray *items = [[[VLCMain sharedInstance] playlist] createItemsFromExternalPasteboard:[sender draggingPasteboard]];
+
+    if (items.count == 0)
+        return NO;
+
+    // Try to add file as a subtitle
+    input_thread_t *p_input = pl_CurrentInput(getIntf());
+    if (items.count == 1 && p_input) {
+        NSString *url = [[items firstObject] valueForKey:@"ITEM_URL"];
+        char *path = vlc_uri2path([url UTF8String]);
+
+        if (path) {
+            int i_result = input_AddSubtitleOSD(p_input, path, true, true);
+            free(path);
+            if (i_result == VLC_SUCCESS) {
+                vlc_object_release(p_input);
+                return YES;
+            }
+        }
+    }
+
+    if (p_input)
+        vlc_object_release(p_input);
+
+    [[[VLCMain sharedInstance] playlist] addPlaylistItems:items];
+    return YES;
+}
+
+#pragma mark - video output stuff
+
+- (void)setAspectRatioIsLocked:(BOOL)b_value
+{
+    config_PutInt(getIntf(), "macosx-lock-aspect-ratio", b_value);
+}
+
+- (BOOL)aspectRatioIsLocked
+{
+    return config_GetInt(getIntf(), "macosx-lock-aspect-ratio");
+}
+
+- (void)toggleFullscreen
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    vout_thread_t *p_vout = getVoutForActiveWindow();
+    if (p_vout) {
+        BOOL b_fs = var_ToggleBool(p_vout, "fullscreen");
+        var_SetBool(pl_Get(p_intf), "fullscreen", b_fs);
+        vlc_object_release(p_vout);
+    } else { // e.g. lion fullscreen toggle
+        BOOL b_fs = var_ToggleBool(pl_Get(p_intf), "fullscreen");
+        [[[VLCMain sharedInstance] voutController] setFullscreen:b_fs forWindow:nil withAnimation:YES];
+    }
+}
+
+#pragma mark - uncommon stuff
+
+- (BOOL)fixPreferences
+{
+    NSMutableString * o_workString;
+    NSRange returnedRange;
+    NSRange fullRange;
+    BOOL b_needsRestart = NO;
+
+    #define fixpref(pref) \
+    o_workString = [[NSMutableString alloc] initWithFormat:@"%s", config_GetPsz(getIntf(), pref)]; \
+    if ([o_workString length] > 0) \
+    { \
+        returnedRange = [o_workString rangeOfString:@"macosx" options: NSCaseInsensitiveSearch]; \
+        if (returnedRange.location != NSNotFound) \
+        { \
+            if ([o_workString isEqualToString:@"macosx"]) \
+                [o_workString setString:@""]; \
+            fullRange = NSMakeRange(0, [o_workString length]); \
+            [o_workString replaceOccurrencesOfString:@":macosx" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
+            fullRange = NSMakeRange(0, [o_workString length]); \
+            [o_workString replaceOccurrencesOfString:@"macosx:" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
+            \
+            config_PutPsz(getIntf(), pref, [o_workString UTF8String]); \
+            b_needsRestart = YES; \
+        } \
+    }
+
+    fixpref("control");
+    fixpref("extraintf");
+    #undef fixpref
+
+    return b_needsRestart;
+}
+
+#pragma mark - video filter handling
+
+- (const char *)getFilterType:(const char *)psz_name
+{
+    module_t *p_obj = module_find(psz_name);
+    if (!p_obj) {
+        return NULL;
+    }
+
+    if (module_provides(p_obj, "video splitter")) {
+        return "video-splitter";
+    } else if (module_provides(p_obj, "video filter2")) {
+        return "video-filter";
+    } else if (module_provides(p_obj, "sub source")) {
+        return "sub-source";
+    } else if (module_provides(p_obj, "sub filter")) {
+        return "sub-filter";
+    } else {
+        msg_Err(getIntf(), "Unknown video filter type.");
+        return NULL;
+    }
+}
+
+- (void)setVideoFilter: (const char *)psz_name on:(BOOL)b_on
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+    char *psz_string, *psz_parser;
+
+    const char *psz_filter_type = [self getFilterType:psz_name];
+    if (!psz_filter_type) {
+        msg_Err(p_intf, "Unable to find filter module \"%s\".", psz_name);
+        return;
+    }
+
+    msg_Dbg(p_intf, "will set filter '%s'", psz_name);
+
+
+    psz_string = config_GetPsz(p_intf, psz_filter_type);
+
+    if (b_on) {
+        if (psz_string == NULL) {
+            psz_string = strdup(psz_name);
+        } else if (strstr(psz_string, psz_name) == NULL) {
+            char *psz_tmp = strdup([[NSString stringWithFormat: @"%s:%s", psz_string, psz_name] UTF8String]);
+            free(psz_string);
+            psz_string = psz_tmp;
+        }
+    } else {
+        if (!psz_string)
+            return;
+
+        psz_parser = strstr(psz_string, psz_name);
+        if (psz_parser) {
+            if (*(psz_parser + strlen(psz_name)) == ':') {
+                memmove(psz_parser, psz_parser + strlen(psz_name) + 1,
+                        strlen(psz_parser + strlen(psz_name) + 1) + 1);
+            } else {
+                *psz_parser = '\0';
+            }
+
+            /* Remove trailing : : */
+            if (strlen(psz_string) > 0 && *(psz_string + strlen(psz_string) -1) == ':')
+                *(psz_string + strlen(psz_string) -1) = '\0';
+        } else {
+            free(psz_string);
+            return;
+        }
+    }
+    config_PutPsz(p_intf, psz_filter_type, psz_string);
+
+    /* Try to set on the fly */
+    if (!strcmp(psz_filter_type, "video-splitter")) {
+        playlist_t *p_playlist = pl_Get(p_intf);
+        var_SetString(p_playlist, psz_filter_type, psz_string);
+    } else {
+        vout_thread_t *p_vout = getVout();
+        if (p_vout) {
+            var_SetString(p_vout, psz_filter_type, psz_string);
+            vlc_object_release(p_vout);
+        }
+    }
+
+    free(psz_string);
+}
+
+- (void)restartFilterIfNeeded: (const char *)psz_filter option: (const char *)psz_name
+{
+    vout_thread_t *p_vout = getVout();
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    if (p_vout == NULL)
+        return;
+    else
+        vlc_object_release(p_vout);
+
+    vlc_object_t *p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
+    if (p_filter) {
+
+        /* we cannot rely on the p_filter existence.
+         This filter might be just
+         disabled, but the object still exists. Therefore, the string
+         is checked, additionally.
+         */
+        const char *psz_filter_type = [self getFilterType:psz_filter];
+        if (!psz_filter_type) {
+            msg_Err(p_intf, "Unable to find filter module \"%s\".", psz_name);
+            goto out;
+        }
+
+        char *psz_string = config_GetPsz(p_intf, psz_filter_type);
+        if (!psz_string) {
+            goto out;
+        }
+        if (strstr(psz_string, psz_filter) == NULL) {
+            free(psz_string);
+            goto out;
+        }
+        free(psz_string);
+
+        int i_type;
+        i_type = var_Type(p_filter, psz_name);
+        if (i_type == 0)
+            i_type = config_GetType(p_intf, psz_name);
+
+        if (!(i_type & VLC_VAR_ISCOMMAND)) {
+            msg_Warn(p_intf, "Brute-restarting filter '%s', because the last changed option isn't a command", psz_name);
+
+            [self setVideoFilter: psz_filter on: NO];
+            [self setVideoFilter: psz_filter on: YES];
+        } else
+            msg_Dbg(p_intf, "restart not needed");
+
+        out:
+        vlc_object_release(p_filter);
+    }
+}
+
+- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter integer: (int)i_value
+{
+    vout_thread_t *p_vout = getVout();
+    vlc_object_t *p_filter;
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    config_PutInt(p_intf, psz_name, i_value);
+
+    if (p_vout) {
+        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
+
+        if (!p_filter) {
+            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
+            vlc_object_release(p_vout);
+            return;
+        }
+        var_SetInteger(p_filter, psz_name, i_value);
+        vlc_object_release(p_vout);
+        vlc_object_release(p_filter);
+
+        [self restartFilterIfNeeded: psz_filter option: psz_name];
+    }
+}
+
+- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter float: (float)f_value
+{
+    vout_thread_t *p_vout = getVout();
+    vlc_object_t *p_filter;
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    config_PutFloat(p_intf, psz_name, f_value);
+
+    if (p_vout) {
+        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
+
+        if (!p_filter) {
+            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
+            vlc_object_release(p_vout);
+            return;
+        }
+        var_SetFloat(p_filter, psz_name, f_value);
+        vlc_object_release(p_vout);
+        vlc_object_release(p_filter);
+
+        [self restartFilterIfNeeded: psz_filter option: psz_name];
+    }
+}
+
+- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter string: (const char *)psz_value
+{
+    char *psz_new_value = strdup(psz_value);
+    vout_thread_t *p_vout = getVout();
+    vlc_object_t *p_filter;
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    config_PutPsz(p_intf, psz_name, EnsureUTF8(psz_new_value));
+
+    if (p_vout) {
+        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
+
+        if (!p_filter) {
+            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
+            vlc_object_release(p_vout);
+            return;
+        }
+        var_SetString(p_filter, psz_name, EnsureUTF8(psz_new_value));
+        vlc_object_release(p_vout);
+        vlc_object_release(p_filter);
+
+        [self restartFilterIfNeeded: psz_filter option: psz_name];
+    }
+
+    free(psz_new_value);
+}
+
+- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter boolean: (BOOL)b_value
+{
+    vout_thread_t *p_vout = getVout();
+    vlc_object_t *p_filter;
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    config_PutInt(p_intf, psz_name, b_value);
+
+    if (p_vout) {
+        p_filter = vlc_object_find_name(pl_Get(p_intf), psz_filter);
+
+        if (!p_filter) {
+            msg_Warn(p_intf, "filter '%s' isn't enabled", psz_filter);
+            vlc_object_release(p_vout);
+            return;
+        }
+        var_SetBool(p_filter, psz_name, b_value);
+        vlc_object_release(p_vout);
+        vlc_object_release(p_filter);
+    }
+}
+
+#pragma mark -
+#pragma mark Media Key support
+
+- (void)resetMediaKeyJump
+{
+    b_mediakeyJustJumped = NO;
+}
+
+- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    b_mediaKeySupport = var_InheritBool(p_intf, "macosx-mediakeys");
+    if (b_mediaKeySupport && !_mediaKeyController)
+        _mediaKeyController = [[SPMediaKeyTap alloc] initWithDelegate:self];
+
+    VLCMain *main = [VLCMain sharedInstance];
+    if (b_mediaKeySupport && ([[[main playlist] model] hasChildren] ||
+                              [[main inputManager] hasInput])) {
+        if (!b_mediaKeyTrapEnabled) {
+            b_mediaKeyTrapEnabled = YES;
+            msg_Dbg(p_intf, "Enable media key support");
+            [_mediaKeyController startWatchingMediaKeys];
+        }
+    } else {
+        if (b_mediaKeyTrapEnabled) {
+            b_mediaKeyTrapEnabled = NO;
+            msg_Dbg(p_intf, "Disable media key support");
+            [_mediaKeyController stopWatchingMediaKeys];
+        }
+    }
+}
+
+-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event
+{
+    if (b_mediaKeySupport) {
+        assert([event type] == NSSystemDefined && [event subtype] == SPSystemDefinedEventMediaKeys);
+
+        int keyCode = (([event data1] & 0xFFFF0000) >> 16);
+        int keyFlags = ([event data1] & 0x0000FFFF);
+        int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
+        int keyRepeat = (keyFlags & 0x1);
+
+        if (keyCode == NX_KEYTYPE_PLAY && keyState == 0)
+            [self playOrPause];
+
+        if ((keyCode == NX_KEYTYPE_FAST || keyCode == NX_KEYTYPE_NEXT) && !b_mediakeyJustJumped) {
+            if (keyState == 0 && keyRepeat == 0)
+                [self next];
+            else if (keyRepeat == 1) {
+                [self forwardShort];
+                b_mediakeyJustJumped = YES;
+                [self performSelector:@selector(resetMediaKeyJump)
+                           withObject: NULL
+                           afterDelay:0.25];
+            }
+        }
+
+        if ((keyCode == NX_KEYTYPE_REWIND || keyCode == NX_KEYTYPE_PREVIOUS) && !b_mediakeyJustJumped) {
+            if (keyState == 0 && keyRepeat == 0)
+                [self previous];
+            else if (keyRepeat == 1) {
+                [self backwardShort];
+                b_mediakeyJustJumped = YES;
+                [self performSelector:@selector(resetMediaKeyJump)
+                           withObject: NULL
+                           afterDelay:0.25];
+            }
+        }
+    }
+}
+
+#pragma mark -
+#pragma mark Apple Remote Control
+
+- (void)startListeningWithAppleRemote
+{
+    [_remote startListening: self];
+}
+
+- (void)stopListeningWithAppleRemote
+{
+    [_remote stopListening:self];
+}
+
+#pragma mark - menu navigation
+- (void)menuFocusActivate
+{
+    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+    if (p_input_thread == NULL)
+        return;
+
+    input_Control(p_input_thread, INPUT_NAV_ACTIVATE, NULL );
+    vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusLeft
+{
+    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+    if (p_input_thread == NULL)
+        return;
+
+    input_Control(p_input_thread, INPUT_NAV_LEFT, NULL );
+    vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusRight
+{
+    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+    if (p_input_thread == NULL)
+        return;
+
+    input_Control(p_input_thread, INPUT_NAV_RIGHT, NULL );
+    vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusUp
+{
+    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+    if (p_input_thread == NULL)
+        return;
+
+    input_Control(p_input_thread, INPUT_NAV_UP, NULL );
+    vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusDown
+{
+    input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+    if (p_input_thread == NULL)
+        return;
+
+    input_Control(p_input_thread, INPUT_NAV_DOWN, NULL );
+    vlc_object_release(p_input_thread);
+}
+
+/* Helper method for the remote control interface in order to trigger forward/backward and volume
+ increase/decrease as long as the user holds the left/right, plus/minus button */
+- (void) executeHoldActionForRemoteButton: (NSNumber*) buttonIdentifierNumber
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    if (b_remote_button_hold) {
+        switch([buttonIdentifierNumber intValue]) {
+            case kRemoteButtonRight_Hold:
+                [self forward];
+                break;
+            case kRemoteButtonLeft_Hold:
+                [self backward];
+                break;
+            case kRemoteButtonVolume_Plus_Hold:
+                if (p_intf)
+                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_UP);
+                break;
+            case kRemoteButtonVolume_Minus_Hold:
+                if (p_intf)
+                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_DOWN);
+                break;
+        }
+        if (b_remote_button_hold) {
+            /* trigger event */
+            [self performSelector:@selector(executeHoldActionForRemoteButton:)
+                       withObject:buttonIdentifierNumber
+                       afterDelay:0.25];
+        }
+    }
+}
+
+/* Apple Remote callback */
+- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier
+               pressedDown: (BOOL) pressedDown
+                clickCount: (unsigned int) count
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return;
+
+    switch(buttonIdentifier) {
+        case k2009RemoteButtonFullscreen:
+            [self toggleFullscreen];
+            break;
+        case k2009RemoteButtonPlay:
+            [self playOrPause];
+            break;
+        case kRemoteButtonPlay:
+            if (count >= 2)
+                [self toggleFullscreen];
+            else
+                [self playOrPause];
+            break;
+        case kRemoteButtonVolume_Plus:
+            if (config_GetInt(getIntf(), "macosx-appleremote-sysvol"))
+                [NSSound increaseSystemVolume];
+            else
+                if (p_intf)
+                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_UP);
+            break;
+        case kRemoteButtonVolume_Minus:
+            if (config_GetInt(getIntf(), "macosx-appleremote-sysvol"))
+                [NSSound decreaseSystemVolume];
+            else
+                if (p_intf)
+                    var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_DOWN);
+            break;
+        case kRemoteButtonRight:
+            if (config_GetInt(getIntf(), "macosx-appleremote-prevnext"))
+                [self forward];
+            else
+                [self next];
+            break;
+        case kRemoteButtonLeft:
+            if (config_GetInt(getIntf(), "macosx-appleremote-prevnext"))
+                [self backward];
+            else
+                [self previous];
+            break;
+        case kRemoteButtonRight_Hold:
+        case kRemoteButtonLeft_Hold:
+        case kRemoteButtonVolume_Plus_Hold:
+        case kRemoteButtonVolume_Minus_Hold:
+            /* simulate an event as long as the user holds the button */
+            b_remote_button_hold = pressedDown;
+            if (pressedDown) {
+                NSNumber* buttonIdentifierNumber = [NSNumber numberWithInt:buttonIdentifier];
+                [self performSelector:@selector(executeHoldActionForRemoteButton:)
+                           withObject:buttonIdentifierNumber];
+            }
+            break;
+        case kRemoteButtonMenu:
+            [self showPosition];
+            break;
+        case kRemoteButtonPlay_Sleep:
+        {
+            NSAppleScript * script = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to sleep"];
+            [script executeAndReturnError:nil];
+            break;
+        }
+        default:
+            /* Add here whatever you want other buttons to do */
+            break;
+    }
+}
+
+#pragma mark -
+#pragma mark Key Shortcuts
+
+/*****************************************************************************
+ * hasDefinedShortcutKey: Check to see if the key press is a defined VLC
+ * shortcut key.  If it is, pass it off to VLC for handling and return YES,
+ * otherwise ignore it and return NO (where it will get handled by Cocoa).
+ *****************************************************************************/
+
+- (BOOL)keyEvent:(NSEvent *)o_event
+{
+    BOOL eventHandled = NO;
+    NSString * characters = [o_event charactersIgnoringModifiers];
+    if ([characters length] > 0) {
+        unichar key = [characters characterAtIndex: 0];
+
+        if (key) {
+            input_thread_t * p_input = pl_CurrentInput(getIntf());
+            if (p_input != NULL) {
+                vout_thread_t *p_vout = input_GetVout(p_input);
+
+                if (p_vout != NULL) {
+                    /* Escape */
+                    if (key == (unichar) 0x1b) {
+                        if (var_GetBool(p_vout, "fullscreen")) {
+                            [self toggleFullscreen];
+                            eventHandled = YES;
+                        }
+                    }
+                    vlc_object_release(p_vout);
+                }
+                vlc_object_release(p_input);
+            }
+        }
+    }
+    return eventHandled;
+}
+
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force
+{
+    intf_thread_t *p_intf = getIntf();
+    if (!p_intf)
+        return NO;
+
+    unichar key = 0;
+    vlc_value_t val;
+    unsigned int i_pressed_modifiers = 0;
+
+    val.i_int = 0;
+    i_pressed_modifiers = [o_event modifierFlags];
+
+    if (i_pressed_modifiers & NSControlKeyMask)
+        val.i_int |= KEY_MODIFIER_CTRL;
+
+    if (i_pressed_modifiers & NSAlternateKeyMask)
+        val.i_int |= KEY_MODIFIER_ALT;
+
+    if (i_pressed_modifiers & NSShiftKeyMask)
+        val.i_int |= KEY_MODIFIER_SHIFT;
+
+    if (i_pressed_modifiers & NSCommandKeyMask)
+        val.i_int |= KEY_MODIFIER_COMMAND;
+
+    NSString * characters = [o_event charactersIgnoringModifiers];
+    if ([characters length] > 0) {
+        key = [[characters lowercaseString] characterAtIndex: 0];
+
+        /* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */
+        if (key == 'f' && i_pressed_modifiers & NSControlKeyMask && i_pressed_modifiers & NSCommandKeyMask) {
+            [self toggleFullscreen];
+            return YES;
+        }
+
+        if (!b_force) {
+            switch(key) {
+                case NSDeleteCharacter:
+                case NSDeleteFunctionKey:
+                case NSDeleteCharFunctionKey:
+                case NSBackspaceCharacter:
+                case NSUpArrowFunctionKey:
+                case NSDownArrowFunctionKey:
+                case NSEnterCharacter:
+                case NSCarriageReturnCharacter:
+                    return NO;
+            }
+        }
+
+        val.i_int |= CocoaKeyToVLC(key);
+
+        BOOL b_found_key = NO;
+        for (NSUInteger i = 0; i < [_usedHotkeys count]; i++) {
+            NSString *str = [_usedHotkeys objectAtIndex:i];
+            unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa: str];
+
+            if ([[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: str]] &&
+                (i_keyModifiers & NSShiftKeyMask)     == (i_pressed_modifiers & NSShiftKeyMask) &&
+                (i_keyModifiers & NSControlKeyMask)   == (i_pressed_modifiers & NSControlKeyMask) &&
+                (i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) &&
+                (i_keyModifiers & NSCommandKeyMask)   == (i_pressed_modifiers & NSCommandKeyMask)) {
+                b_found_key = YES;
+                break;
+            }
+        }
+
+        if (b_found_key) {
+            var_SetInteger(p_intf->obj.libvlc, "key-pressed", val.i_int);
+            return YES;
+        }
+    }
+
+    return NO;
+}
+
+- (void)updateCurrentlyUsedHotkeys
+{
+    NSMutableArray *mutArray = [[NSMutableArray alloc] init];
+    /* Get the main Module */
+    module_t *p_main = module_get_main();
+    assert(p_main);
+    unsigned confsize;
+    module_config_t *p_config;
+
+    p_config = module_config_get (p_main, &confsize);
+
+    for (size_t i = 0; i < confsize; i++) {
+        module_config_t *p_item = p_config + i;
+
+        if (CONFIG_ITEM(p_item->i_type) && p_item->psz_name != NULL
+            && !strncmp(p_item->psz_name , "key-", 4)
+            && !EMPTY_STR(p_item->psz_text)) {
+            if (p_item->value.psz)
+                [mutArray addObject:toNSStr(p_item->value.psz)];
+        }
+    }
+    module_config_free (p_config);
+
+    _usedHotkeys = [[NSArray alloc] initWithArray:mutArray copyItems:YES];
+}
+
+@end
index 3229672..dd3c1db 100644 (file)
@@ -21,7 +21,7 @@
 
 #import "VLCInputManager.h"
 
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "CompatibilityFixes.h"
 #import "ExtensionsManager.h"
 #import "intf.h"
index c8e4dd1..6ae4fc3 100644 (file)
@@ -39,7 +39,7 @@
 #import "VLCPlaylist.h"
 #import "VLCPlaylistInfo.h"
 #import "VideoView.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCMainWindow.h"
 #import "ControlsBar.h"
 #import "ExtensionsManager.h"
index bc9c1b5..448954b 100644 (file)
@@ -29,7 +29,7 @@
 
 #import "intf.h"
 #import "CompatibilityFixes.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCAudioEffectsWindowController.h"
 #import "VLCMainMenu.h"
 #import "open.h"
index 0389093..1144d92 100644 (file)
@@ -29,8 +29,9 @@
 #import <vlc_common.h>
 #import <vlc_playlist.h>
 #import <vlc_input.h>
-#import <CoreInteraction.h>
-#import <StringUtility.h>
+
+#import "VLCCoreInteraction.h"
+#import "StringUtility.h"
 
 @interface VLCStatusBarIcon ()
 {
index 28aa594..2731303 100644 (file)
@@ -26,7 +26,7 @@
 #import "intf.h"
 #import <vlc_common.h>
 #import "VLCTrackSynchronizationWindowController.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 
 #define SUBSDELAY_CFG_MODE                     "subsdelay-mode"
 #define SUBSDELAY_CFG_FACTOR                   "subsdelay-factor"
index 1549900..6944fb1 100644 (file)
@@ -25,7 +25,7 @@
 #import "intf.h"
 #import "VLCVideoEffectsWindowController.h"
 #import "SharedDialogs.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 
 @interface VLCVideoEffectsWindowController()
 {
index c7faf44..00c2d54 100644 (file)
@@ -34,7 +34,7 @@
 #import "CompatibilityFixes.h"
 #import "intf.h"
 #import "VideoView.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCMainMenu.h"
 
 #import <QuartzCore/QuartzCore.h>
index c2e88a3..58b5c32 100644 (file)
@@ -24,7 +24,7 @@
 
 #import "Windows.h"
 #import "intf.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "ControlsBar.h"
 #import "VideoView.h"
 #import "CompatibilityFixes.h"
index e6fb610..2651ce1 100644 (file)
@@ -27,7 +27,7 @@
  *****************************************************************************/
 #import "intf.h"
 #import "applescript.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCPlaylist.h"
 #import <vlc_url.h>
 
index 91d3d48..9c4abd2 100644 (file)
@@ -27,7 +27,7 @@
  * Preamble
  *****************************************************************************/
 #import "intf.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCMainWindow.h"
 #import "misc.h"
 #import "fspanel.h"
index b27ec91..fcdc20c 100644 (file)
@@ -24,7 +24,7 @@
  *****************************************************************************/
 
 #import "intf-prefs.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 
 #include <unistd.h> /* execl() */
 
index 828e710..f268118 100644 (file)
@@ -54,7 +54,7 @@
 #import "VLCBookmarksWindowController.h"
 #import "VLCCoreDialogProvider.h"
 #import "simple_prefs.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import "VLCTrackSynchronizationWindowController.h"
 #import "ExtensionsManager.h"
 #import "BWQuincyManager.h"
index 161d5ba..dd784eb 100644 (file)
@@ -28,7 +28,7 @@
 #import "VLCMainWindow.h"
 #import "VLCMainMenu.h"
 #import "ControlsBar.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import <CoreAudio/CoreAudio.h>
 #import <vlc_keys.h>
 
index 56c695b..b8dd43e 100644 (file)
@@ -58,7 +58,7 @@
 #import "prefs.h"
 #import "simple_prefs.h"
 #import "prefs_widgets.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 #import <vlc_keys.h>
 #import <vlc_modules.h>
 #import <vlc_plugin.h>
index d10a600..0944535 100644 (file)
@@ -37,7 +37,7 @@
 #import "intf.h"
 #import "intf-prefs.h"
 #import "AppleRemote.h"
-#import "CoreInteraction.h"
+#import "VLCCoreInteraction.h"
 
 #ifdef HAVE_SPARKLE
 #import <Sparkle/Sparkle.h>                        //for o_intf_last_updateLabel