1 /*****************************************************************************
2 * gnome2.c : GNOME 2 plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: gnome2.c,v 1.3 2004/03/03 20:39:52 gbazin Exp $
7 * Authors: Samuel Hocevar <sam@zoy.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 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
37 #include "gnome2_interface.h"
38 #include "gnome2_support.h"
40 /*****************************************************************************
42 *****************************************************************************/
43 static int Open ( vlc_object_t * );
44 static void Close ( vlc_object_t * );
46 static void Run ( intf_thread_t * );
47 static int Manage ( intf_thread_t * );
49 /*****************************************************************************
51 *****************************************************************************/
53 int i = getenv( "DISPLAY" ) == NULL ? 15 : 95;
54 set_description( _("Gtk2 interface") );
55 set_capability( "interface", i );
56 set_callbacks( Open, Close );
57 set_program( "gvlc" );
60 /*****************************************************************************
62 *****************************************************************************/
65 module_t *p_gui_helper;
70 /*****************************************************************************
71 * Open: initialize and create window
72 *****************************************************************************/
73 static int Open( vlc_object_t *p_this )
75 intf_thread_t *p_intf = (intf_thread_t *)p_this;
77 /* Allocate instance and initialize some members */
78 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
79 if( p_intf->p_sys == NULL )
81 msg_Err( p_intf, "out of memory" );
86 p_intf->p_sys->p_gui_helper =
87 module_Need( p_this, "gui-helper", "gnome2", VLC_TRUE );
88 if( p_intf->p_sys->p_gui_helper == NULL )
90 free( p_intf->p_sys );
100 /*****************************************************************************
101 * Close: destroy interface window
102 *****************************************************************************/
103 static void Close( vlc_object_t *p_this )
105 intf_thread_t *p_intf = (intf_thread_t *)p_this;
107 #ifdef NEED_GTK2_MAIN
108 module_Unneed( p_intf, p_intf->p_sys->p_gui_helper );
111 /* Destroy structure */
112 free( p_intf->p_sys );
115 /*****************************************************************************
117 *****************************************************************************
118 * this part of the interface is in a separate thread so that we can call
119 * gtk_main() from within it without annoying the rest of the program.
120 *****************************************************************************/
121 static void Run( intf_thread_t *p_intf )
123 #ifdef NEED_GTK2_MAIN
126 /* gnome_program_init needs to know the command line. We don't care, so
127 * we give it an empty one */
128 char *p_args[] = { "", NULL };
133 gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
135 GNOME_PARAM_APP_DATADIR, "",//PACKAGE_DATA_DIR,
139 /* Create some useful widgets that will certainly be used */
140 p_intf->p_sys->p_app = create_app1();
142 /* Set the title of the main window */
143 //gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_app),
144 // VOUT_TITLE " (Gtk+ interface)" );
146 /* Show the control window */
147 gtk_widget_show( p_intf->p_sys->p_app );
149 #ifdef NEED_GTK2_MAIN
150 while( !p_intf->b_die )
154 /* Sleep to avoid using all CPU - since some interfaces need to
155 * access keyboard events, a 100ms delay is a good compromise */
157 msleep( INTF_IDLE_SLEEP );
161 /* Sleep to avoid using all CPU - since some interfaces needs to access
162 * keyboard events, a 100ms delay is a good compromise */
163 i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,
167 /* Remove the timeout */
168 gtk_timeout_remove( i_dummy );
171 gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_app) );
173 #ifdef NEED_GTK2_MAIN
178 /* following functions are local */
180 /*****************************************************************************
181 * Manage: manage main thread messages
182 *****************************************************************************
183 * In this function, called approx. 10 times a second, we check what the
184 * main program wanted to tell us.
185 *****************************************************************************/
186 static int Manage( intf_thread_t *p_intf )
188 #ifndef NEED_GTK2_MAIN