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

macosx: refactor main class object life management and main menu

parent db62975c
...@@ -374,8 +374,6 @@ ...@@ -374,8 +374,6 @@
1CCB5F5B1A62A724004C3E90 /* bookmarks.h in Sources */ = {isa = PBXBuildFile; fileRef = DCE7BD0708A5724D007B10AE /* bookmarks.h */; }; 1CCB5F5B1A62A724004C3E90 /* bookmarks.h in Sources */ = {isa = PBXBuildFile; fileRef = DCE7BD0708A5724D007B10AE /* bookmarks.h */; };
1CCB5F5C1A62A724004C3E90 /* bookmarks.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE7BD0608A5724D007B10AE /* bookmarks.m */; }; 1CCB5F5C1A62A724004C3E90 /* bookmarks.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE7BD0608A5724D007B10AE /* bookmarks.m */; };
1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */ = {isa = PBXBuildFile; fileRef = CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */; }; 1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */ = {isa = PBXBuildFile; fileRef = CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */; };
1CCB5F5E1A62A724004C3E90 /* controls.h in Sources */ = {isa = PBXBuildFile; fileRef = 8E6BC6FA041684EC0059A3A7 /* controls.h */; };
1CCB5F5F1A62A724004C3E90 /* controls.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ED6C27B03E2EB1C0059A3A7 /* controls.m */; };
1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */ = {isa = PBXBuildFile; fileRef = E0382C00160BA09E0031D7FF /* ControlsBar.h */; }; 1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */ = {isa = PBXBuildFile; fileRef = E0382C00160BA09E0031D7FF /* ControlsBar.h */; };
1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = E0382C01160BA09E0031D7FF /* ControlsBar.m */; }; 1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = E0382C01160BA09E0031D7FF /* ControlsBar.m */; };
1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */ = {isa = PBXBuildFile; fileRef = CC0663341566C34C003A411C /* ConvertAndSave.h */; }; 1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */ = {isa = PBXBuildFile; fileRef = CC0663341566C34C003A411C /* ConvertAndSave.h */; };
...@@ -1272,12 +1270,10 @@ ...@@ -1272,12 +1270,10 @@
8E55FB800459B0FD00FB3317 /* output.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = output.m; path = ../../../modules/gui/macosx/output.m; sourceTree = SOURCE_ROOT; }; 8E55FB800459B0FD00FB3317 /* output.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = output.m; path = ../../../modules/gui/macosx/output.m; sourceTree = SOURCE_ROOT; };
8E6BC6F6041643860059A3A7 /* applescript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = applescript.h; path = ../../../modules/gui/macosx/applescript.h; sourceTree = SOURCE_ROOT; }; 8E6BC6F6041643860059A3A7 /* applescript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = applescript.h; path = ../../../modules/gui/macosx/applescript.h; sourceTree = SOURCE_ROOT; };
8E6BC6F7041643860059A3A7 /* applescript.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = applescript.m; path = ../../../modules/gui/macosx/applescript.m; sourceTree = SOURCE_ROOT; }; 8E6BC6F7041643860059A3A7 /* applescript.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = applescript.m; path = ../../../modules/gui/macosx/applescript.m; sourceTree = SOURCE_ROOT; };
8E6BC6FA041684EC0059A3A7 /* controls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = controls.h; path = ../../../modules/gui/macosx/controls.h; sourceTree = SOURCE_ROOT; };
8E9CA1A306D7DEE800B7186C /* prefs_widgets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = prefs_widgets.h; path = ../../../modules/gui/macosx/prefs_widgets.h; sourceTree = SOURCE_ROOT; }; 8E9CA1A306D7DEE800B7186C /* prefs_widgets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = prefs_widgets.h; path = ../../../modules/gui/macosx/prefs_widgets.h; sourceTree = SOURCE_ROOT; };
8E9CA1A406D7DEE800B7186C /* prefs_widgets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = prefs_widgets.m; path = ../../../modules/gui/macosx/prefs_widgets.m; sourceTree = SOURCE_ROOT; }; 8E9CA1A406D7DEE800B7186C /* prefs_widgets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = prefs_widgets.m; path = ../../../modules/gui/macosx/prefs_widgets.m; sourceTree = SOURCE_ROOT; };
8EBF3FA303F13FFB0059A3A7 /* vlc.scriptSuite */ = {isa = PBXFileReference; lastKnownFileType = text; name = vlc.scriptSuite; path = Resources/vlc.scriptSuite; sourceTree = SOURCE_ROOT; }; 8EBF3FA303F13FFB0059A3A7 /* vlc.scriptSuite */ = {isa = PBXFileReference; lastKnownFileType = text; name = vlc.scriptSuite; path = Resources/vlc.scriptSuite; sourceTree = SOURCE_ROOT; };
8EBF3FA503F140960059A3A7 /* vlc.scriptTerminology */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = vlc.scriptTerminology; path = Resources/vlc.scriptTerminology; sourceTree = SOURCE_ROOT; }; 8EBF3FA503F140960059A3A7 /* vlc.scriptTerminology */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = vlc.scriptTerminology; path = Resources/vlc.scriptTerminology; sourceTree = SOURCE_ROOT; };
8ED6C27B03E2EB1C0059A3A7 /* controls.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = controls.m; path = ../../../modules/gui/macosx/controls.m; sourceTree = SOURCE_ROOT; };
8ED6C27C03E2EB1C0059A3A7 /* intf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = intf.h; path = ../../../modules/gui/macosx/intf.h; sourceTree = SOURCE_ROOT; }; 8ED6C27C03E2EB1C0059A3A7 /* intf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = intf.h; path = ../../../modules/gui/macosx/intf.h; sourceTree = SOURCE_ROOT; };
8ED6C27D03E2EB1C0059A3A7 /* intf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = intf.m; path = ../../../modules/gui/macosx/intf.m; sourceTree = SOURCE_ROOT; }; 8ED6C27D03E2EB1C0059A3A7 /* intf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = intf.m; path = ../../../modules/gui/macosx/intf.m; sourceTree = SOURCE_ROOT; };
8ED6C27E03E2EB1C0059A3A7 /* macosx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = macosx.m; path = ../../../modules/gui/macosx/macosx.m; sourceTree = SOURCE_ROOT; }; 8ED6C27E03E2EB1C0059A3A7 /* macosx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = macosx.m; path = ../../../modules/gui/macosx/macosx.m; sourceTree = SOURCE_ROOT; };
...@@ -1827,8 +1823,6 @@ ...@@ -1827,8 +1823,6 @@
DCE7BD0708A5724D007B10AE /* bookmarks.h */, DCE7BD0708A5724D007B10AE /* bookmarks.h */,
DCE7BD0608A5724D007B10AE /* bookmarks.m */, DCE7BD0608A5724D007B10AE /* bookmarks.m */,
CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */, CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */,
8E6BC6FA041684EC0059A3A7 /* controls.h */,
8ED6C27B03E2EB1C0059A3A7 /* controls.m */,
E0382C00160BA09E0031D7FF /* ControlsBar.h */, E0382C00160BA09E0031D7FF /* ControlsBar.h */,
E0382C01160BA09E0031D7FF /* ControlsBar.m */, E0382C01160BA09E0031D7FF /* ControlsBar.m */,
CC0663341566C34C003A411C /* ConvertAndSave.h */, CC0663341566C34C003A411C /* ConvertAndSave.h */,
...@@ -3854,8 +3848,6 @@ ...@@ -3854,8 +3848,6 @@
1CCB5F5B1A62A724004C3E90 /* bookmarks.h in Sources */, 1CCB5F5B1A62A724004C3E90 /* bookmarks.h in Sources */,
1CCB5F5C1A62A724004C3E90 /* bookmarks.m in Sources */, 1CCB5F5C1A62A724004C3E90 /* bookmarks.m in Sources */,
1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */, 1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */,
1CCB5F5E1A62A724004C3E90 /* controls.h in Sources */,
1CCB5F5F1A62A724004C3E90 /* controls.m in Sources */,
1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */, 1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */,
1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */, 1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */,
1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */, 1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */,
......
...@@ -1104,7 +1104,7 @@ else \ ...@@ -1104,7 +1104,7 @@ else \
- (IBAction)effects:(id)sender - (IBAction)effects:(id)sender
{ {
[[VLCMainMenu sharedInstance] showAudioEffects: sender]; [[[VLCMain sharedInstance] mainMenu] showAudioEffects: sender];
} }
#pragma mark - #pragma mark -
...@@ -1161,7 +1161,7 @@ else \ ...@@ -1161,7 +1161,7 @@ else \
[o_next_btn setEnabled: (b_seekable || b_plmul || b_chapters)]; [o_next_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
} }
[[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control]; [[[VLCMain sharedInstance] mainMenu] setRateControlsEnabled: b_control];
} }
@end @end
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
- (void)volumeUp; - (void)volumeUp;
- (void)volumeDown; - (void)volumeDown;
- (void)toggleMute; - (void)toggleMute;
- (void)showPosition;
- (void)startListeningWithAppleRemote; - (void)startListeningWithAppleRemote;
- (void)stopListeningWithAppleRemote; - (void)stopListeningWithAppleRemote;
...@@ -82,6 +83,7 @@ ...@@ -82,6 +83,7 @@
- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter string: (const char *)psz_value; - (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter string: (const char *)psz_value;
- (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter boolean: (BOOL)b_value; - (void)setVideoFilterProperty: (const char *)psz_name forFilter: (const char *)psz_filter boolean: (BOOL)b_value;
- (BOOL)keyEvent:(NSEvent *)o_event;
- (void)updateCurrentlyUsedHotkeys; - (void)updateCurrentlyUsedHotkeys;
- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force; - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#import "SPMediaKeyTap.h" #import "SPMediaKeyTap.h"
#import "AppleRemote.h" #import "AppleRemote.h"
#import "InputManager.h" #import "InputManager.h"
#import "controls.h"
static int BossCallback(vlc_object_t *p_this, const char *psz_var, static int BossCallback(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param) vlc_value_t oldval, vlc_value_t new_val, void *param)
...@@ -616,6 +615,19 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var, ...@@ -616,6 +615,19 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
vlc_object_release(p_input); vlc_object_release(p_input);
} }
- (void)showPosition
{
input_thread_t *p_input = pl_CurrentInput(VLCIntf);
if (p_input != NULL) {
vout_thread_t *p_vout = input_GetVout(p_input);
if (p_vout != NULL) {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_POSITION);
vlc_object_release(p_vout);
}
vlc_object_release(p_input);
}
}
#pragma mark - drag and drop support for VLCVoutView, VLCDragDropView and VLCThreePartDropView #pragma mark - drag and drop support for VLCVoutView, VLCDragDropView and VLCThreePartDropView
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{ {
...@@ -1152,7 +1164,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var, ...@@ -1152,7 +1164,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
} }
break; break;
case kRemoteButtonMenu: case kRemoteButtonMenu:
[[[VLCMain sharedInstance] controls] showPosition: self]; //FIXME [self showPosition];
break; break;
case kRemoteButtonPlay_Sleep: case kRemoteButtonPlay_Sleep:
{ {
...@@ -1174,6 +1186,36 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var, ...@@ -1174,6 +1186,36 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
* shortcut key. If it is, pass it off to VLC for handling and return YES, * 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). * 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(VLCIntf);
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 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force
{ {
intf_thread_t *p_intf = VLCIntf; intf_thread_t *p_intf = VLCIntf;
......
This diff is collapsed.
This diff is collapsed.
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#import "AudioEffects.h" #import "AudioEffects.h"
#import "MainMenu.h" #import "MainMenu.h"
#import "open.h" #import "open.h"
#import "controls.h" // TODO: remove me
#import "playlist.h" #import "playlist.h"
#import "SideBarItem.h" #import "SideBarItem.h"
#import <math.h> #import <math.h>
...@@ -146,8 +145,9 @@ static VLCMainWindow *sharedInstance = nil; ...@@ -146,8 +145,9 @@ static VLCMainWindow *sharedInstance = nil;
else else
b_force = YES; b_force = YES;
return [[VLCCoreInteraction sharedInstance] hasDefinedShortcutKey:o_event force:b_force] || VLCCoreInteraction *coreInteraction = [VLCCoreInteraction sharedInstance];
[(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event]; return [coreInteraction hasDefinedShortcutKey:o_event force:b_force] ||
[coreInteraction keyEvent:o_event];
} }
- (void)dealloc - (void)dealloc
......
...@@ -29,7 +29,6 @@ libmacosx_plugin_la_SOURCES = \ ...@@ -29,7 +29,6 @@ libmacosx_plugin_la_SOURCES = \
BWQuincyManager.h BWQuincyManager.m \ BWQuincyManager.h BWQuincyManager.m \
BWQuincyUI.h BWQuincyUI.m \ BWQuincyUI.h BWQuincyUI.m \
CompatibilityFixes.h \ CompatibilityFixes.h \
controls.h controls.m \
ControlsBar.m ControlsBar.h \ ControlsBar.m ControlsBar.h \
ConvertAndSave.h ConvertAndSave.m \ ConvertAndSave.h ConvertAndSave.m \
coredialogs.h coredialogs.m \ coredialogs.h coredialogs.m \
......
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
} else if (([o_event type] == NSRightMouseDown) || } else if (([o_event type] == NSRightMouseDown) ||
(([o_event type] == NSLeftMouseDown) && (([o_event type] == NSLeftMouseDown) &&
([o_event modifierFlags] & NSControlKeyMask))) ([o_event modifierFlags] & NSControlKeyMask)))
[NSMenu popUpContextMenu: [[VLCMainMenu sharedInstance] voutMenu] withEvent: o_event forView: self]; [NSMenu popUpContextMenu: [[[VLCMain sharedInstance] mainMenu] voutMenu] withEvent: o_event forView: self];
[super mouseDown: o_event]; [super mouseDown: o_event];
} }
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
- (void)rightMouseDown:(NSEvent *)o_event - (void)rightMouseDown:(NSEvent *)o_event
{ {
if ([o_event type] == NSRightMouseDown) if ([o_event type] == NSRightMouseDown)
[NSMenu popUpContextMenu: [[VLCMainMenu sharedInstance] voutMenu] withEvent: o_event forView: self]; [NSMenu popUpContextMenu: [[[VLCMain sharedInstance] mainMenu] voutMenu] withEvent: o_event forView: self];
[super mouseDown: o_event]; [super mouseDown: o_event];
} }
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
- (void)rightMouseUp:(NSEvent *)o_event - (void)rightMouseUp:(NSEvent *)o_event
{ {
if ([o_event type] == NSRightMouseUp) if ([o_event type] == NSRightMouseUp)
[NSMenu popUpContextMenu: [[VLCMainMenu sharedInstance] voutMenu] withEvent: o_event forView: self]; [NSMenu popUpContextMenu: [[[VLCMain sharedInstance] mainMenu] voutMenu] withEvent: o_event forView: self];
[super mouseUp: o_event]; [super mouseUp: o_event];
} }
......
/*****************************************************************************
* controls.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Derk-Jan Hartman <thedj@users.sourceforge.net>
* Felix Paul Kühne <fkuehne at videolan 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.
*****************************************************************************/
/*****************************************************************************
* VLCControls interface
*****************************************************************************/
@interface VLCControls : NSObject
{
IBOutlet id o_main;
IBOutlet id o_specificTime_cancel_btn;
IBOutlet id o_specificTime_enter_fld;
IBOutlet id o_specificTime_goTo_lbl;
IBOutlet id o_specificTime_ok_btn;
IBOutlet id o_specificTime_win;
IBOutlet id o_specificTime_sec_lbl;
IBOutlet id o_specificTime_stepper;
IBOutlet id o_specificTime_mi;
}
@property (nonatomic) int jumpTimeValue;
- (IBAction)play:(id)sender;
- (IBAction)stop:(id)sender;
- (IBAction)prev:(id)sender;
- (IBAction)next:(id)sender;
- (IBAction)random:(id)sender;
- (IBAction)repeat:(id)sender;
- (IBAction)loop:(id)sender;
- (IBAction)forward:(id)sender;
- (IBAction)backward:(id)sender;
- (IBAction)volumeUp:(id)sender;
- (IBAction)volumeDown:(id)sender;
- (IBAction)mute:(id)sender;
- (IBAction)volumeSliderUpdated:(id)sender;
- (IBAction)showPosition: (id)sender;
- (IBAction)lockVideosAspectRatio:(id)sender;
- (BOOL)keyEvent:(NSEvent *)o_event;
- (IBAction)goToSpecificTime:(id)sender;
@end
/*****************************************************************************
* controls.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* Benjamin Pracht <bigben at videolan doit org>
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
#import "intf.h"
#import "VideoView.h"
#import "open.h"
#import "controls.h"
#import "playlist.h"
#import "MainMenu.h"
#import "CoreInteraction.h"
#import "misc.h"
#import <vlc_keys.h>
#pragma mark -
/*****************************************************************************
* VLCControls implementation
*****************************************************************************/
@implementation VLCControls
- (void)awakeFromNib
{
[o_specificTime_mi setTitle: _NS("Jump to Time")];
[o_specificTime_cancel_btn setTitle: _NS("Cancel")];
[o_specificTime_ok_btn setTitle: _NS("OK")];
[o_specificTime_sec_lbl setStringValue: _NS("sec.")];
[o_specificTime_goTo_lbl setStringValue: _NS("Jump to Time")];
[o_specificTime_enter_fld setFormatter:[[PositionFormatter alloc] init]];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
}
- (IBAction)play:(id)sender
{
[[VLCCoreInteraction sharedInstance] playOrPause];
}
- (IBAction)stop:(id)sender
{
[[VLCCoreInteraction sharedInstance] stop];
}
- (IBAction)prev:(id)sender
{
[[VLCCoreInteraction sharedInstance] previous];
}
- (IBAction)next:(id)sender
{
[[VLCCoreInteraction sharedInstance] next];
}
- (IBAction)random:(id)sender
{
[[VLCCoreInteraction sharedInstance] shuffle];
}
- (IBAction)repeat:(id)sender
{
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get(p_intf);
var_Get(p_playlist, "repeat", &val);
if (! val.b_bool)
[[VLCCoreInteraction sharedInstance] repeatOne];
else
[[VLCCoreInteraction sharedInstance] repeatOff];
}
- (IBAction)loop:(id)sender
{
vlc_value_t val;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get(p_intf);
var_Get(p_playlist, "loop", &val);
if (! val.b_bool)
[[VLCCoreInteraction sharedInstance] repeatAll];
else
[[VLCCoreInteraction sharedInstance] repeatOff];
}
- (IBAction)forward:(id)sender
{
[[VLCCoreInteraction sharedInstance] forward];
}
- (IBAction)backward:(id)sender
{
[[VLCCoreInteraction sharedInstance] backward];
}
- (IBAction)volumeUp:(id)sender
{
[[VLCCoreInteraction sharedInstance] volumeUp];
}
- (IBAction)volumeDown:(id)sender
{
[[VLCCoreInteraction sharedInstance] volumeDown];
}
- (IBAction)mute:(id)sender
{
[[VLCCoreInteraction sharedInstance] toggleMute];
}
- (IBAction)volumeSliderUpdated:(id)sender
{
[[VLCCoreInteraction sharedInstance] setVolume: [sender intValue]];
}
- (IBAction)showPosition: (id)sender
{
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (p_input != NULL) {
vout_thread_t *p_vout = input_GetVout(p_input);
if (p_vout != NULL) {
var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_POSITION);
vlc_object_release(p_vout);
}
vlc_object_release(p_input);
}
}
- (IBAction)lockVideosAspectRatio:(id)sender
{
[[VLCCoreInteraction sharedInstance] setAspectRatioIsLocked: ![sender state]];
[sender setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
}
- (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(VLCIntf);
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")) {
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
eventHandled = YES;
}
}
vlc_object_release(p_vout);
}
vlc_object_release(p_input);
}
}
}
return eventHandled;
}
- (IBAction)goToSpecificTime:(id)sender
{
if (sender == o_specificTime_cancel_btn)
{
[NSApp endSheet: o_specificTime_win];
[o_specificTime_win close];
} else if (sender == o_specificTime_ok_btn) {
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
int64_t timeInSec = 0;
NSString * fieldContent = [o_specificTime_enter_fld stringValue];
if ([[fieldContent componentsSeparatedByString: @":"] count] > 1 &&
[[fieldContent componentsSeparatedByString: @":"] count] <= 3) {
NSArray * ourTempArray = \
[fieldContent componentsSeparatedByString: @":"];
if ([[fieldContent componentsSeparatedByString: @":"] count] == 3) {
timeInSec += ([[ourTempArray firstObject] intValue] * 3600); //h
timeInSec += ([[ourTempArray objectAtIndex:1] intValue] * 60); //m
timeInSec += [[ourTempArray objectAtIndex:2] intValue]; //s
} else {
timeInSec += ([[ourTempArray firstObject] intValue] * 60); //m
timeInSec += [[ourTempArray objectAtIndex:1] intValue]; //s
}
}
else
timeInSec = [fieldContent intValue];
input_Control(p_input, INPUT_SET_TIME, (int64_t)(timeInSec * 1000000));
vlc_object_release(p_input);
}
[NSApp endSheet: o_specificTime_win];
[o_specificTime_win close];
} else {
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
/* we can obviously only do that if an input is available */
int64_t pos, length;
length = var_GetInteger(p_input, "length");
[o_specificTime_stepper setMaxValue: (length / CLOCK_FREQ)];
pos = var_GetInteger(p_input, "time");
[self setJumpTimeValue: (pos / CLOCK_FREQ)];
[NSApp beginSheet: o_specificTime_win modalForWindow: \
[NSApp mainWindow] modalDelegate: self didEndSelector: nil \
contextInfo: nil];
[o_specificTime_win makeKeyWindow];
vlc_object_release(p_input);
}
}
}
@end
@implementation VLCControls (NSMenuValidation)
- (BOOL)validateMenuItem:(NSMenuItem *)o_mi
{
return [[VLCMainMenu sharedInstance] validateMenuItem:o_mi];
}
@end
...@@ -55,7 +55,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -55,7 +55,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
*****************************************************************************/ *****************************************************************************/
@class AppleRemote; @class AppleRemote;
@class VLCInfo; @class VLCInfo;
@class VLCControls;
@class VLCMainMenu; @class VLCMainMenu;
@class VLCPlaylist; @class VLCPlaylist;
@class VLCInputManager; @class VLCInputManager;
...@@ -70,8 +69,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -70,8 +69,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{ {
IBOutlet VLCMainWindow *o_mainwindow; /* VLCMainWindow */ IBOutlet VLCMainWindow *o_mainwindow; /* VLCMainWindow */
IBOutlet VLCControls * o_controls; /* VLCControls */
IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */ IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
} }
...@@ -85,7 +82,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -85,7 +82,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCMainMenu *)mainMenu; - (VLCMainMenu *)mainMenu;
- (VLCMainWindow *)mainWindow; - (VLCMainWindow *)mainWindow;
- (VLCControls *)controls;
- (VLCBookmarks *)bookmarks; - (VLCBookmarks *)bookmarks;
- (VLCOpen *)open; - (VLCOpen *)open;
- (VLCSimplePrefs *)simplePreferences; - (VLCSimplePrefs *)simplePreferences;
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#import "prefs.h" #import "prefs.h"
#import "playlist.h" #import "playlist.h"
#import "playlistinfo.h" #import "playlistinfo.h"
#import "controls.h"
#import "open.h" #import "open.h"
#import "bookmarks.h" #import "bookmarks.h"
#import "coredialogs.h" #import "coredialogs.h"
...@@ -73,6 +72,8 @@ ...@@ -73,6 +72,8 @@
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
static VLCMain *sharedInstance = nil;
#pragma mark - #pragma mark -
#pragma mark VLC Interface Object Callbacks #pragma mark VLC Interface Object Callbacks
...@@ -91,11 +92,6 @@ int OpenIntf (vlc_object_t *p_this) ...@@ -91,11 +92,6 @@ int OpenIntf (vlc_object_t *p_this)
[VLCVoutWindowController sharedInstance]; [VLCVoutWindowController sharedInstance];
[NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
[NSBundle loadNibNamed:@"MainWindow" owner:[VLCMain sharedInstance]];
[[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
} }
...@@ -105,6 +101,7 @@ void CloseIntf (vlc_object_t *p_this) ...@@ -105,6 +101,7 @@ void CloseIntf (vlc_object_t *p_this)
@autoreleasepool { @autoreleasepool {
msg_Dbg(p_this, "Closing macosx interface"); msg_Dbg(p_this, "Closing macosx interface");
[[VLCMain sharedInstance] applicationWillTerminate:nil]; [[VLCMain sharedInstance] applicationWillTerminate:nil];
sharedInstance = nil;
} }
} }
...@@ -151,8 +148,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -151,8 +148,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
BOOL nib_main_loaded; /* main nibfile */ BOOL nib_main_loaded; /* main nibfile */
BOOL nib_open_loaded; /* open nibfile */ BOOL nib_open_loaded; /* open nibfile */
BOOL nib_about_loaded; /* about nibfile */ BOOL nib_about_loaded; /* about nibfile */
BOOL nib_prefs_loaded; /* preferences nibfile */ BOOL nib_prefs_loaded; /* preferences xibfile */
BOOL nib_info_loaded; /* information panel nibfile */ BOOL nib_sprefs_loaded; /* simple preferences xibfile */
BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */ BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */ BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */
BOOL b_active_videoplayback; BOOL b_active_videoplayback;
...@@ -162,7 +159,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -162,7 +159,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCSimplePrefs *_sprefs; VLCSimplePrefs *_sprefs;
VLCOpen *_open; VLCOpen *_open;
VLCCoreDialogProvider *_coredialogs; VLCCoreDialogProvider *_coredialogs;
VLCInfo *_info;
VLCEyeTVController *_eyetv; VLCEyeTVController *_eyetv;
VLCBookmarks *_bookmarks; VLCBookmarks *_bookmarks;
VLCCoreInteraction *_coreinteraction; VLCCoreInteraction *_coreinteraction;
...@@ -185,7 +181,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -185,7 +181,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
+ (VLCMain *)sharedInstance + (VLCMain *)sharedInstance
{ {
static dispatch_once_t pred; static dispatch_once_t pred;
static VLCMain *sharedInstance = nil;
dispatch_once(&pred, ^{ dispatch_once(&pred, ^{
sharedInstance = [VLCMain new]; sharedInstance = [VLCMain new];
...@@ -200,9 +195,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -200,9 +195,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
p_intf = NULL; p_intf = NULL;
_open = [[VLCOpen alloc] init]; [VLCApplication sharedApplication].delegate = self;
_mainmenu = [VLCMainMenu sharedInstance];
_eyetv = [[VLCEyeTVController alloc] init];
/* announce our launch to a potential eyetv plugin */ /* announce our launch to a potential eyetv plugin */
[[NSDistributedNotificationCenter defaultCenter] postNotificationName: @"VLCOSXGUIInit" [[NSDistributedNotificationCenter defaultCenter] postNotificationName: @"VLCOSXGUIInit"
...@@ -219,6 +212,20 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -219,6 +212,20 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return self; return self;
} }
- (void)dealloc
{
_mainmenu = nil;
_prefs = nil;
_sprefs = nil;
_open = nil;
_coredialogs = nil;
_eyetv = nil;
_bookmarks = nil;
_coreinteraction = nil;
_resume_dialog = nil;
_input_manager = nil;
}
- (void)setIntf: (intf_thread_t *)p_mainintf - (void)setIntf: (intf_thread_t *)p_mainintf
{ {
p_intf = p_mainintf; p_intf = p_mainintf;
...@@ -229,13 +236,35 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -229,13 +236,35 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return p_intf; return p_intf;
} }
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
_open = [[VLCOpen alloc] init];
_mainmenu = [[VLCMainMenu alloc] init];
[NSBundle loadNibNamed:@"MainMenu" owner:_mainmenu];
[NSBundle loadNibNamed:@"MainWindow" owner:[VLCMain sharedInstance]];
[[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
_eyetv = [[VLCEyeTVController alloc] init];
_coreinteraction = [VLCCoreInteraction sharedInstance];
playlist_t * p_playlist = pl_Get(VLCIntf);
PL_LOCK;
items_at_launch = p_playlist->p_local_category->i_children;
PL_UNLOCK;
#ifdef HAVE_SPARKLE
[[SUUpdater sharedUpdater] setDelegate:self];
#endif
}
- (void)awakeFromNib - (void)awakeFromNib
{ {
if (!p_intf) return; if (!p_intf) return;
var_Create(p_intf, "intf-change", VLC_VAR_BOOL); var_Create(p_intf, "intf-change", VLC_VAR_BOOL);
/* Check if we already did this once. Opening the other nibs calls it too, /* Check if we already did this once */
because VLCMain is the owner */
if (nib_main_loaded) if (nib_main_loaded)
return; return;
...@@ -270,20 +299,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -270,20 +299,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
nib_main_loaded = TRUE; nib_main_loaded = TRUE;
} }
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
_coreinteraction = [VLCCoreInteraction sharedInstance];
playlist_t * p_playlist = pl_Get(VLCIntf);
PL_LOCK;
items_at_launch = p_playlist->p_local_category->i_children;
PL_UNLOCK;
#ifdef HAVE_SPARKLE
[[SUUpdater sharedUpdater] setDelegate:self];
#endif
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
launched = YES; launched = YES;
...@@ -525,11 +540,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -525,11 +540,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return o_mainwindow; return o_mainwindow;
} }
- (VLCControls *)controls
{
return o_controls;
}
- (VLCInputManager *)inputManager - (VLCInputManager *)inputManager
{ {
return _input_manager; return _input_manager;
...@@ -559,8 +569,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -559,8 +569,8 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
if (!_sprefs) if (!_sprefs)
_sprefs = [[VLCSimplePrefs alloc] init]; _sprefs = [[VLCSimplePrefs alloc] init];
if (!nib_prefs_loaded) if (!nib_sprefs_loaded)
nib_prefs_loaded = [NSBundle loadNibNamed:@"SimplePreferences" owner: _sprefs]; nib_sprefs_loaded = [NSBundle loadNibNamed:@"SimplePreferences" owner: _sprefs];
return _sprefs; return _sprefs;
} }
......
/***************************************************************************** /*****************************************************************************
* misc.m: code not specific to vlc * misc.m: code not specific to vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2014 VLC authors and VideoLAN * Copyright (C) 2003-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#import "misc.h" #import "misc.h"
#import "intf.h" /* VLCApplication */ #import "intf.h" /* VLCApplication */
#import "MainWindow.h" #import "MainWindow.h"
#import "MainMenu.h"
#import "ControlsBar.h" #import "ControlsBar.h"
#import "controls.h"
#import "CoreInteraction.h" #import "CoreInteraction.h"
#import <CoreAudio/CoreAudio.h> #import <CoreAudio/CoreAudio.h>
#import <vlc_keys.h> #import <vlc_keys.h>
...@@ -791,7 +791,7 @@ void _drawFrameInRect(NSRect frameRect) ...@@ -791,7 +791,7 @@ void _drawFrameInRect(NSRect frameRect)
- (void)mouseDown: (NSEvent *)ourEvent - (void)mouseDown: (NSEvent *)ourEvent
{ {
if ( [ourEvent clickCount] > 1 ) if ( [ourEvent clickCount] > 1 )
[[[VLCMain sharedInstance] controls] goToSpecificTime: nil]; [[[VLCMain sharedInstance] mainMenu] goToSpecificTime: nil];
else else
{ {
if (o_remaining_identifier) { if (o_remaining_identifier) {
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#import "bookmarks.h" #import "bookmarks.h"
#import "playlistinfo.h" #import "playlistinfo.h"
#import "playlist.h" #import "playlist.h"
#import "controls.h"
#import "misc.h" #import "misc.h"
#import "open.h" #import "open.h"
#import "MainMenu.h" #import "MainMenu.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment