X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fapplescript.m;h=232d7e53d42680993302bd9166266152b5099b6c;hb=3561b9b28f58eb7a4183e158a8fd973800d31ceb;hp=47d427df9ec9685750120ab51f5576e8ffd1bce2;hpb=85c7ea2e8e6a0d5b3c6acebf3e7d94da695cacd3;p=vlc diff --git a/modules/gui/macosx/applescript.m b/modules/gui/macosx/applescript.m index 47d427df9e..232d7e53d4 100644 --- a/modules/gui/macosx/applescript.m +++ b/modules/gui/macosx/applescript.m @@ -1,8 +1,8 @@ /***************************************************************************** * applescript.m: MacOS X AppleScript support ***************************************************************************** - * Copyright (C) 2002-2003 VideoLAN - * $Id: applescript.m,v 1.5 2004/01/05 13:07:03 zorglub Exp $ + * Copyright (C) 2002-2003, 2005, 2007 the VideoLAN team + * $Id$ * * Authors: Derk-Jan Hartman * @@ -10,7 +10,7 @@ * 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 @@ -18,7 +18,7 @@ * * 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -29,9 +29,8 @@ #include "controls.h" #include "open.h" - /***************************************************************************** - * VLGetURLScriptCommand implementation + * VLGetURLScriptCommand implementation *****************************************************************************/ @implementation VLGetURLScriptCommand @@ -41,7 +40,7 @@ if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] ) { - intf_thread_t * p_intf = [NSApp getIntf]; + intf_thread_t * p_intf = VLCIntf; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) @@ -52,18 +51,23 @@ if ( o_urlString ) { NSURL * o_url; - - int i_mode = PLAYLIST_INSERT | PLAYLIST_GO; - - playlist_Add( p_playlist, [o_urlString fileSystemRepresentation], - [o_urlString fileSystemRepresentation], - i_mode, PLAYLIST_END ); + input_item_t *p_input; + + p_input = input_ItemNew( p_playlist, + [o_urlString fileSystemRepresentation], + [[[NSFileManager defaultManager] + displayNameAtPath: o_urlString] UTF8String] ); + /* FIXME: playlist_AddInput() can fail */ + playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT, + PLAYLIST_END, true, false ); + + vlc_gc_decref( p_input ); o_url = [NSURL fileURLWithPath: o_urlString]; if( o_url != nil ) - { + { [[NSDocumentController sharedDocumentController] - noteNewRecentDocumentURL: o_url]; + noteNewRecentDocumentURL: o_url]; } } vlc_object_release( p_playlist ); @@ -75,7 +79,7 @@ /***************************************************************************** - * VLControlScriptCommand implementation + * VLControlScriptCommand implementation *****************************************************************************/ /* * This entire control command needs a better design. more object oriented. @@ -86,16 +90,16 @@ - (id)performDefaultImplementation { NSString *o_command = [[self commandDescription] commandName]; - intf_thread_t * p_intf = [NSApp getIntf]; + intf_thread_t * p_intf = VLCIntf; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return nil; } - + VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls]; - + if ( o_controls ) { if ( [o_command isEqualToString:@"play"] ) @@ -120,8 +124,7 @@ } else if ( [o_command isEqualToString:@"fullscreen"] ) { - NSMenuItem *o_mi = [[NSMenuItem alloc] initWithTitle: _NS("Fullscreen") action: nil keyEquivalent:@""]; - [o_controls windowAction:[o_mi autorelease]]; + [o_controls toogleFullscreen: self]; return nil; } else if ( [o_command isEqualToString:@"mute"] ) @@ -145,3 +148,21 @@ } @end + +/***************************************************************************** + * Category that adds AppleScript support to NSApplication + *****************************************************************************/ +@implementation NSApplication(ScriptSupport) + +- (BOOL) scriptFullscreenMode { + VLCControls * o_controls = (VLCControls *)[[self delegate] getControls]; + + return [o_controls isFullscreen]; +} +- (void) setScriptFullscreenMode: (BOOL) mode { + VLCControls * o_controls = (VLCControls *)[[self delegate] getControls]; + if (mode == [o_controls isFullscreen]) return; + [o_controls toogleFullscreen: self]; +} + +@end