]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/applescript.m
Use pl_Locked and pl_Unlocked.
[vlc] / modules / gui / macosx / applescript.m
index a6d059e25beb98dc388a2e982cabd328f868a260..cfba3bb341d922fd75935874d088d68b5321d9b1 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * applescript.m: MacOS X AppleScript support
  *****************************************************************************
- * Copyright (C) 2002-2003 the VideoLAN team
+ * Copyright (C) 2002-2003, 2005, 2007-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
@@ -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
@@ -29,9 +29,8 @@
 #include "controls.h"
 #include "open.h"
 
-
 /*****************************************************************************
- * VLGetURLScriptCommand implementation 
+ * VLGetURLScriptCommand implementation
  *****************************************************************************/
 @implementation VLGetURLScriptCommand
 
@@ -42,8 +41,7 @@
     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_Yield( p_intf );
         if( p_playlist == NULL )
         {
             return nil;
         if ( o_urlString )
         {
             NSURL * o_url;
-    
-            playlist_Add( p_playlist, [o_urlString fileSystemRepresentation],
-                          [[[NSFileManager defaultManager] displayNameAtPath: o_urlString] UTF8String],
-                          PLAYLIST_INSERT, 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, pl_Unlocked );
+
+            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 );
@@ -73,7 +78,7 @@
 
 
 /*****************************************************************************
- * 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_Yield( p_intf );
     if( p_playlist == NULL )
     {
         return nil;
     }
-    
     VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls];
-    
     if ( o_controls )
     {
         if ( [o_command isEqualToString:@"play"] )
         }
         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"] )
 }
 
 @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