]> git.sesse.net Git - vlc/blob - plugins/gtk/gtk_display.c
e1d6b854ef367c417c0d2f8464a7ba0fae50febd
[vlc] / plugins / gtk / gtk_display.c
1 /*****************************************************************************
2  * gtk_display.c: Gtk+ tools for main interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: gtk_display.c,v 1.2 2001/05/30 05:19:03 stef Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Stéphane Borel <stef@via.ecp.fr>
9  *
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.
14  * 
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.
19  *
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  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #include <errno.h>                                                 /* ENOMEM */
31 #include <stdlib.h>                                                /* free() */
32 #include <string.h>                                            /* strerror() */
33 #include <stdio.h>
34
35 #include <gtk/gtk.h>
36
37 #include "config.h"
38 #include "common.h"
39 #include "threads.h"
40 #include "mtime.h"
41 #include "tests.h"
42 #include "modules.h"
43
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
46
47 #include "interface.h"
48 #include "intf_msg.h"
49 #include "intf_playlist.h"
50
51 #include "video.h"
52 #include "video_output.h"
53
54 #include "gtk_callbacks.h"
55 #include "gtk_interface.h"
56 #include "gtk_support.h"
57 #include "gtk_menu.h"
58 #include "gtk_display.h"
59 #include "intf_gtk.h"
60
61 #include "main.h"
62
63 /*****************************************************************************
64  * GtkDisplayDate: display stream date
65  *****************************************************************************
66  * This function displays the current date related to the position in
67  * the stream. It is called whenever the slider changes its value.
68  * The lock has to be taken before you call the function.
69  *****************************************************************************/
70 void GtkDisplayDate( GtkAdjustment *p_adj )
71 {
72     intf_thread_t *p_intf;
73    
74     p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
75
76     if( p_intf->p_input != NULL )
77     {
78 #define p_area p_intf->p_input->stream.p_selected_area
79         char psz_time[ OFFSETTOTIME_MAX_SIZE ];
80
81         gtk_frame_set_label( GTK_FRAME( p_intf->p_sys->p_slider_frame ),
82                             input_OffsetToTime( p_intf->p_input, psz_time,
83                                    ( p_area->i_size * p_adj->value ) / 100 ) );
84 #undef p_area
85      }
86 }
87
88
89 /*****************************************************************************
90  * GtkModeManage: actualise the aspect of the interface whenever the input
91  *                changes.
92  *****************************************************************************
93  * The lock has to be taken before you call the function.
94  *****************************************************************************/
95 gint GtkModeManage( intf_thread_t * p_intf )
96 {
97     GtkWidget *     p_dvd_box;
98     GtkWidget *     p_file_box;
99     GtkWidget *     p_network_box;
100     GtkWidget *     p_slider;
101     GtkWidget *     p_label;
102     boolean_t       b_control;
103
104 #define GETWIDGET( ptr, name ) GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( \
105                            p_intf->p_sys->ptr ) , ( name ) ) )
106     /* hide all boxes except default file box */
107     p_file_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
108                  p_intf->p_sys->p_window ), "file_box" ) );
109     gtk_widget_hide( GTK_WIDGET( p_file_box ) );
110
111     p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
112                  p_intf->p_sys->p_window ), "network_box" ) );
113     gtk_widget_hide( GTK_WIDGET( p_network_box ) );
114
115     p_dvd_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
116                  p_intf->p_sys->p_window ), "dvd_box" ) );
117     gtk_widget_hide( GTK_WIDGET( p_dvd_box ) );
118
119     /* hide slider */
120     p_slider = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
121                            p_intf->p_sys->p_window ), "slider_frame" ) );
122     gtk_widget_hide( GTK_WIDGET( p_slider ) );
123
124     /* controls unavailable */
125     b_control = 0;
126
127     /* show the box related to current input mode */
128     if( p_intf->p_input != NULL )
129     {
130         switch( p_intf->p_input->stream.i_method & 0xf0 )
131         {
132             case INPUT_METHOD_FILE:
133 //intf_WarnMsg( 2, "intf info: file method" );
134                 gtk_widget_show( GTK_WIDGET( p_file_box ) );
135                 p_label = gtk_object_get_data( GTK_OBJECT(
136                             p_intf->p_sys->p_window ),
137                             "label_status" );
138                 gtk_label_set_text( GTK_LABEL( p_label ),
139                                     p_intf->p_input->p_source );
140                 break;
141             case INPUT_METHOD_DISC:
142 //intf_WarnMsg( 2, "intf info: disc method" );
143                 gtk_widget_show( GTK_WIDGET( p_dvd_box ) );
144                 break;
145             case INPUT_METHOD_NETWORK:
146 //intf_WarnMsg( 2, "intf info: network method" );
147                 gtk_widget_show( GTK_WIDGET( p_network_box ) );
148                 p_label = gtk_object_get_data( GTK_OBJECT(
149                             p_intf->p_sys->p_window ),
150                             "network_address_label" );
151                 gtk_label_set_text( GTK_LABEL( p_label ),
152                                     p_intf->p_input->p_source );
153                 break;
154             default:
155                 intf_ErrMsg( "intf error: can't determine input method" );
156                 break;
157         }
158     
159         /* slider for seekable streams */
160         if( p_intf->p_input->stream.b_seekable )
161         {
162             gtk_widget_show( GTK_WIDGET( p_slider ) );
163         }
164     
165         /* control buttons for free pace streams */
166         b_control = p_intf->p_input->stream.b_pace_control;
167
168         /* get ready for menu regeneration */
169         p_intf->p_sys->b_title_update = 1;
170         p_intf->p_sys->b_chapter_update = 1;
171         p_intf->p_sys->b_angle_update = 1;
172         p_intf->p_sys->b_audio_update = 1;
173         p_intf->p_sys->b_spu_update = 1;
174         p_intf->p_sys->i_part = 0;
175     
176         p_intf->p_input->stream.b_changed = 0;
177         intf_WarnMsg( 3, 
178                       "intf info: menus refreshed as stream has changed" );
179     }
180     else
181     {
182 //intf_WarnMsg( 2, "intf info: default to file method" );
183         /* default mode */
184         p_label = gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_window ),
185                         "label_status" );
186         gtk_label_set_text( GTK_LABEL( p_label ), "" );
187         gtk_widget_show( GTK_WIDGET( p_file_box ) );
188
189         /* unsensitize menus */
190         gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_title"), FALSE );
191         gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_chapter"),
192                                   FALSE );
193         gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_angle"), FALSE );
194         gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_audio"), FALSE );
195         gtk_widget_set_sensitive( GETWIDGET(p_window,"menubar_subpictures"),
196                                   FALSE );
197         gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_navigation"),
198                                   FALSE );
199         gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_angle"), FALSE );
200         gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_audio"), FALSE );
201         gtk_widget_set_sensitive( GETWIDGET(p_popup,"popup_subpictures"),
202                                   FALSE );
203     }
204
205     /* set control items */
206     gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_back"), FALSE );
207     gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_stop"), b_control );
208     gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_pause"), b_control );
209     gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_slow"), b_control );
210     gtk_widget_set_sensitive( GETWIDGET(p_window, "toolbar_fast"), b_control );
211     gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_back"), FALSE );
212     gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_stop"), b_control );
213     gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_pause"), b_control );
214     gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_slow"), b_control );
215     gtk_widget_set_sensitive( GETWIDGET(p_popup, "popup_fast"), b_control );
216
217 #undef GETWIDGET
218     return TRUE;
219 }