1 /*****************************************************************************
2 * gtk_control.c : functions to handle stream control buttons.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gtk_preferences.c,v 1.2 2001/05/15 14:49:48 stef Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Stéphane Borel <stef@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #define MODULE_NAME gtk
26 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
32 #include <sys/types.h> /* off_t */
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
47 #include "interface.h"
48 #include "intf_playlist.h"
51 #include "gtk_callbacks.h"
52 #include "gtk_interface.h"
53 #include "gtk_support.h"
54 #include "gtk_playlist.h"
59 /****************************************************************************
60 * GtkPreferencesShow: display interface window after initialization
62 ****************************************************************************/
64 /* macros to create preference box */
65 #define ASSIGN_PSZ_ENTRY( var, default, name ) \
66 gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data( GTK_OBJECT( \
67 p_intf->p_sys->p_preferences ), name ) ), \
68 main_GetPszVariable( var, default ) )
70 #define ASSIGN_INT_VALUE( var, default, name ) \
71 gtk_spin_button_set_value( GTK_SPIN_BUTTON( gtk_object_get_data( \
72 GTK_OBJECT( p_intf->p_sys->p_preferences ), name ) ), \
73 main_GetIntVariable( var, default ) )
75 #define ASSIGN_INT_TOGGLE( var, default, name ) \
76 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( gtk_object_get_data( \
77 GTK_OBJECT( p_intf->p_sys->p_preferences ), name ) ), \
78 main_GetIntVariable( var, default ) )
80 gboolean GtkPreferencesShow( GtkWidget *widget,
81 GdkEventButton *event,
84 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
86 /* If we have never used the file selector, open it */
87 if( !GTK_IS_WIDGET( p_intf->p_sys->p_preferences ) )
89 p_intf->p_sys->p_preferences = create_intf_preferences();
90 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_preferences ),
94 ASSIGN_PSZ_ENTRY( INTF_PATH_VAR, INTF_PATH_DEFAULT,
95 "preferences_file_path_entry" );
98 ASSIGN_PSZ_ENTRY( INPUT_DVD_DEVICE_VAR,INPUT_DVD_DEVICE_DEFAULT,
99 "preferences_disc_dvd_entry" );
102 ASSIGN_PSZ_ENTRY( INPUT_VCD_DEVICE_VAR, INPUT_VCD_DEVICE_DEFAULT,
103 "preferences_disc_vcd_entry" );
106 ASSIGN_PSZ_ENTRY( INPUT_SERVER_VAR, INPUT_SERVER_DEFAULT,
107 "preferences_network_server_entry" );
110 ASSIGN_INT_VALUE( INPUT_PORT_VAR, INPUT_PORT_DEFAULT,
111 "preferences_network_port_spinbutton" );
113 /* Broadcast address */
114 ASSIGN_PSZ_ENTRY( INPUT_BCAST_ADRR_VAR, INPUT_BCAST_ADDR_DEFAULT,
115 "preferences_network_broadcast_entry" );
117 /* Broadcast stream by default ? */
118 ASSIGN_INT_TOGGLE( INPUT_BROADCAST_VAR, INPUT_BROADCAST_DEFAULT,
119 "preferences_network_broadcast_checkbutton" );
123 /* Default interface */
124 ASSIGN_PSZ_ENTRY( INTF_METHOD_VAR, INTF_METHOD_DEFAULT,
125 "preferences_interface_entry" );
127 /* Default video output */
128 ASSIGN_PSZ_ENTRY( VOUT_METHOD_VAR, VOUT_METHOD_DEFAULT,
129 "preferences_video_output_entry" );
131 /* Default output width */
132 ASSIGN_INT_VALUE( VOUT_WIDTH_VAR, VOUT_WIDTH_DEFAULT,
133 "preferences_video_width_spinbutton" );
135 /* Default output height */
136 ASSIGN_INT_VALUE( VOUT_HEIGHT_VAR, VOUT_HEIGHT_DEFAULT,
137 "preferences_video_height_spinbutton" );
139 /* XXX Default screen depth */
141 /* XXX Default fullscreen depth */
143 /* XXX Default gamma */
145 /* Fullscreen on play */
146 ASSIGN_INT_TOGGLE( VOUT_FULLSCREEN_VAR, VOUT_FULLSCREEN_DEFAULT,
147 "preferences_video_fullscreen_checkbutton" );
149 /* Grayscale display */
150 ASSIGN_INT_TOGGLE( VOUT_GRAYSCALE_VAR, VOUT_GRAYSCALE_DEFAULT,
151 "preferences_video_grayscale_checkbutton" );
153 /* Default audio output */
154 ASSIGN_PSZ_ENTRY( AOUT_METHOD_VAR, AOUT_METHOD_DEFAULT,
155 "preferences_audio_output_entry" );
157 /* Default audio device */
158 ASSIGN_PSZ_ENTRY( AOUT_DSP_VAR, AOUT_DSP_DEFAULT,
159 "preferences_audio_device_entry" );
161 /* XXX Default frequency */
163 /* XXX Default quality */
165 /* XXX Default number of channels */
167 /* Use spdif output ? */
168 ASSIGN_INT_TOGGLE( AOUT_SPDIF_VAR, AOUT_SPDIF_DEFAULT,
169 "preferences_audio_spdif_checkbutton" );
171 /* Launch playlist on startup */
172 ASSIGN_INT_TOGGLE( PLAYLIST_STARTUP_VAR, PLAYLIST_STARTUP_DEFAULT,
173 "preferences_playlist_startup_checkbutton" );
175 /* Enqueue drag'n dropped item as default */
176 ASSIGN_INT_TOGGLE( PLAYLIST_ENQUEUE_VAR, PLAYLIST_ENQUEUE_DEFAULT,
177 "preferences_playlist_enqueue_checkbutton" );
179 /* Loop on playlist end */
180 ASSIGN_INT_TOGGLE( PLAYLIST_LOOP_VAR, PLAYLIST_LOOP_DEFAULT,
181 "preferences_playlist_loop_checkbutton" );
183 /* Verbosity of warning messages */
184 ASSIGN_INT_VALUE( INTF_WARNING_VAR, INTF_WARNING_DEFAULT,
185 "preferences_misc_messages_spinbutton" );
186 #undef ASSIGN_PSZ_ENTRY
187 #undef ASSIGN_INT_VALUE
188 #undef ASSIGN_INT_TOGGLE
191 gtk_widget_show( p_intf->p_sys->p_preferences );
192 gdk_window_raise( p_intf->p_sys->p_preferences->window );
197 /****************************************************************************
198 * GtkPreferencesApply: store the values into the environnement variables
199 ****************************************************************************/
201 /* macros to read value frfom preference box */
202 #define ASSIGN_PSZ_ENTRY( var, name ) \
203 main_PutPszVariable( var, gtk_entry_get_text( \
204 GTK_ENTRY( gtk_object_get_data( GTK_OBJECT( p_preferences ), name ) ) ) )
206 #define ASSIGN_INT_VALUE( var, name ) \
207 main_PutIntVariable( var, gtk_spin_button_get_value_as_int( \
208 GTK_SPIN_BUTTON( gtk_object_get_data( GTK_OBJECT( p_preferences ), \
211 #define ASSIGN_INT_TOGGLE( var, name ) \
212 main_PutIntVariable( var, gtk_toggle_button_get_active( \
213 GTK_TOGGLE_BUTTON( gtk_object_get_data( GTK_OBJECT( p_preferences ), \
216 void GtkPreferencesApply( GtkButton * button, gpointer user_data )
218 GtkWidget * p_preferences;
220 /* get preferences window */
221 p_preferences = gtk_widget_get_toplevel( GTK_WIDGET( button ) );
224 ASSIGN_PSZ_ENTRY( INTF_PATH_VAR, "preferences_file_path_entry" );
227 ASSIGN_PSZ_ENTRY( INPUT_DVD_DEVICE_VAR, "preferences_disc_dvd_entry" );
230 ASSIGN_PSZ_ENTRY( INPUT_VCD_DEVICE_VAR, "preferences_disc_vcd_entry" );
233 ASSIGN_PSZ_ENTRY( INPUT_SERVER_VAR, "preferences_network_server_entry" );
236 ASSIGN_INT_VALUE( INPUT_PORT_VAR, "preferences_network_port_spinbutton" );
238 /* Broadcast address */
239 ASSIGN_PSZ_ENTRY( INPUT_BCAST_ADRR_VAR,
240 "preferences_network_broadcast_entry" );
242 /* Broadcast stream by default ? */
243 ASSIGN_INT_TOGGLE( INPUT_BROADCAST_VAR,
244 "preferences_network_broadcast_checkbutton" );
248 /* Default interface */
249 ASSIGN_PSZ_ENTRY( INTF_METHOD_VAR, "preferences_interface_entry" );
251 /* Default video output */
252 ASSIGN_PSZ_ENTRY( VOUT_METHOD_VAR, "preferences_video_output_entry" );
254 /* Default output width */
255 ASSIGN_INT_VALUE( VOUT_WIDTH_VAR, "preferences_video_width_spinbutton" );
257 /* Default output height */
258 ASSIGN_INT_VALUE( VOUT_HEIGHT_VAR, "preferences_video_height_spinbutton" );
260 /* XXX Default screen depth */
262 /* XXX Default fullscreen depth */
264 /* XXX Default gamma */
266 /* Fullscreen on play */
267 ASSIGN_INT_TOGGLE( VOUT_FULLSCREEN_VAR,
268 "preferences_video_fullscreen_checkbutton" );
270 /* Grayscale display */
271 ASSIGN_INT_TOGGLE( VOUT_GRAYSCALE_VAR,
272 "preferences_video_grayscale_checkbutton" );
274 /* Default audio output */
275 ASSIGN_PSZ_ENTRY( AOUT_METHOD_VAR, "preferences_audio_output_entry" );
277 /* Default audio device */
278 ASSIGN_PSZ_ENTRY( AOUT_DSP_VAR, "preferences_audio_device_entry" );
280 /* XXX Default frequency */
282 /* XXX Default quality */
284 /* XXX Default number of channels */
286 /* Use spdif output ? */
287 ASSIGN_INT_TOGGLE( AOUT_SPDIF_VAR, "preferences_audio_spdif_checkbutton" );
289 /* Launch playlist on startup */
290 ASSIGN_INT_TOGGLE( PLAYLIST_STARTUP_VAR,
291 "preferences_playlist_startup_checkbutton" );
293 /* Enqueue drag'n dropped item as default */
294 ASSIGN_INT_TOGGLE( PLAYLIST_ENQUEUE_VAR,
295 "preferences_playlist_enqueue_checkbutton" );
297 /* Loop on playlist end */
298 ASSIGN_INT_TOGGLE( PLAYLIST_LOOP_VAR,
299 "preferences_playlist_loop_checkbutton" );
301 /* Verbosity of warning messages */
302 ASSIGN_INT_VALUE( INTF_WARNING_VAR,
303 "preferences_misc_messages_spinbutton" );
305 #undef ASSIGN_PSZ_ENTRY
306 #undef ASSIGN_INT_VALUE
307 #undef ASSIGN_INT_TOGGLE
310 void GtkPreferencesOk( GtkButton * button, gpointer user_data )
312 GtkPreferencesApply( button, user_data );
313 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
317 void GtkPreferencesCancel( GtkButton * button, gpointer user_data )
319 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
322 /****************************************************************************
323 * Callbacks for menuitems
324 ****************************************************************************/
325 void GtkPreferencesActivate( GtkMenuItem * menuitem, gpointer user_data )
327 GtkPreferencesShow( GTK_WIDGET( menuitem ), NULL, user_data );