/*****************************************************************************
* applescript.m: MacOS X AppleScript support
*****************************************************************************
- * Copyright (C) 2002-2003 the VideoLAN team
+ * Copyright (C) 2002-2009 the VideoLAN team
* $Id$
*
* Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
* 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
#include "controls.h"
#include "open.h"
-
/*****************************************************************************
- * VLGetURLScriptCommand implementation
+ * VLGetURLScriptCommand implementation
*****************************************************************************/
@implementation VLGetURLScriptCommand
if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
{
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
+ playlist_t * p_playlist = pl_Get( p_intf );
if( p_playlist == NULL )
{
return nil;
NSURL * o_url;
input_item_t *p_input;
- p_input = input_ItemNew( p_playlist,
- [o_urlString fileSystemRepresentation],
+ p_input = input_item_New( [o_urlString fileSystemRepresentation],
[[[NSFileManager defaultManager]
displayNameAtPath: o_urlString] UTF8String] );
- playlist_PlaylistAddInput( p_playlist, p_input, PLAYLIST_INSERT,
- PLAYLIST_END );
+ /* FIXME: playlist_AddInput() can fail */
+ playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
+ PLAYLIST_END, true, pl_Unlocked );
+ vlc_gc_decref( p_input );
o_url = [NSURL fileURLWithPath: o_urlString];
if( o_url != nil )
noteNewRecentDocumentURL: o_url];
}
}
- vlc_object_release( p_playlist );
}
return nil;
}
/*****************************************************************************
- * VLControlScriptCommand implementation
+ * VLControlScriptCommand implementation
*****************************************************************************/
/*
* This entire control command needs a better design. more object oriented.
NSString *o_command = [[self commandDescription] commandName];
intf_thread_t * p_intf = VLCIntf;
- playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
+ playlist_t * p_playlist = pl_Get( p_intf );
if( p_playlist == NULL )
{
return nil;
}
-
- VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls];
-
+
+ VLCControls * o_controls = [[VLCMain sharedInstance] controls];
+
if ( o_controls )
{
if ( [o_command isEqualToString:@"play"] )
{
[o_controls play:self];
- return nil;
}
else if ( [o_command isEqualToString:@"stop"] )
{
[o_controls stop:self];
- return nil;
}
else if ( [o_command isEqualToString:@"previous"] )
{
[o_controls prev:self];
- return nil;
}
else if ( [o_command isEqualToString:@"next"] )
{
[o_controls next:self];
- return nil;
}
else if ( [o_command isEqualToString:@"fullscreen"] )
{
- NSMenuItem *o_mi = [[NSMenuItem alloc] initWithTitle: _NS("Fullscreen") action: nil keyEquivalent:@""];
- [o_controls windowAction:[o_mi autorelease]];
- return nil;
+ [o_controls toogleFullscreen: self];
}
else if ( [o_command isEqualToString:@"mute"] )
{
[o_controls mute:self];
- return nil;
}
else if ( [o_command isEqualToString:@"volumeUp"] )
{
[o_controls volumeUp:self];
- return nil;
}
else if ( [o_command isEqualToString:@"volumeDown"] )
{
[o_controls volumeDown:self];
- return nil;
}
}
- vlc_object_release( p_playlist );
return nil;
}
@end
+
+/*****************************************************************************
+ * Category that adds AppleScript support to NSApplication
+ *****************************************************************************/
+@implementation NSApplication(ScriptSupport)
+
+- (BOOL) scriptFullscreenMode {
+ return [[[VLCMain sharedInstance] controls] isFullscreen];
+}
+- (void) setScriptFullscreenMode: (BOOL) mode {
+ VLCControls * o_controls = [[VLCMain sharedInstance] controls];
+ if (mode == [o_controls isFullscreen]) return;
+ [o_controls toogleFullscreen: self];
+}
+
+@end