]> git.sesse.net Git - vlc/blob - plugins/macosx/intf_macosx.m
* ./plugins/macosx/vout_macosx.m, ./plugins/macosx/aout_macosx.m,
[vlc] / plugins / macosx / intf_macosx.m
1 /*****************************************************************************
2  * intf_macosx.c: MacOS X interface plugin
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: intf_macosx.m,v 1.4 2002/06/02 12:16:31 massiot Exp $
6  *
7  * Authors: Colin Delacroix <colin@zoy.org>
8  *          Florian G. Pflug <fgp@phlo.org>
9  *          Jon Lech Johansen <jon-vl@nanocrew.net>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include <stdlib.h>                                      /* malloc(), free() */
30 #include <sys/param.h>                                    /* for MAXPATHLEN */
31 #include <string.h>
32
33 #include <vlc/vlc.h>
34 #include <vlc/intf.h>
35
36 #include "macosx.h"
37
38 /*****************************************************************************
39  * Local prototypes.
40  *****************************************************************************/
41 static int  intf_Open      ( intf_thread_t *p_intf );
42 static void intf_Close     ( intf_thread_t *p_intf );
43 static void intf_Run       ( intf_thread_t *p_intf );
44
45 /*****************************************************************************
46  * Functions exported as capabilities. They are declared as static so that
47  * we don't pollute the namespace too much.
48  *****************************************************************************/
49 void _M( intf_getfunctions )( function_list_t * p_function_list )
50 {
51     p_function_list->functions.intf.pf_open  = intf_Open;
52     p_function_list->functions.intf.pf_close = intf_Close;
53     p_function_list->functions.intf.pf_run   = intf_Run;
54 }
55
56 /*****************************************************************************
57  * intf_Open: initialize interface
58  *****************************************************************************/
59 static int intf_Open( intf_thread_t *p_intf )
60 {
61     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
62     if( p_intf->p_sys == NULL )
63     {
64         return( 1 );
65     }
66
67     p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
68     p_intf->p_sys->o_port = [[NSPort port] retain];
69     p_intf->p_sys->b_mute = 0;
70     p_intf->p_sys->i_part = 0;
71     p_intf->p_sys->b_disabled_menus = 0; 
72     p_intf->p_sys->b_loop = 0; 
73     p_intf->p_sys->>i_channel = 0; 
74
75     [[NSApplication sharedApplication] autorelease];
76     [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
77
78     return( 0 );
79 }
80
81 /*****************************************************************************
82  * intf_Close: destroy interface
83  *****************************************************************************/
84 static void intf_Close( intf_thread_t *p_intf )
85 {
86     /* write cached user defaults to disk */
87     [[NSUserDefaults standardUserDefaults] synchronize];
88
89     [p_intf->p_sys->o_port release];
90     [p_intf->p_sys->o_pool release];
91
92     free( p_intf->p_sys );
93 }
94
95 /*****************************************************************************
96  * intf_Run: main loop
97  *****************************************************************************/
98 static void intf_Run( intf_thread_t *p_intf )
99 {
100     [NSApp run];
101 }