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