1 /*****************************************************************************
2 * display.c: Gtk+ tools for main interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2003 VideoLAN
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 *****************************************************************************/
28 #include <errno.h> /* ENOMEM */
29 #include <stdlib.h> /* free() */
30 #include <string.h> /* strerror() */
36 #ifdef MODULE_NAME_IS_gnome
42 #include "gtk_callbacks.h"
43 #include "gtk_interface.h"
44 #include "gtk_support.h"
50 /*****************************************************************************
51 * GtkDisplayDate: display stream date
52 *****************************************************************************
53 * This function displays the current date related to the position in
54 * the stream. It is called whenever the slider changes its value.
55 * The lock has to be taken before you call the function.
56 *****************************************************************************/
57 void E_(GtkDisplayDate)( GtkAdjustment *p_adj )
59 intf_thread_t *p_intf;
61 p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
63 if( p_intf->p_sys->p_input )
65 char psz_time[ MSTRTIME_MAX_SIZE ];
68 i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / I64C(1000000 );
69 secstotimestr( psz_time, i_seconds );
71 gtk_frame_set_label( GTK_FRAME( p_intf->p_sys->p_slider_frame ),
77 /*****************************************************************************
78 * GtkModeManage: actualize the aspect of the interface whenever the input
80 *****************************************************************************
81 * The lock has to be taken before you call the function.
82 *****************************************************************************/
83 gint E_(GtkModeManage)( intf_thread_t * p_intf )
85 GtkWidget * p_dvd_box;
86 GtkWidget * p_file_box;
87 GtkWidget * p_network_box;
92 #define GETWIDGET( ptr, name ) GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( \
93 p_intf->p_sys->ptr ) , ( name ) ) )
94 /* hide all boxes except default file box */
95 p_file_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
96 p_intf->p_sys->p_window ), "file_box" ) );
97 gtk_widget_hide( GTK_WIDGET( p_file_box ) );
99 p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
100 p_intf->p_sys->p_window ), "network_box" ) );
101 gtk_widget_hide( GTK_WIDGET( p_network_box ) );
103 p_dvd_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
104 p_intf->p_sys->p_window ), "dvd_box" ) );
105 gtk_widget_hide( GTK_WIDGET( p_dvd_box ) );
108 p_slider = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
109 p_intf->p_sys->p_window ), "slider_frame" ) );
110 gtk_widget_hide( GTK_WIDGET( p_slider ) );
112 /* controls unavailable */
115 /* show the box related to current input mode */
116 if( p_intf->p_sys->p_input )
118 switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 )
120 case INPUT_METHOD_FILE:
121 gtk_widget_show( GTK_WIDGET( p_file_box ) );
122 p_label = gtk_object_get_data( GTK_OBJECT(
123 p_intf->p_sys->p_window ),
125 gtk_label_set_text( GTK_LABEL( p_label ),
126 p_intf->p_sys->p_input->psz_source );
128 case INPUT_METHOD_DISC:
129 gtk_widget_show( GTK_WIDGET( p_dvd_box ) );
131 case INPUT_METHOD_NETWORK:
132 gtk_widget_show( GTK_WIDGET( p_network_box ) );
133 p_label = gtk_object_get_data( GTK_OBJECT(
134 p_intf->p_sys->p_window ),
135 "network_address_label" );
136 gtk_label_set_text( GTK_LABEL( p_label ),
137 p_intf->p_sys->p_input->psz_source );
140 msg_Warn( p_intf, "cannot determine input method" );
141 gtk_widget_show( GTK_WIDGET( p_file_box ) );
142 p_label = gtk_object_get_data( GTK_OBJECT(
143 p_intf->p_sys->p_window ),
145 gtk_label_set_text( GTK_LABEL( p_label ),
146 p_intf->p_sys->p_input->psz_source );
150 /* initialize and show slider for seekable streams */
151 if( p_intf->p_sys->p_input->stream.b_seekable )
153 p_intf->p_sys->p_adj->value = p_intf->p_sys->f_adj_oldvalue = 0;
154 gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
156 gtk_widget_show( GTK_WIDGET( p_slider ) );
159 /* control buttons for free pace streams */
160 b_control = p_intf->p_sys->p_input->stream.b_pace_control;
162 /* get ready for menu regeneration */
163 p_intf->p_sys->b_program_update = 1;
164 p_intf->p_sys->b_title_update = 1;
165 p_intf->p_sys->b_chapter_update = 1;
166 p_intf->p_sys->b_audio_update = 1;
167 p_intf->p_sys->b_spu_update = 1;
168 p_intf->p_sys->i_part = 0;
170 p_intf->p_sys->b_aout_update = 1;
171 p_intf->p_sys->b_vout_update = 1;
173 p_intf->p_sys->p_input->stream.b_changed = 0;
174 msg_Dbg( p_intf, "stream has changed, refreshing interface" );
179 p_label = gtk_object_get_data(
180 GTK_OBJECT( p_intf->p_sys->p_window ), "label_status" );
181 gtk_label_set_text( GTK_LABEL( p_label ), "" );
182 gtk_widget_show( GTK_WIDGET( p_file_box ) );
184 /* unsensitize menus */
185 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_program"),
187 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_title"), FALSE );
188 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_chapter"),
190 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_audio"), FALSE );
191 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_subpictures"),
193 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_navigation"),
195 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_language"), FALSE );
196 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_subpictures"),
200 /* set control items */
201 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_back"), FALSE );
202 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_eject"), !b_control);
203 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_pause"), b_control );
204 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_slow"), b_control );
205 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_fast"), b_control );
206 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_back"), FALSE );
207 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_pause"), b_control );
208 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_slow"), b_control );
209 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_fast"), b_control );
215 /*****************************************************************************
216 * GtkHideTooltips: show or hide the tooltips depending on the configuration
217 * option gnome-tooltips
218 *****************************************************************************/
219 int E_(GtkHideTooltips)( vlc_object_t *p_this, const char *psz_name,
220 vlc_value_t oldval, vlc_value_t val, void *p_data )
222 intf_thread_t *p_intf;
224 vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
227 vlc_bool_t b_enable = config_GetInt( p_this, "gnome-tooltips" );
229 for( i_index = 0; i_index < p_list->i_count; i_index++ )
231 p_intf = (intf_thread_t *)p_list->p_values[i_index].p_object ;
233 if( strcmp( MODULE_STRING, p_intf->p_module->psz_object_name ) )
240 gtk_tooltips_enable( p_intf->p_sys->p_tooltips );
244 gtk_tooltips_disable( p_intf->p_sys->p_tooltips );
248 vlc_list_release( p_list );
252 #ifdef MODULE_NAME_IS_gnome
253 /*****************************************************************************
254 * GtkHideToolbartext: show or hide the tooltips depending on the
255 * configuration option gnome-toolbartext
256 *****************************************************************************
257 * FIXME: GNOME only because of missing icons in gtk interface
258 *****************************************************************************/
259 int GtkHideToolbarText( vlc_object_t *p_this, const char *psz_name,
260 vlc_value_t oldval, vlc_value_t val, void *p_data )
262 GtkToolbarStyle style;
263 GtkToolbar * p_toolbar;
264 intf_thread_t *p_intf;
266 vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
269 style = config_GetInt( p_this, "gnome-toolbartext" )
273 for( i_index = 0; i_index < p_list->i_count; i_index++ )
275 p_intf = (intf_thread_t *)p_list->p_values[i_index].p_object ;
277 if( strcmp( MODULE_STRING, p_intf->p_module->psz_object_name ) )
282 p_toolbar = GTK_TOOLBAR(lookup_widget( p_intf->p_sys->p_window,
284 gtk_toolbar_set_style( p_toolbar, style );
287 vlc_list_release( p_list );