]> git.sesse.net Git - vlc/blob - plugins/macosx/intf_main.c
Interface changes to include menu for Title and chapter navigation.
[vlc] / plugins / macosx / intf_main.c
1 /*****************************************************************************
2  * intf_main.c: MacOS X interface plugin
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  *
6  * Authors:     Colin Delacroix <colin@zoy.org>
7  *              Florian G. Pflug <fgp@phlo.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 #define MODULE_NAME macosx
25 #include "modules_inner.h"
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "defs.h"
31
32 #include <stdlib.h>                                      /* malloc(), free() */
33 #include <sys/param.h>                                    /* for MAXPATHLEN */
34
35 #include "config.h"
36 #include "common.h"
37 #include "threads.h"
38 #include "mtime.h"
39 #include "tests.h"
40
41 #include "interface.h"
42 #include "intf_msg.h"
43
44 #include "modules.h"
45 #include "modules_export.h"
46
47 /* OS specific */
48 #import <Cocoa/Cocoa.h>
49
50
51 /*****************************************************************************
52  * intf_sys_t: description and status of the interface
53  *****************************************************************************/
54 typedef struct intf_sys_s
55 {
56     NSAutoreleasePool *o_pool ;
57 } intf_sys_t;
58
59
60 /*****************************************************************************
61  * Local prototypes.
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 );
67
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 )
73 {
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;
78 }
79
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 )
87 {
88     if( TestMethod( INTF_METHOD_VAR, "macosx" ) )
89     {
90         return( 999 );
91     }
92
93     /* Under MacOS X, this plugin always works */
94     return( 100 );
95 }
96
97 /*****************************************************************************
98  * intf_Open: initialize interface
99  *****************************************************************************/
100 static int intf_Open( intf_thread_t *p_intf )
101 {
102     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
103     if( p_intf->p_sys == NULL )
104     {
105         return( 1 );
106     };
107
108     p_intf->p_sys->o_pool =[[NSAutoreleasePool alloc] init];
109
110     [NSApplication sharedApplication];
111     [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
112
113     return( 0 );
114 }
115
116 /*****************************************************************************
117  * intf_Close: destroy interface
118  *****************************************************************************/
119 static void intf_Close( intf_thread_t *p_intf )
120 {
121     /* Destroy structure */
122     [NSApp terminate:NSApp] ;
123     [p_intf->p_sys->o_pool release] ;
124     free( p_intf->p_sys );
125 }
126
127 /*****************************************************************************
128  * intf_Run: main loop
129  *****************************************************************************/
130 static void intf_Run( intf_thread_t *p_intf )
131 {
132     [NSApp run] ;
133 }