]> git.sesse.net Git - vlc/blob - modules/gui/pda/pda.c
Remove E_()
[vlc] / modules / gui / pda / pda.c
1 /*****************************************************************************
2  * pda.c : PDA Gtk2 plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2002 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Paul Saman <jpsaman  _at_ videolan _dot_ org>
8  *          Marc Ariberti <marcari@videolan.org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <errno.h>                                                 /* ENOMEM */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <vlc/vlc.h>
35 #include <vlc_plugin.h>
36 #include <vlc_input.h>
37 #include <vlc_interface.h>
38 #include <vlc_playlist.h>
39
40 #include <gtk/gtk.h>
41
42 #include "pda_callbacks.h"
43 #include "pda_interface.h"
44 #include "pda_support.h"
45 #include "pda.h"
46
47 /*****************************************************************************
48  * Local prototypes.
49  *****************************************************************************/
50 static int  Open         ( vlc_object_t * );
51 static void Close        ( vlc_object_t * );
52 static void Run          ( intf_thread_t * );
53
54 void GtkAutoPlayFile     ( vlc_object_t * );
55 static int Manage        ( intf_thread_t *p_intf );
56 void GtkDisplayDate  ( GtkAdjustment *p_adj, gpointer userdata );
57 gint GtkModeManage   ( intf_thread_t * p_intf );
58
59 /*****************************************************************************
60  * Module descriptor
61  *****************************************************************************/
62 #define AUTOPLAYFILE_TEXT  N_("Autoplay selected file")
63 #define AUTOPLAYFILE_LONGTEXT N_("Automatically play a file when selected in the "\
64         "file selection list")
65
66 /*****************************************************************************
67  * Module descriptor
68  *****************************************************************************/
69 vlc_module_begin();
70     set_description( _("PDA Linux Gtk2+ interface") );
71     set_category( CAT_INTERFACE );
72     set_subcategory( SUBCAT_INTERFACE_MAIN );
73 //    add_bool( "pda-autoplayfile", 1, GtkAutoPlayFile, AUTOPLAYFILE_TEXT, AUTOPLAYFILE_LONGTEXT, true );
74     set_capability( "interface", 70 );
75     set_callbacks( Open, Close );
76     add_shortcut( "pda" );
77 vlc_module_end();
78
79 /*****************************************************************************
80  * Open: initialize and create window
81  *****************************************************************************/
82 static int Open( vlc_object_t *p_this )
83 {
84     intf_thread_t *p_intf = (intf_thread_t *)p_this;
85
86     /* Allocate instance and initialize some members */
87     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
88     if( p_intf->p_sys == NULL )
89     {
90         msg_Err( p_intf, "out of memory" );
91         return VLC_ENOMEM;
92     }
93
94 #ifdef NEED_GTK2_MAIN
95     msg_Dbg( p_intf, "Using gui-helper" );
96     p_intf->p_sys->p_gtk_main =
97         module_Need( p_this, "gui-helper", "gtk2", true );
98     if( p_intf->p_sys->p_gtk_main == NULL )
99     {
100         free( p_intf->p_sys );
101         return VLC_ENOMOD;
102     }
103 #endif
104
105     /* Initialize Gtk+ thread */
106     p_intf->p_sys->p_input = NULL;
107
108     p_intf->p_sys->b_autoplayfile = 1;
109     p_intf->p_sys->b_playing = 0;
110     p_intf->p_sys->b_slider_free = 1;
111
112     p_intf->pf_run = Run;
113
114     return VLC_SUCCESS;
115 }
116
117 /*****************************************************************************
118  * Close: destroy interface window
119  *****************************************************************************/
120 static void Close( vlc_object_t *p_this )
121 {
122     intf_thread_t *p_intf = (intf_thread_t *)p_this;
123
124     if( p_intf->p_sys->p_input )
125     {
126         vlc_object_release( p_intf->p_sys->p_input );
127     }
128
129 #ifdef NEED_GTK2_MAIN
130     msg_Dbg( p_intf, "Releasing gui-helper" );
131     module_Unneed( p_intf, p_intf->p_sys->p_gtk_main );
132 #endif
133
134     /* Destroy structure */
135     free( p_intf->p_sys );
136 }
137
138 /*****************************************************************************
139  * Run: Gtk+ thread
140  *****************************************************************************
141  * this part of the interface is in a separate thread so that we can call
142  * gtk_main() from within it without annoying the rest of the program.
143  *****************************************************************************/
144 static void Run( intf_thread_t *p_intf )
145 {
146 #ifndef NEED_GTK2_MAIN
147     /* gtk_init needs to know the command line. We don't care, so we
148      * give it an empty one */
149     char  *p_args[] = { "", NULL };
150     char **pp_args  = p_args;
151     int    i_args   = 1;
152     int    i_dummy;
153 #endif
154     playlist_t        *p_playlist;
155     GtkCellRenderer   *p_renderer = NULL;
156     GtkTreeViewColumn *p_column   = NULL;
157     GtkListStore      *p_filelist = NULL;
158     GtkListStore      *p_playlist_store = NULL;
159
160 #ifndef NEED_GTK2_MAIN
161     gtk_set_locale ();
162     msg_Dbg( p_intf, "Starting pda GTK2+ interface" );
163     gtk_init( &i_args, &pp_args );
164 #else
165     /* Initialize Gtk+ */
166     msg_Dbg( p_intf, "Starting pda GTK2+ interface thread" );
167     gdk_threads_enter();
168 #endif
169
170     /* Create some useful widgets that will certainly be used */
171 /* FIXME: magic path */
172     add_pixmap_directory("share");
173     add_pixmap_directory("/usr/share/vlc");
174
175     /* Path for pixmaps under linupy 1.4 */
176     add_pixmap_directory("/usr/local/share/pixmaps/vlc");
177     /* Path for pixmaps under linupy 2.0 */
178     add_pixmap_directory("/usr/share/pixmaps/vlc");
179
180     p_intf->p_sys->p_window = create_pda();
181     if (p_intf->p_sys->p_window == NULL)
182     {
183         msg_Err( p_intf, "unable to create pda interface" );
184     }
185
186     /* Store p_intf to keep an eye on it */
187     gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
188                          "p_intf", p_intf );
189
190     /* Set the title of the main window */
191     gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
192                           VOUT_TITLE " (PDA Linux interface)");
193
194     /* Get the notebook object */
195     p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
196         GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );
197
198     /* Get the slider object */
199     p_intf->p_sys->p_slider = (GtkHScale*) lookup_widget( p_intf->p_sys->p_window, "timeSlider" );
200     p_intf->p_sys->p_slider_label = (GtkLabel*) lookup_widget( p_intf->p_sys->p_window, "timeLabel" );
201     if (p_intf->p_sys->p_slider == NULL)
202         msg_Err( p_intf, "Time slider widget not found." );
203     if (p_intf->p_sys->p_slider_label == NULL)
204         msg_Err( p_intf, "Time label widget not found." );
205
206     /* Connect the date display to the slider */
207     p_intf->p_sys->p_adj = gtk_range_get_adjustment( GTK_RANGE(p_intf->p_sys->p_slider) );
208     if (p_intf->p_sys->p_adj == NULL)
209         msg_Err( p_intf, "Adjustment range not found." );
210     g_signal_connect( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed",
211                          G_CALLBACK( GtkDisplayDate ), p_intf );
212     p_intf->p_sys->f_adj_oldvalue = 0;
213     p_intf->p_sys->i_adj_oldvalue = 0;
214
215     /* BEGIN OF FILEVIEW GTK_TREE_VIEW */
216     p_intf->p_sys->p_tvfile = NULL;
217     p_intf->p_sys->p_tvfile = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window,
218                                                              "tvFileList");
219     if (NULL == p_intf->p_sys->p_tvfile)
220        msg_Err(p_intf, "Error obtaining pointer to File List");
221
222     /* Insert columns 0 */
223     p_renderer = gtk_cell_renderer_text_new ();
224     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, (gchar *) N_("Filename"), p_renderer, NULL);
225     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 0 );
226     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
227     gtk_tree_view_column_set_sort_column_id(p_column, 0);
228     /* Insert columns 1 */
229     p_renderer = gtk_cell_renderer_text_new ();
230     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, (gchar *) N_("Permissions"), p_renderer, NULL);
231     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 1 );
232     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
233     gtk_tree_view_column_set_sort_column_id(p_column, 1);
234     /* Insert columns 2 */
235     p_renderer = gtk_cell_renderer_text_new ();
236     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 2, (gchar *) N_("Size"), p_renderer, NULL);
237     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 2 );
238     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
239     gtk_tree_view_column_set_sort_column_id(p_column, 2);
240     /* Insert columns 3 */
241     p_renderer = gtk_cell_renderer_text_new ();
242     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, (gchar *) N_("Owner"), p_renderer, NULL);
243     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 3 );
244     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 3 );
245     gtk_tree_view_column_set_sort_column_id(p_column, 3);
246     /* Insert columns 4 */
247     p_renderer = gtk_cell_renderer_text_new ();
248     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, (gchar *) N_("Group"), p_renderer, NULL);
249     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 4 );
250     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 4 );
251     gtk_tree_view_column_set_sort_column_id(p_column, 4);
252
253     /* Get new directory listing */
254     p_filelist = gtk_list_store_new (5,
255                 G_TYPE_STRING, /* Filename */
256                 G_TYPE_STRING, /* permissions */
257                 G_TYPE_UINT64, /* File size */
258                 G_TYPE_STRING, /* Owner */
259                 G_TYPE_STRING);/* Group */
260     ReadDirectory(p_intf, p_filelist, ".");
261     gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(p_filelist));
262     g_object_unref(p_filelist);     /* Model will be released by GtkTreeView */
263     gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE);
264
265     /* Column properties */
266     gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvfile, TRUE);
267     gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvfile);
268     gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile),TRUE);
269     /* END OF FILEVIEW GTK_TREE_VIEW */
270
271     /* BEGIN OF PLAYLIST GTK_TREE_VIEW */
272     p_intf->p_sys->p_tvplaylist = NULL;
273     p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window, "tvPlaylist");
274     if (NULL == p_intf->p_sys->p_tvplaylist)
275        msg_Err(p_intf, "Error obtaining pointer to Play List");
276
277     /* Columns 1 */
278     p_renderer = gtk_cell_renderer_text_new ();
279     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, (gchar *) N_("Filename"), p_renderer, NULL);
280     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 0 );
281     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
282     gtk_tree_view_column_set_sort_column_id(p_column, 0);
283     /* Column 2 */
284     p_renderer = gtk_cell_renderer_text_new ();
285     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, (gchar *) N_("Time"), p_renderer, NULL);
286     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 1 );
287     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
288     gtk_tree_view_column_set_sort_column_id(p_column, 1);
289 #if 0
290     /* Column 3 - is a hidden column used for reliable deleting items from the underlying playlist */
291     p_renderer = gtk_cell_renderer_text_new ();
292     gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 2, (gchar *) N_("Index"), p_renderer, NULL);
293     p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 2 );
294     gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
295     gtk_tree_view_column_set_sort_column_id(p_column, 2);
296 #endif
297     /* update the playlist */
298     p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
299     p_playlist_store = gtk_list_store_new (3,
300                 G_TYPE_STRING, /* Filename */
301                 G_TYPE_STRING, /* Time */
302                 G_TYPE_UINT);  /* Hidden index */
303     PlaylistRebuildListStore(p_intf,p_playlist_store, p_playlist);
304     gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(p_playlist_store));
305     g_object_unref(p_playlist_store);
306     vlc_object_release(p_playlist); /* Free the playlist */
307     gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist)),GTK_SELECTION_MULTIPLE);
308
309     /* Column properties */
310     gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvplaylist, TRUE);
311     gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvplaylist);
312     gtk_tree_view_set_headers_clickable(p_intf->p_sys->p_tvplaylist, TRUE);
313     /* END OF PLAYLIST GTK_TREE_VIEW */
314
315     /* Hide the Preference TAB for now. */
316     GtkWidget *p_preference_tab = NULL;
317     p_preference_tab = gtk_notebook_get_nth_page(p_intf->p_sys->p_notebook,5);
318     if (p_preference_tab != NULL)
319       gtk_widget_hide(p_preference_tab);
320
321     /* Show the control window */
322     gtk_widget_show( p_intf->p_sys->p_window );
323
324 #ifdef NEED_GTK2_MAIN
325     msg_Dbg( p_intf, "Manage GTK keyboard events using threads" );
326     while( !intf_ShouldDie( p_intf ) )
327     {
328         Manage( p_intf );
329
330         /* Sleep to avoid using all CPU - since some interfaces need to
331          * access keyboard events, a 100ms delay is a good compromise */
332         gdk_threads_leave();
333         if (vlc_CPU() & CPU_CAPABILITY_FPU)
334             msleep( INTF_IDLE_SLEEP );
335         else
336             msleep( 1000 );
337         gdk_threads_enter();
338     }
339 #else
340     msg_Dbg( p_intf, "Manage GTK keyboard events using timeouts" );
341     /* Sleep to avoid using all CPU - since some interfaces needs to access
342      * keyboard events, a 1000ms delay is a good compromise */
343     if (vlc_CPU() & CPU_CAPABILITY_FPU)
344         i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage, p_intf );
345     else
346         i_dummy = gtk_timeout_add( 1000, (GtkFunction)Manage, p_intf );
347
348     /* Enter Gtk mode */
349     gtk_main();
350     /* Remove the timeout */
351     gtk_timeout_remove( i_dummy );
352 #endif
353
354     gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
355 #ifdef NEED_GTK2_MAIN
356     gdk_threads_leave();
357 #endif
358 }
359
360 /*****************************************************************************
361  * GtkAutoplayFile: Autoplay file depending on configuration settings
362  *****************************************************************************/
363 void GtkAutoPlayFile( vlc_object_t *p_this )
364 {
365     GtkWidget *cbautoplay;
366     intf_thread_t *p_intf;
367     int i_index;
368     vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
369                                         FIND_ANYWHERE );
370
371     for( i_index = 0; i_index < p_list->i_count; i_index++ )
372     {
373         p_intf = (intf_thread_t *)p_list->p_values[i_index].p_object ;
374
375         if( strcmp( MODULE_STRING, module_GetObjName(p_intf->p_module) ) )
376         {
377             continue;
378         }
379         cbautoplay = GTK_WIDGET( gtk_object_get_data(
380                             GTK_OBJECT( p_intf->p_sys->p_window ),
381                             "cbautoplay" ) );
382
383         if( !config_GetInt( p_this, "pda-autoplayfile" ) )
384         {
385             p_intf->p_sys->b_autoplayfile = false;
386         }
387         else
388         {
389             p_intf->p_sys->b_autoplayfile = true;
390         }
391         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( cbautoplay ),
392                                       p_intf->p_sys->b_autoplayfile );
393     }
394     vlc_list_release( p_list );
395 }
396
397 /* following functions are local */
398
399 /*****************************************************************************
400  * Manage: manage main thread messages
401  *****************************************************************************
402  * In this function, called approx. 10 times a second, we check what the
403  * main program wanted to tell us.
404  *****************************************************************************/
405 static int Manage( intf_thread_t *p_intf )
406 {
407     GtkListStore *p_liststore;
408     vlc_mutex_lock( &p_intf->change_lock );
409
410     /* Update the input */
411     if( p_intf->p_sys->p_input == NULL )
412     {
413         p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
414                                                           FIND_ANYWHERE );
415     }
416     else if( p_intf->p_sys->p_input->b_dead )
417     {
418         vlc_object_release( p_intf->p_sys->p_input );
419         p_intf->p_sys->p_input = NULL;
420     }
421
422     if( p_intf->p_sys->p_input )
423     {
424         input_thread_t *p_input = p_intf->p_sys->p_input;
425         int64_t i_time = 0, i_length = 0;
426
427         vlc_mutex_lock( &p_input->object_lock );
428         if( !p_input->b_die )
429         {
430             playlist_t *p_playlist;
431
432             GtkModeManage( p_intf );
433             p_intf->p_sys->b_playing = 1;
434
435             /* update playlist interface */
436             p_playlist = (playlist_t *) vlc_object_find(
437                     p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
438             if (p_playlist != NULL)
439             {
440                 p_liststore = gtk_list_store_new (3,
441                                             G_TYPE_STRING,
442                                             G_TYPE_STRING,
443                                             G_TYPE_UINT);  /* Hidden index */
444                 PlaylistRebuildListStore(p_intf, p_liststore, p_playlist);
445                 gtk_tree_view_set_model(p_intf->p_sys->p_tvplaylist, (GtkTreeModel*) p_liststore);
446                 g_object_unref(p_liststore);
447                 vlc_object_release( p_playlist );
448             }
449
450             /* Manage the slider */
451             i_time = var_GetTime( p_intf->p_sys->p_input, "time" );
452             i_length = var_GetTime( p_intf->p_sys->p_input, "length" );
453
454             if (vlc_CPU() & CPU_CAPABILITY_FPU)
455             {
456                 /* Manage the slider for CPU_CAPABILITY_FPU hardware */
457                 if( p_intf->p_sys->b_playing )
458                 {
459                     float newvalue = p_intf->p_sys->p_adj->value;
460
461                     /* If the user hasn't touched the slider since the last time,
462                      * then the input can safely change it */
463                     if( newvalue == p_intf->p_sys->f_adj_oldvalue )
464                     {
465                         /* Update the value */
466                         p_intf->p_sys->p_adj->value =
467                         p_intf->p_sys->f_adj_oldvalue =
468                             ( 100 * i_time ) / i_length;
469                         g_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
470                                                  "value_changed" );
471                     }
472                     /* Otherwise, send message to the input if the user has
473                      * finished dragging the slider */
474                     else if( p_intf->p_sys->b_slider_free )
475                     {
476                         double f_pos = (double)newvalue / 100.0;
477
478                         /* release the lock to be able to seek */
479                         vlc_mutex_unlock( &p_input->object_lock );
480                         var_SetFloat( p_input, "position", f_pos );
481                         vlc_mutex_lock( &p_input->object_lock );
482
483                         /* Update the old value */
484                         p_intf->p_sys->f_adj_oldvalue = newvalue;
485                     }
486                 }
487             }
488             else
489             {
490                 /* Manage the slider without CPU_CAPABILITY_FPU hardware */
491                 if( p_intf->p_sys->b_playing )
492                 {
493                     off_t newvalue = p_intf->p_sys->p_adj->value;
494
495                     /* If the user hasn't touched the slider since the last time,
496                      * then the input can safely change it */
497                     if( newvalue == p_intf->p_sys->i_adj_oldvalue )
498                     {
499                         /* Update the value */
500                         p_intf->p_sys->p_adj->value =
501                         p_intf->p_sys->i_adj_oldvalue =
502                             ( 100 * i_time ) / i_length;
503                         g_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
504                                                  "value_changed" );
505                     }
506                     /* Otherwise, send message to the input if the user has
507                      * finished dragging the slider */
508                     else if( p_intf->p_sys->b_slider_free )
509                     {
510                         double f_pos = (double)newvalue / 100.0;
511
512                         /* release the lock to be able to seek */
513                         vlc_mutex_unlock( &p_input->object_lock );
514                         var_SetFloat( p_input, "position", f_pos );
515                         vlc_mutex_lock( &p_input->object_lock );
516
517                         /* Update the old value */
518                         p_intf->p_sys->i_adj_oldvalue = newvalue;
519                     }
520                 }
521             }
522         }
523         vlc_mutex_unlock( &p_input->object_lock );
524     }
525     else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) )
526     {
527         GtkModeManage( p_intf );
528         p_intf->p_sys->b_playing = 0;
529     }
530
531 #ifndef NEED_GTK2_MAIN
532     if( intf_ShouldDie( p_intf ) )
533     {
534         vlc_mutex_unlock( &p_intf->change_lock );
535
536         /* Prepare to die, young Skywalker */
537         gtk_main_quit();
538
539         return FALSE;
540     }
541 #endif
542
543     vlc_mutex_unlock( &p_intf->change_lock );
544
545     return TRUE;
546 }
547
548 /*****************************************************************************
549  * GtkDisplayDate: display stream date
550  *****************************************************************************
551  * This function displays the current date related to the position in
552  * the stream. It is called whenever the slider changes its value.
553  * The lock has to be taken before you call the function.
554  *****************************************************************************/
555 void GtkDisplayDate( GtkAdjustment *p_adj, gpointer userdata )
556 {
557     intf_thread_t *p_intf;
558
559     p_intf = (intf_thread_t*) userdata;
560     if (p_intf == NULL)
561         return;
562
563     if( p_intf->p_sys->p_input )
564     {
565         char psz_time[ MSTRTIME_MAX_SIZE ];
566         int64_t i_seconds;
567
568         i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / INT64_C(1000000 );
569         secstotimestr( psz_time, i_seconds );
570
571         gtk_label_set_text( GTK_LABEL( p_intf->p_sys->p_slider_label ),
572                             psz_time );
573      }
574 }
575
576 /*****************************************************************************
577  * GtkModeManage: actualize the aspect of the interface whenever the input
578  *                changes.
579  *****************************************************************************
580  * The lock has to be taken before you call the function.
581  *****************************************************************************/
582 gint GtkModeManage( intf_thread_t * p_intf )
583 {
584     GtkWidget *     p_slider = NULL;
585     bool      b_control;
586
587     if ( p_intf->p_sys->p_window == NULL )
588         msg_Err( p_intf, "Main widget not found" );
589
590     p_slider = lookup_widget( p_intf->p_sys->p_window, "timeSlider");
591     if (p_slider == NULL)
592         msg_Err( p_intf, "Slider widget not found" );
593
594     /* controls unavailable */
595     b_control = 0;
596
597     /* show the box related to current input mode */
598     if( p_intf->p_sys->p_input )
599     {
600         /* initialize and show slider for seekable streams */
601         {
602             gtk_widget_show( GTK_WIDGET( p_slider ) );
603         }
604
605         /* control buttons for free pace streams */
606         b_control = p_intf->p_sys->p_input->b_can_pace_control;
607
608         msg_Dbg( p_intf, "stream has changed, refreshing interface" );
609     }
610
611     /* set control items */
612     gtk_widget_set_sensitive( lookup_widget( p_intf->p_sys->p_window, "tbRewind"), b_control );
613     gtk_widget_set_sensitive( lookup_widget( p_intf->p_sys->p_window, "tbPause"), b_control );
614     gtk_widget_set_sensitive( lookup_widget( p_intf->p_sys->p_window, "tbForward"), b_control );
615     return TRUE;
616 }