]> git.sesse.net Git - vlc/blob - modules/gui/beos/Interface.cpp
cbaebcc4f98427939367251d53bf9c12ce26ae23
[vlc] / modules / gui / beos / Interface.cpp
1 /*****************************************************************************
2  * intf_beos.cpp: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8  *          Samuel Hocevar <sam@zoy.org>
9  *          Tony Castley <tony@castley.net>
10  *          Richard Shepherd <richard@rshepherd.demon.co.uk>
11  *          Stephan Aßmus <stippi@yellowbites.com>
12  *          Eric Petit <titer@videolan.org>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27  *****************************************************************************/
28
29 /*****************************************************************************
30  * Preamble
31  *****************************************************************************/
32 #include <InterfaceKit.h>
33 #include <Application.h>
34 #include <Message.h>
35
36 #include <vlc/vlc.h>
37 #include <vlc_interface.h>
38 #include <vlc_aout.h>
39 #include <aout_internal.h>
40
41 #include "InterfaceWindow.h"
42 #include "MsgVals.h"
43
44 /*****************************************************************************
45  * intf_sys_t: internal variables of the BeOS interface
46  *****************************************************************************/
47 struct intf_sys_t
48 {
49     InterfaceWindow * p_window;
50 };
51
52 /*****************************************************************************
53  * Local prototype
54  *****************************************************************************/
55 static void Run       ( intf_thread_t *p_intf );
56
57 /*****************************************************************************
58  * intf_Open: initialize interface
59  *****************************************************************************/
60 int E_(OpenIntf) ( vlc_object_t *p_this )
61 {
62     intf_thread_t * p_intf = (intf_thread_t*) p_this;
63
64     /* Allocate instance and initialize some members */
65     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
66     if( !p_intf->p_sys )
67     {
68         msg_Err( p_intf, "out of memory" );
69         return VLC_EGENERIC;
70     }
71     
72     p_intf->pf_run = Run;
73
74     /* Create the interface window */
75     BScreen screen( B_MAIN_SCREEN_ID );
76     BRect rect   = screen.Frame();
77     rect.top     = rect.bottom - 100;
78     rect.bottom -= 50;
79     rect.left   += 50;
80     rect.right   = rect.left + 350;
81     p_intf->p_sys->p_window =
82         new InterfaceWindow( p_intf, rect, "VLC " VERSION );
83     if( !p_intf->p_sys->p_window )
84     {
85         free( p_intf->p_sys );
86         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
87         return VLC_EGENERIC;
88     }
89
90     /* Make the be_app aware the interface has been created */
91     BMessage message( INTERFACE_CREATED );
92     message.AddPointer( "window", p_intf->p_sys->p_window );
93     be_app->PostMessage( &message );
94
95     return VLC_SUCCESS;
96 }
97
98 /*****************************************************************************
99  * intf_Close: destroy dummy interface
100  *****************************************************************************/
101 void E_(CloseIntf) ( vlc_object_t *p_this )
102 {
103     intf_thread_t *p_intf = (intf_thread_t*) p_this;
104
105     /* Destroy the interface window */
106     if( p_intf->p_sys->p_window->Lock() )
107         p_intf->p_sys->p_window->Quit();
108
109     /* Destroy structure */
110     free( p_intf->p_sys );
111 }
112
113
114 /*****************************************************************************
115  * intf_Run: event loop
116  *****************************************************************************/
117 static void Run( intf_thread_t *p_intf )
118 {
119     while( !intf_ShouldDie( p_intf ) )
120     {
121         p_intf->p_sys->p_window->UpdateInterface();
122         msleep( INTF_IDLE_SLEEP );
123     }
124 }