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.5 2001/05/30 17:03:12 sam 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 /*****************************************************************************
27 *****************************************************************************/
29 #include <sys/types.h> /* off_t */
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
44 #include "interface.h"
45 #include "intf_playlist.h"
48 #include "gtk_callbacks.h"
49 #include "gtk_interface.h"
50 #include "gtk_support.h"
51 #include "gtk_playlist.h"
56 #include "modules_export.h"
58 /****************************************************************************
59 * GtkPreferencesShow: display interface window after initialization
61 ****************************************************************************/
63 /* macros to create preference box */
64 #define ASSIGN_PSZ_ENTRY( var, default, name ) \
65 gtk_entry_set_text( GTK_ENTRY( gtk_object_get_data( GTK_OBJECT( \
66 p_intf->p_sys->p_preferences ), name ) ), \
67 main_GetPszVariable( var, default ) )
69 #define ASSIGN_INT_VALUE( var, default, name ) \
70 gtk_spin_button_set_value( GTK_SPIN_BUTTON( gtk_object_get_data( \
71 GTK_OBJECT( p_intf->p_sys->p_preferences ), name ) ), \
72 main_GetIntVariable( var, default ) )
74 #define ASSIGN_INT_TOGGLE( var, default, name ) \
75 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( gtk_object_get_data( \
76 GTK_OBJECT( p_intf->p_sys->p_preferences ), name ) ), \
77 main_GetIntVariable( var, default ) )
79 gboolean GtkPreferencesShow( GtkWidget *widget,
80 GdkEventButton *event,
83 intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
85 /* If we have never used the file selector, open it */
86 if( !GTK_IS_WIDGET( p_intf->p_sys->p_preferences ) )
88 p_intf->p_sys->p_preferences = create_intf_preferences();
89 gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_preferences ),
93 ASSIGN_PSZ_ENTRY( INTF_PATH_VAR, INTF_PATH_DEFAULT,
94 "preferences_file_path_entry" );
97 ASSIGN_PSZ_ENTRY( INPUT_DVD_DEVICE_VAR,INPUT_DVD_DEVICE_DEFAULT,
98 "preferences_disc_dvd_entry" );
101 ASSIGN_PSZ_ENTRY( INPUT_VCD_DEVICE_VAR, INPUT_VCD_DEVICE_DEFAULT,
102 "preferences_disc_vcd_entry" );
105 ASSIGN_PSZ_ENTRY( INPUT_SERVER_VAR, INPUT_SERVER_DEFAULT,
106 "preferences_network_server_entry" );
109 ASSIGN_INT_VALUE( INPUT_PORT_VAR, INPUT_PORT_DEFAULT,
110 "preferences_network_port_spinbutton" );
112 /* Broadcast address */
113 ASSIGN_PSZ_ENTRY( INPUT_BCAST_ADDR_VAR, INPUT_BCAST_ADDR_DEFAULT,
114 "preferences_network_broadcast_entry" );
116 /* Broadcast stream by default ? */
117 ASSIGN_INT_TOGGLE( INPUT_BROADCAST_VAR, INPUT_BROADCAST_DEFAULT,
118 "preferences_network_broadcast_checkbutton" );
122 /* Default interface */
123 ASSIGN_PSZ_ENTRY( INTF_METHOD_VAR, INTF_METHOD_DEFAULT,
124 "preferences_interface_entry" );
126 /* Default video output */
127 ASSIGN_PSZ_ENTRY( VOUT_METHOD_VAR, VOUT_METHOD_DEFAULT,
128 "preferences_video_output_entry" );
130 /* Default output width */
131 ASSIGN_INT_VALUE( VOUT_WIDTH_VAR, VOUT_WIDTH_DEFAULT,
132 "preferences_video_width_spinbutton" );
134 /* Default output height */
135 ASSIGN_INT_VALUE( VOUT_HEIGHT_VAR, VOUT_HEIGHT_DEFAULT,
136 "preferences_video_height_spinbutton" );
138 /* XXX Default screen depth */
140 /* XXX Default fullscreen depth */
142 /* XXX Default gamma */
144 /* Fullscreen on play */
145 ASSIGN_INT_TOGGLE( VOUT_FULLSCREEN_VAR, VOUT_FULLSCREEN_DEFAULT,
146 "preferences_video_fullscreen_checkbutton" );
148 /* Grayscale display */
149 ASSIGN_INT_TOGGLE( VOUT_GRAYSCALE_VAR, VOUT_GRAYSCALE_DEFAULT,
150 "preferences_video_grayscale_checkbutton" );
152 /* Default audio output */
153 ASSIGN_PSZ_ENTRY( AOUT_METHOD_VAR, AOUT_METHOD_DEFAULT,
154 "preferences_audio_output_entry" );
156 /* Default audio device */
157 ASSIGN_PSZ_ENTRY( AOUT_DSP_VAR, AOUT_DSP_DEFAULT,
158 "preferences_audio_device_entry" );
160 /* XXX Default frequency */
162 /* XXX Default quality */
164 /* XXX Default number of channels */
166 /* Use spdif output ? */
167 ASSIGN_INT_TOGGLE( AOUT_SPDIF_VAR, AOUT_SPDIF_DEFAULT,
168 "preferences_audio_spdif_checkbutton" );
170 /* Launch playlist on startup */
171 ASSIGN_INT_TOGGLE( PLAYLIST_STARTUP_VAR, PLAYLIST_STARTUP_DEFAULT,
172 "preferences_playlist_startup_checkbutton" );
174 /* Enqueue drag'n dropped item as default */
175 ASSIGN_INT_TOGGLE( PLAYLIST_ENQUEUE_VAR, PLAYLIST_ENQUEUE_DEFAULT,
176 "preferences_playlist_enqueue_checkbutton" );
178 /* Loop on playlist end */
179 ASSIGN_INT_TOGGLE( PLAYLIST_LOOP_VAR, PLAYLIST_LOOP_DEFAULT,
180 "preferences_playlist_loop_checkbutton" );
182 /* Verbosity of warning messages */
183 ASSIGN_INT_VALUE( INTF_WARNING_VAR, INTF_WARNING_DEFAULT,
184 "preferences_misc_messages_spinbutton" );
185 #undef ASSIGN_PSZ_ENTRY
186 #undef ASSIGN_INT_VALUE
187 #undef ASSIGN_INT_TOGGLE
190 gtk_widget_show( p_intf->p_sys->p_preferences );
191 gdk_window_raise( p_intf->p_sys->p_preferences->window );
196 /****************************************************************************
197 * GtkPreferencesApply: store the values into the environnement variables
198 ****************************************************************************/
200 /* macros to read value frfom preference box */
201 #define ASSIGN_PSZ_ENTRY( var, name ) \
202 main_PutPszVariable( var, gtk_entry_get_text( \
203 GTK_ENTRY( gtk_object_get_data( GTK_OBJECT( p_preferences ), name ) ) ) )
205 #define ASSIGN_INT_VALUE( var, name ) \
206 main_PutIntVariable( var, gtk_spin_button_get_value_as_int( \
207 GTK_SPIN_BUTTON( gtk_object_get_data( GTK_OBJECT( p_preferences ), \
210 #define ASSIGN_INT_TOGGLE( var, name ) \
211 main_PutIntVariable( var, gtk_toggle_button_get_active( \
212 GTK_TOGGLE_BUTTON( gtk_object_get_data( GTK_OBJECT( p_preferences ), \
215 void GtkPreferencesApply( GtkButton * button, gpointer user_data )
217 GtkWidget * p_preferences;
219 /* get preferences window */
220 p_preferences = gtk_widget_get_toplevel( GTK_WIDGET( button ) );
223 ASSIGN_PSZ_ENTRY( INTF_PATH_VAR, "preferences_file_path_entry" );
226 ASSIGN_PSZ_ENTRY( INPUT_DVD_DEVICE_VAR, "preferences_disc_dvd_entry" );
229 ASSIGN_PSZ_ENTRY( INPUT_VCD_DEVICE_VAR, "preferences_disc_vcd_entry" );
232 ASSIGN_PSZ_ENTRY( INPUT_SERVER_VAR, "preferences_network_server_entry" );
235 ASSIGN_INT_VALUE( INPUT_PORT_VAR, "preferences_network_port_spinbutton" );
237 /* Broadcast address */
238 ASSIGN_PSZ_ENTRY( INPUT_BCAST_ADDR_VAR,
239 "preferences_network_broadcast_entry" );
241 /* Broadcast stream by default ? */
242 ASSIGN_INT_TOGGLE( INPUT_BROADCAST_VAR,
243 "preferences_network_broadcast_checkbutton" );
247 /* Default interface */
248 ASSIGN_PSZ_ENTRY( INTF_METHOD_VAR, "preferences_interface_entry" );
250 /* Default video output */
251 ASSIGN_PSZ_ENTRY( VOUT_METHOD_VAR, "preferences_video_output_entry" );
253 /* Default output width */
254 ASSIGN_INT_VALUE( VOUT_WIDTH_VAR, "preferences_video_width_spinbutton" );
256 /* Default output height */
257 ASSIGN_INT_VALUE( VOUT_HEIGHT_VAR, "preferences_video_height_spinbutton" );
259 /* XXX Default screen depth */
261 /* XXX Default fullscreen depth */
263 /* XXX Default gamma */
265 /* Fullscreen on play */
266 ASSIGN_INT_TOGGLE( VOUT_FULLSCREEN_VAR,
267 "preferences_video_fullscreen_checkbutton" );
269 /* Grayscale display */
270 ASSIGN_INT_TOGGLE( VOUT_GRAYSCALE_VAR,
271 "preferences_video_grayscale_checkbutton" );
273 /* Default audio output */
274 ASSIGN_PSZ_ENTRY( AOUT_METHOD_VAR, "preferences_audio_output_entry" );
276 /* Default audio device */
277 ASSIGN_PSZ_ENTRY( AOUT_DSP_VAR, "preferences_audio_device_entry" );
279 /* XXX Default frequency */
281 /* XXX Default quality */
283 /* XXX Default number of channels */
285 /* Use spdif output ? */
286 ASSIGN_INT_TOGGLE( AOUT_SPDIF_VAR, "preferences_audio_spdif_checkbutton" );
288 /* Launch playlist on startup */
289 ASSIGN_INT_TOGGLE( PLAYLIST_STARTUP_VAR,
290 "preferences_playlist_startup_checkbutton" );
292 /* Enqueue drag'n dropped item as default */
293 ASSIGN_INT_TOGGLE( PLAYLIST_ENQUEUE_VAR,
294 "preferences_playlist_enqueue_checkbutton" );
296 /* Loop on playlist end */
297 ASSIGN_INT_TOGGLE( PLAYLIST_LOOP_VAR,
298 "preferences_playlist_loop_checkbutton" );
300 /* Verbosity of warning messages */
301 ASSIGN_INT_VALUE( INTF_WARNING_VAR,
302 "preferences_misc_messages_spinbutton" );
304 #undef ASSIGN_PSZ_ENTRY
305 #undef ASSIGN_INT_VALUE
306 #undef ASSIGN_INT_TOGGLE
309 void GtkPreferencesOk( GtkButton * button, gpointer user_data )
311 GtkPreferencesApply( button, user_data );
312 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
316 void GtkPreferencesCancel( GtkButton * button, gpointer user_data )
318 gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
321 /****************************************************************************
322 * Callbacks for menuitems
323 ****************************************************************************/
324 void GtkPreferencesActivate( GtkMenuItem * menuitem, gpointer user_data )
326 GtkPreferencesShow( GTK_WIDGET( menuitem ), NULL, user_data );