1 /*****************************************************************************
2 * gtk_display.c: Gtk+ tools for main interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: gtk_display.c,v 1.17 2002/03/05 17:46:33 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 /*****************************************************************************
27 *****************************************************************************/
28 #include <errno.h> /* ENOMEM */
29 #include <stdlib.h> /* free() */
30 #include <string.h> /* strerror() */
33 #include <videolan/vlc.h>
35 #ifdef MODULE_NAME_IS_gnome
41 #include "stream_control.h"
42 #include "input_ext-intf.h"
44 #include "interface.h"
45 #include "intf_playlist.h"
48 #include "video_output.h"
50 #include "gtk_callbacks.h"
51 #include "gtk_interface.h"
52 #include "gtk_support.h"
54 #include "gtk_display.h"
55 #include "gtk_common.h"
57 /*****************************************************************************
58 * GtkDisplayDate: display stream date
59 *****************************************************************************
60 * This function displays the current date related to the position in
61 * the stream. It is called whenever the slider changes its value.
62 * The lock has to be taken before you call the function.
63 *****************************************************************************/
64 void GtkDisplayDate( GtkAdjustment *p_adj )
66 intf_thread_t *p_intf;
68 p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
70 if( p_input_bank->pp_input[0] != NULL )
72 #define p_area p_input_bank->pp_input[0]->stream.p_selected_area
73 char psz_time[ OFFSETTOTIME_MAX_SIZE ];
75 gtk_frame_set_label( GTK_FRAME( p_intf->p_sys->p_slider_frame ),
76 input_OffsetToTime( p_input_bank->pp_input[0], psz_time,
77 ( p_area->i_size * p_adj->value ) / 100 ) );
83 /*****************************************************************************
84 * GtkModeManage: actualise the aspect of the interface whenever the input
86 *****************************************************************************
87 * The lock has to be taken before you call the function.
88 *****************************************************************************/
89 gint GtkModeManage( intf_thread_t * p_intf )
91 GtkWidget * p_dvd_box;
92 GtkWidget * p_file_box;
93 GtkWidget * p_network_box;
96 GtkWidget * p_channel;
99 #define GETWIDGET( ptr, name ) GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( \
100 p_intf->p_sys->ptr ) , ( name ) ) )
101 /* hide all boxes except default file box */
102 p_file_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
103 p_intf->p_sys->p_window ), "file_box" ) );
104 gtk_widget_hide( GTK_WIDGET( p_file_box ) );
106 p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
107 p_intf->p_sys->p_window ), "network_box" ) );
108 gtk_widget_hide( GTK_WIDGET( p_network_box ) );
110 p_dvd_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
111 p_intf->p_sys->p_window ), "dvd_box" ) );
112 gtk_widget_hide( GTK_WIDGET( p_dvd_box ) );
115 p_slider = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
116 p_intf->p_sys->p_window ), "slider_frame" ) );
117 gtk_widget_hide( GTK_WIDGET( p_slider ) );
119 /* controls unavailable */
122 /* show the box related to current input mode */
123 if( p_input_bank->pp_input[0] != NULL )
125 switch( p_input_bank->pp_input[0]->stream.i_method & 0xf0 )
127 case INPUT_METHOD_FILE:
128 //intf_WarnMsg( 2, "intf info: file method" );
129 gtk_widget_show( GTK_WIDGET( p_file_box ) );
130 p_label = gtk_object_get_data( GTK_OBJECT(
131 p_intf->p_sys->p_window ),
133 gtk_label_set_text( GTK_LABEL( p_label ),
134 p_input_bank->pp_input[0]->psz_source );
136 case INPUT_METHOD_DISC:
137 //intf_WarnMsg( 2, "intf info: disc method" );
138 gtk_widget_show( GTK_WIDGET( p_dvd_box ) );
140 case INPUT_METHOD_NETWORK:
141 //intf_WarnMsg( 2, "intf info: network method" );
142 gtk_widget_show( GTK_WIDGET( p_network_box ) );
143 p_label = gtk_object_get_data( GTK_OBJECT(
144 p_intf->p_sys->p_window ),
145 "network_address_label" );
146 gtk_label_set_text( GTK_LABEL( p_label ),
147 p_input_bank->pp_input[0]->psz_source );
148 p_channel = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
149 p_intf->p_sys->p_window ), "network_channel_box" ) );
150 if( config_GetIntVariable( INPUT_NETWORK_CHANNEL_VAR ) )
152 gtk_widget_show( GTK_WIDGET( p_channel ) );
156 gtk_widget_hide( GTK_WIDGET( p_channel ) );
161 intf_WarnMsg( 3, "intf: can't determine input method" );
162 gtk_widget_show( GTK_WIDGET( p_file_box ) );
163 p_label = gtk_object_get_data( GTK_OBJECT(
164 p_intf->p_sys->p_window ),
166 gtk_label_set_text( GTK_LABEL( p_label ),
167 p_input_bank->pp_input[0]->psz_source );
171 /* initialize and show slider for seekable streams */
172 if( p_input_bank->pp_input[0]->stream.b_seekable )
174 p_intf->p_sys->p_adj->value = p_intf->p_sys->f_adj_oldvalue = 0;
175 gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
177 gtk_widget_show( GTK_WIDGET( p_slider ) );
180 /* control buttons for free pace streams */
181 b_control = p_input_bank->pp_input[0]->stream.b_pace_control;
183 /* get ready for menu regeneration */
184 p_intf->p_sys->b_program_update = 1;
185 p_intf->p_sys->b_title_update = 1;
186 p_intf->p_sys->b_chapter_update = 1;
187 p_intf->p_sys->b_audio_update = 1;
188 p_intf->p_sys->b_spu_update = 1;
189 p_intf->p_sys->i_part = 0;
191 p_input_bank->pp_input[0]->stream.b_changed = 0;
192 intf_WarnMsg( 3, "intf: stream has changed, refreshing interface" );
196 if( config_GetIntVariable( INPUT_NETWORK_CHANNEL_VAR ) )
198 gtk_widget_show( GTK_WIDGET( p_network_box ) );
200 p_channel = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
201 p_intf->p_sys->p_window ), "network_channel_box" ) );
202 gtk_widget_show( GTK_WIDGET( p_channel ) );
206 //intf_WarnMsg( 2, "intf info: default to file method" );
208 p_label = gtk_object_get_data(
209 GTK_OBJECT( p_intf->p_sys->p_window ), "label_status" );
210 gtk_label_set_text( GTK_LABEL( p_label ), "" );
211 gtk_widget_show( GTK_WIDGET( p_file_box ) );
213 /* unsensitize menus */
214 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_program"),
216 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_title"), FALSE );
217 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_chapter"),
219 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_angle"), FALSE );
220 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_audio"), FALSE );
221 gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_subpictures"),
223 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_navigation"),
225 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_angle"), FALSE );
226 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_audio"), FALSE );
227 gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_subpictures"),
232 /* set control items */
233 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_back"), FALSE );
234 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_eject"), !b_control);
235 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_pause"), b_control );
236 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_slow"), b_control );
237 gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_fast"), b_control );
238 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_back"), FALSE );
239 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_pause"), b_control );
240 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_slow"), b_control );
241 gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_fast"), b_control );