1 /*****************************************************************************
2 * intf_main.c: MacOS X interface plugin
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
6 * Authors: Colin Delacroix <colin@zoy.org>
7 * Florian G. Pflug <fgp@phlo.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 #define MODULE_NAME macosx
25 #include "modules_inner.h"
27 /*****************************************************************************
29 *****************************************************************************/
32 #include <stdlib.h> /* malloc(), free() */
33 #include <sys/param.h> /* for MAXPATHLEN */
41 #include "interface.h"
45 #include "modules_export.h"
48 #import <Cocoa/Cocoa.h>
51 /*****************************************************************************
52 * intf_sys_t: description and status of the interface
53 *****************************************************************************/
54 typedef struct intf_sys_s
56 NSAutoreleasePool *o_pool ;
60 /*****************************************************************************
62 *****************************************************************************/
63 static int intf_Probe ( probedata_t *p_data );
64 static int intf_Open ( intf_thread_t *p_intf );
65 static void intf_Close ( intf_thread_t *p_intf );
66 static void intf_Run ( intf_thread_t *p_intf );
68 /*****************************************************************************
69 * Functions exported as capabilities. They are declared as static so that
70 * we don't pollute the namespace too much.
71 *****************************************************************************/
72 void _M( intf_getfunctions )( function_list_t * p_function_list )
74 p_function_list->pf_probe = intf_Probe;
75 p_function_list->functions.intf.pf_open = intf_Open;
76 p_function_list->functions.intf.pf_close = intf_Close;
77 p_function_list->functions.intf.pf_run = intf_Run;
80 /*****************************************************************************
81 * intf_Probe: probe the interface and return a score
82 *****************************************************************************
83 * This function checks the interface can be run and returns a score to the
84 * plugin manager so that it can select the best plugin.
85 *****************************************************************************/
86 static int intf_Probe( probedata_t *p_data )
88 if( TestMethod( INTF_METHOD_VAR, "macosx" ) )
93 /* Under MacOS X, this plugin always works */
97 /*****************************************************************************
98 * intf_Open: initialize interface
99 *****************************************************************************/
100 static int intf_Open( intf_thread_t *p_intf )
102 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
103 if( p_intf->p_sys == NULL )
108 p_intf->p_sys->o_pool =[[NSAutoreleasePool alloc] init];
110 [NSApplication sharedApplication];
111 [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
116 /*****************************************************************************
117 * intf_Close: destroy interface
118 *****************************************************************************/
119 static void intf_Close( intf_thread_t *p_intf )
121 /* Destroy structure */
122 [NSApp terminate:NSApp] ;
123 [p_intf->p_sys->o_pool release] ;
124 free( p_intf->p_sys );
127 /*****************************************************************************
128 * intf_Run: main loop
129 *****************************************************************************/
130 static void intf_Run( intf_thread_t *p_intf )