1 /*****************************************************************************
2 * intf_gnome.c: Gnome interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: intf_gnome.c,v 1.28 2001/04/12 03:26:53 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 #define MODULE_NAME gnome
26 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
33 #include <errno.h> /* ENOMEM */
34 #include <stdlib.h> /* free() */
35 #include <string.h> /* strerror() */
47 #include "stream_control.h"
48 #include "input_ext-intf.h"
51 #include "interface.h"
52 #include "intf_playlist.h"
54 #include "gnome_callbacks.h"
55 #include "gnome_interface.h"
56 #include "gnome_support.h"
57 #include "intf_gnome.h"
61 /*****************************************************************************
63 *****************************************************************************/
64 static int intf_Probe ( probedata_t *p_data );
65 static int intf_Open ( intf_thread_t *p_intf );
66 static void intf_Close ( intf_thread_t *p_intf );
67 static void intf_Run ( intf_thread_t *p_intf );
69 static gint GnomeManage ( gpointer p_data );
70 static gint GnomeLanguageMenus( gpointer, GtkWidget *, es_descriptor_t *, gint,
71 void (*pf_toggle)(GtkCheckMenuItem *, gpointer) );
72 static gint GnomeChapterMenu ( gpointer, GtkWidget *,
73 void (*pf_toggle)(GtkCheckMenuItem *, gpointer) );
74 static gint GnomeTitleMenu ( gpointer, GtkWidget *,
75 void (*pf_toggle)(GtkCheckMenuItem *, gpointer) );
76 static gint GnomeSetupMenu ( intf_thread_t * p_intf );
77 static void GnomeDisplayDate ( GtkAdjustment *p_adj );
78 static gint GnomeDVDModeManage( intf_thread_t * p_intf );
79 static gint GnomeFileModeManage( intf_thread_t * p_intf );
80 static gint GnomeNetworkModeManage( intf_thread_t * p_intf );
82 /*****************************************************************************
83 * g_atexit: kludge to avoid the Gnome thread to segfault at exit
84 *****************************************************************************
85 * gtk_init() makes several calls to g_atexit() which calls atexit() to
86 * register tidying callbacks to be called at program exit. Since the Gnome
87 * plugin is likely to be unloaded at program exit, we have to export this
88 * symbol to intercept the g_atexit() calls. Talk about crude hack.
89 *****************************************************************************/
90 void g_atexit( GVoidFunc func )
92 intf_thread_t *p_intf = p_main->p_intf;
94 if( p_intf->p_sys->pf_gdk_callback == NULL )
96 p_intf->p_sys->pf_gdk_callback = func;
98 else if( p_intf->p_sys->pf_gtk_callback == NULL )
100 p_intf->p_sys->pf_gtk_callback = func;
102 /* else nothing, but we could do something here */
106 /*****************************************************************************
107 * Functions exported as capabilities. They are declared as static so that
108 * we don't pollute the namespace too much.
109 *****************************************************************************/
110 void _M( intf_getfunctions )( function_list_t * p_function_list )
112 p_function_list->pf_probe = intf_Probe;
113 p_function_list->functions.intf.pf_open = intf_Open;
114 p_function_list->functions.intf.pf_close = intf_Close;
115 p_function_list->functions.intf.pf_run = intf_Run;
118 /*****************************************************************************
119 * intf_Probe: probe the interface and return a score
120 *****************************************************************************
121 * This function tries to initialize Gnome and returns a score to the
122 * plugin manager so that it can select the best plugin.
123 *****************************************************************************/
124 static int intf_Probe( probedata_t *p_data )
126 if( TestMethod( INTF_METHOD_VAR, "gnome" ) )
131 if( TestProgram( "gnome-vlc" ) )
139 /*****************************************************************************
140 * intf_Open: initialize and create window
141 *****************************************************************************/
142 static int intf_Open( intf_thread_t *p_intf )
144 /* Allocate instance and initialize some members */
145 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
146 if( p_intf->p_sys == NULL )
148 intf_ErrMsg("error: %s", strerror(ENOMEM));
152 /* Initialize Gnome thread */
153 p_intf->p_sys->b_popup_changed = 0;
154 p_intf->p_sys->b_window_changed = 0;
155 p_intf->p_sys->b_playlist_changed = 0;
156 p_intf->p_sys->b_menus_update = 1;
158 p_intf->p_sys->b_slider_free = 1;
160 p_intf->p_sys->b_mode_changed = 1;
161 p_intf->p_sys->i_intf_mode = FILE_MODE;
163 p_intf->p_sys->i_part = 0;
165 p_intf->p_sys->pf_gtk_callback = NULL;
166 p_intf->p_sys->pf_gdk_callback = NULL;
171 /*****************************************************************************
172 * intf_Close: destroy interface window
173 *****************************************************************************/
174 static void intf_Close( intf_thread_t *p_intf )
176 /* Destroy structure */
177 free( p_intf->p_sys );
180 /*****************************************************************************
181 * intf_Run: Gnome thread
182 *****************************************************************************
183 * this part of the interface is in a separate thread so that we can call
184 * gtk_main() from within it without annoying the rest of the program.
185 * XXX: the approach may look kludgy, and probably is, but I could not find
186 * a better way to dynamically load a Gnome interface at runtime.
187 *****************************************************************************/
188 static void intf_Run( intf_thread_t *p_intf )
190 /* gnome_init needs to know the command line. We don't care, so we
191 * give it an empty one */
192 char *p_args[] = { "" };
195 /* The data types we are allowed to receive */
196 static GtkTargetEntry target_table[] =
198 { "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST },
199 { "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
202 /* intf_Manage callback timeout */
205 /* Initialize Gnome */
206 gnome_init( p_main->psz_arg0, VERSION, i_args, p_args );
208 /* Create some useful widgets that will certainly be used */
209 p_intf->p_sys->p_window = create_intf_window( );
210 p_intf->p_sys->p_popup = create_intf_popup( );
211 p_intf->p_sys->p_disc = create_intf_disc( );
212 p_intf->p_sys->p_network = create_intf_network( );
214 /* Set the title of the main window */
215 gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
216 VOUT_TITLE " (Gnome interface)");
218 /* Accept file drops on the main window */
219 gtk_drag_dest_set( GTK_WIDGET( p_intf->p_sys->p_window ),
220 GTK_DEST_DEFAULT_ALL, target_table,
221 1, GDK_ACTION_COPY );
223 /* Get the interface labels */
224 #define P_LABEL( name ) GTK_LABEL( gtk_object_get_data( \
225 GTK_OBJECT( p_intf->p_sys->p_window ), name ) )
226 p_intf->p_sys->p_label_date = P_LABEL( "label_date" );
227 p_intf->p_sys->p_label_status = P_LABEL( "label_status" );
228 p_intf->p_sys->p_label_title = P_LABEL( "label_title" );
229 p_intf->p_sys->p_label_chapter = P_LABEL( "label_chapter" );
232 /* Connect the date display to the slider */
233 #define P_SLIDER GTK_RANGE( gtk_object_get_data( \
234 GTK_OBJECT( p_intf->p_sys->p_window ), "slider" ) )
235 p_intf->p_sys->p_adj = gtk_range_get_adjustment( P_SLIDER );
237 gtk_signal_connect ( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed",
238 GTK_SIGNAL_FUNC( GnomeDisplayDate ), NULL );
239 p_intf->p_sys->f_adj_oldvalue = 0;
242 /* We don't create these ones yet because we perhaps won't need them */
243 p_intf->p_sys->p_about = NULL;
244 p_intf->p_sys->p_playlist = NULL;
245 p_intf->p_sys->p_modules = NULL;
246 p_intf->p_sys->p_fileopen = NULL;
248 /* Store p_intf to keep an eye on it */
249 gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
252 gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_popup),
255 gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_disc),
258 gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_network),
261 gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_adj),
264 /* Show the control window */
265 gtk_widget_show( p_intf->p_sys->p_window );
267 /* Sleep to avoid using all CPU - since some interfaces needs to access
268 * keyboard events, a 100ms delay is a good compromise */
269 i_timeout = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, GnomeManage, p_intf );
271 /* Enter gnome mode */
274 /* Remove the timeout */
275 gtk_timeout_remove( i_timeout );
277 /* Get rid of stored callbacks so we can unload the plugin */
278 if( p_intf->p_sys->pf_gtk_callback != NULL )
280 p_intf->p_sys->pf_gtk_callback( );
281 p_intf->p_sys->pf_gtk_callback = NULL;
285 if( p_intf->p_sys->pf_gdk_callback != NULL )
287 p_intf->p_sys->pf_gdk_callback( );
288 p_intf->p_sys->pf_gdk_callback = NULL;
292 /* following functions are local */
294 /*****************************************************************************
295 * GnomeManage: manage main thread messages
296 *****************************************************************************
297 * In this function, called approx. 10 times a second, we check what the
298 * main program wanted to tell us.
299 *****************************************************************************/
300 static gint GnomeManage( gpointer p_data )
302 #define p_intf ((intf_thread_t *)p_data)
304 vlc_mutex_lock( &p_intf->change_lock );
306 /* If the "display popup" flag has changed */
307 if( p_intf->b_menu_change )
309 gnome_popup_menu_do_popup( p_intf->p_sys->p_popup,
310 NULL, NULL, NULL, NULL );
311 p_intf->b_menu_change = 0;
314 if( p_intf->p_sys->b_mode_changed )
316 /* Sets the interface mode according to playlist item */
317 if( p_main->p_playlist->p_item != NULL )
319 if( !strncmp( p_main->p_playlist->p_item->psz_name, "dvd:", 4 ) )
321 p_intf->p_sys->i_intf_mode = DVD_MODE;
324 p_main->p_playlist->p_item->psz_name, "ts:", 4 ) )
326 p_intf->p_sys->i_intf_mode = NET_MODE;
330 switch( p_intf->p_sys->i_intf_mode )
333 GnomeDVDModeManage( p_intf );
336 GnomeNetworkModeManage( p_intf );
340 GnomeFileModeManage( p_intf );
344 p_intf->p_sys->b_mode_changed = 0;
348 if( p_intf->p_input != NULL )
354 if( p_intf->p_input->stream.b_changed )
356 p_intf->p_sys->b_menus_update = 1;
357 p_intf->p_input->stream.b_changed = 0;
358 fprintf( stderr, "########changed interface##########\n" );
361 #define p_area p_intf->p_input->stream.p_selected_area
362 /* Update language/chapter menus after user request */
363 if( ( p_intf->p_sys->b_menus_update ) ||
364 ( p_intf->p_sys->i_part != p_area->i_part ) )
366 p_intf->p_sys->b_menus_update = 1;
367 GnomeSetupMenu( p_intf );
368 p_intf->p_sys->b_menus_update = 0;
370 snprintf( psz_title, 3, "%02d", p_area->i_id );
371 gtk_label_set_text( p_intf->p_sys->p_label_title, psz_title );
373 p_intf->p_sys->i_part = p_area->i_part;
374 snprintf( psz_chapter, 3, "%02d", p_area->i_part );
375 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
378 /* Manage the slider */
379 newvalue = p_intf->p_sys->p_adj->value;
381 /* If the user hasn't touched the slider since the last time,
382 * then the input can safely change it */
383 if( newvalue == p_intf->p_sys->f_adj_oldvalue )
385 /* Update the value */
386 p_intf->p_sys->p_adj->value = p_intf->p_sys->f_adj_oldvalue =
387 ( 100. * p_area->i_tell ) / p_area->i_size;
389 gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),
392 /* Otherwise, send message to the input if the user has
393 * finished dragging the slider */
394 else if( p_intf->p_sys->b_slider_free )
396 off_t i_seek = ( newvalue * p_area->i_size ) / 100;
398 input_Seek( p_intf->p_input, i_seek );
400 /* Update the old value */
401 p_intf->p_sys->f_adj_oldvalue = newvalue;
406 /* Manage core vlc functions through the callback */
407 p_intf->pf_manage( p_intf );
411 vlc_mutex_unlock( &p_intf->change_lock );
413 /* Prepare to die, young Skywalker */
420 vlc_mutex_unlock( &p_intf->change_lock );
427 /*****************************************************************************
428 * GnomeLanguageMenus: update interactive menus of the interface
429 *****************************************************************************
430 * Sets up menus with information from input:
433 * Warning: since this function is designed to be called by management
434 * function, the interface lock has to be taken
435 *****************************************************************************/
436 static gint GnomeLanguageMenus( gpointer p_data,
438 es_descriptor_t * p_es,
440 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
442 intf_thread_t * p_intf;
444 GtkWidget * p_separator;
446 GtkWidget * p_item_active;
455 p_intf = (intf_thread_t *)p_data;
457 /* removes previous menu */
458 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
459 gtk_widget_set_sensitive( p_root, FALSE );
464 p_menu = gtk_menu_new();
466 /* special case for "off" item */
469 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
470 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
472 gtk_widget_show( p_item );
474 /* signal hanling for off */
475 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
476 GTK_SIGNAL_FUNC ( pf_toggle ), NULL );
478 gtk_menu_append( GTK_MENU( p_menu ), p_item );
480 p_separator = gtk_menu_item_new();
481 gtk_widget_set_sensitive( p_separator, FALSE );
482 gtk_widget_show( p_separator );
483 gtk_menu_append( GTK_MENU( p_menu ), p_separator );
485 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
486 p_item_active = NULL;
489 /* create a set of language buttons and append them to the container */
490 for( i = 0 ; i < p_intf->p_input->stream.i_es_number ; i++ )
492 if( p_intf->p_input->stream.pp_es[i]->i_cat == i_cat )
495 psz_name = p_intf->p_input->stream.pp_es[i]->psz_desc;
496 if( psz_name[0] == '\0' )
498 sprintf( psz_name, "Language %d", i_item );
501 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
503 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
505 if( p_es == p_intf->p_input->stream.pp_es[i] )
507 /* don't lose p_item when we append into menu */
508 p_item_active = p_item;
511 gtk_widget_show( p_item );
513 /* setup signal hanling */
514 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
515 GTK_SIGNAL_FUNC( pf_toggle ),
516 (gpointer)( p_intf->p_input->stream.pp_es[i] ) );
518 gtk_menu_append( GTK_MENU( p_menu ), p_item );
522 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
524 /* link the new menu to the menubar item */
525 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
527 /* acitvation will call signals so we can only do it
528 * when submenu is attached to menu - to get intf_window */
529 if( p_item_active != NULL )
531 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
535 /* be sure that menu is sensitive if non empty */
538 gtk_widget_set_sensitive( p_root, TRUE );
544 /*****************************************************************************
545 * GnomeChapterMenu: generate chapter menu for current title
546 *****************************************************************************/
547 static gint GnomeChapterMenu( gpointer p_data, GtkWidget * p_chapter,
548 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
550 intf_thread_t * p_intf;
552 GtkWidget * p_chapter_menu;
553 GtkWidget * p_chapter_submenu;
554 GtkWidget * p_menu_item;
556 GtkWidget * p_item_selected;
557 GSList * p_chapter_group;
563 p_intf = (intf_thread_t*)p_data;
565 /* removes previous menu */
566 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_chapter ) );
567 gtk_widget_set_sensitive( p_chapter, FALSE );
569 p_chapter_submenu = NULL;
570 p_chapter_group = NULL;
571 p_item_selected = NULL;
574 i_title = p_intf->p_input->stream.p_selected_area->i_id;
575 p_chapter_menu = gtk_menu_new();
576 i_nb = p_intf->p_input->stream.pp_areas[i_title]->i_part_nb;
578 for( i_chapter = 0 ; i_chapter < i_nb ; i_chapter++ )
580 /* we group chapters in packets of ten for small screens */
581 if( ( i_chapter % 10 == 0 ) && ( i_nb > 20 ) )
585 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_menu_item ),
587 gtk_menu_append( GTK_MENU( p_chapter_menu ), p_menu_item );
590 sprintf( psz_name, "%d - %d", i_chapter + 1, i_chapter + 10);
591 p_menu_item = gtk_menu_item_new_with_label( psz_name );
592 gtk_widget_show( p_menu_item );
593 p_chapter_submenu = gtk_menu_new();
596 sprintf( psz_name, "Chapter %d", i_chapter + 1 );
598 p_item = gtk_radio_menu_item_new_with_label( p_chapter_group,
601 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
603 if( p_intf->p_input->stream.pp_areas[i_title]->i_part
606 p_item_selected = p_item;
609 gtk_widget_show( p_item );
611 /* setup signal hanling */
612 gtk_signal_connect( GTK_OBJECT( p_item ),
614 GTK_SIGNAL_FUNC( pf_toggle ),
615 (gpointer)(i_chapter + 1) );
619 gtk_menu_append( GTK_MENU( p_chapter_submenu ), p_item );
623 gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );
629 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_menu_item ),
631 gtk_menu_append( GTK_MENU( p_chapter_menu ), p_menu_item );
634 /* link the new menu to the title menu item */
635 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter ),
638 /* toggle currently selected chapter */
639 if( p_item_selected != NULL )
641 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_selected ),
645 /* be sure that chapter menu is sensitive, if there are several items */
646 if( p_intf->p_input->stream.pp_areas[i_title]->i_part_nb > 1 )
648 gtk_widget_set_sensitive( p_chapter, TRUE );
654 /*****************************************************************************
655 * GnomeTitleMenu: sets menus for titles and chapters selection
656 *****************************************************************************
657 * Generates two types of menus:
658 * -simple list of titles
659 * -cascaded lists of chapters for each title
660 *****************************************************************************/
661 static gint GnomeTitleMenu( gpointer p_data,
662 GtkWidget * p_navigation,
663 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
665 intf_thread_t * p_intf;
667 GtkWidget * p_title_menu;
668 GtkWidget * p_title_submenu;
669 GtkWidget * p_title_item;
670 GtkWidget * p_item_active;
671 GtkWidget * p_chapter_menu;
672 GtkWidget * p_chapter_submenu;
673 GtkWidget * p_title_menu_item;
674 GtkWidget * p_chapter_menu_item;
676 GSList * p_title_group;
677 GSList * p_chapter_group;
684 p_intf = (intf_thread_t*)p_data;
686 p_title_menu = gtk_menu_new();
687 p_title_group = NULL;
688 p_title_submenu = NULL;
689 p_title_menu_item = NULL;
690 p_chapter_group = NULL;
691 p_chapter_submenu = NULL;
692 p_chapter_menu_item = NULL;
693 p_item_active = NULL;
694 i_title_nb = p_intf->p_input->stream.i_area_nb;
697 for( i_title = 1 ; i_title < i_title_nb ; i_title++ )
699 /* we group titles in packets of ten for small screens */
700 if( ( i_title % 10 == 1 ) && ( i_title_nb > 20 ) )
704 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),
706 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );
709 sprintf( psz_name, "%d - %d", i_title, i_title + 9 );
710 p_title_menu_item = gtk_menu_item_new_with_label( psz_name );
711 gtk_widget_show( p_title_menu_item );
712 p_title_submenu = gtk_menu_new();
715 sprintf( psz_name, "Title %d", i_title );
717 if( pf_toggle == on_menubar_title_toggle )
719 p_title_item = gtk_radio_menu_item_new_with_label( p_title_group,
722 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_title_item ) );
724 if( p_intf->p_input->stream.pp_areas[i_title] ==
725 p_intf->p_input->stream.p_selected_area )
727 p_item_active = p_title_item;
730 /* setup signal hanling */
731 gtk_signal_connect( GTK_OBJECT( p_title_item ),
733 GTK_SIGNAL_FUNC( pf_toggle ),
734 (gpointer)(p_intf->p_input->stream.pp_areas[i_title]) );
736 if( p_intf->p_input->stream.i_area_nb > 1 )
738 /* be sure that menu is sensitive */
739 gtk_widget_set_sensitive( p_navigation, TRUE );
745 p_title_item = gtk_menu_item_new_with_label( psz_name );
746 p_chapter_menu = gtk_menu_new();
748 p_intf->p_input->stream.pp_areas[i_title]->i_part_nb;
750 for( i_chapter = 0 ; i_chapter < i_chapter_nb ; i_chapter++ )
752 /* we group chapters in packets of ten for small screens */
753 if( ( i_chapter % 10 == 0 ) && ( i_chapter_nb > 20 ) )
757 gtk_menu_item_set_submenu(
758 GTK_MENU_ITEM( p_chapter_menu_item ),
760 gtk_menu_append( GTK_MENU( p_chapter_menu ),
761 p_chapter_menu_item );
764 sprintf( psz_name, "%d - %d", i_chapter + 1,
766 p_chapter_menu_item =
767 gtk_menu_item_new_with_label( psz_name );
768 gtk_widget_show( p_chapter_menu_item );
769 p_chapter_submenu = gtk_menu_new();
772 sprintf( psz_name, "Chapter %d", i_chapter + 1 );
774 p_item = gtk_radio_menu_item_new_with_label(
775 p_chapter_group, psz_name );
776 p_chapter_group = gtk_radio_menu_item_group(
777 GTK_RADIO_MENU_ITEM( p_item ) );
778 gtk_widget_show( p_item );
780 #define p_area p_intf->p_input->stream.pp_areas[i_title]
781 if( ( p_area == p_intf->p_input->stream.p_selected_area ) &&
782 ( p_area->i_part == i_chapter + 1 ) )
784 p_item_active = p_item;
788 /* setup signal hanling */
789 gtk_signal_connect( GTK_OBJECT( p_item ),
791 GTK_SIGNAL_FUNC( pf_toggle ),
792 (gpointer)( ( i_title * 100 ) + ( i_chapter + 1) ) );
794 if( i_chapter_nb > 20 )
796 gtk_menu_append( GTK_MENU( p_chapter_submenu ), p_item );
800 gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );
804 if( i_chapter_nb > 20 )
806 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter_menu_item ),
808 gtk_menu_append( GTK_MENU( p_chapter_menu ),
809 p_chapter_menu_item );
812 /* link the new menu to the title menu item */
813 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),
816 if( p_intf->p_input->stream.pp_areas[i_title]->i_part_nb > 1 )
818 /* be sure that menu is sensitive */
819 gtk_widget_set_sensitive( p_navigation, TRUE );
822 gtk_widget_show( p_title_item );
824 if( i_title_nb > 20 )
826 gtk_menu_append( GTK_MENU( p_title_submenu ), p_title_item );
830 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_item );
834 if( i_title_nb > 20 )
836 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),
838 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );
841 /* be sure that menu is sensitive */
842 gtk_widget_set_sensitive( p_title_menu, TRUE );
844 /* link the new menu to the menubar item */
845 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );
847 if( p_item_active != NULL )
849 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
857 /*****************************************************************************
858 * GnomeSetupMenu: function that generates title/chapter/audio/subpic
859 * menus with help from preceding functions
860 *****************************************************************************/
861 static gint GnomeSetupMenu( intf_thread_t * p_intf )
863 es_descriptor_t * p_audio_es;
864 es_descriptor_t * p_spu_es;
865 GtkWidget * p_menubar_menu;
866 GtkWidget * p_popup_menu;
869 if( p_intf->p_input->stream.i_area_nb > 1 )
871 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
872 p_intf->p_sys->p_window ), "menubar_title" ) );
873 GnomeTitleMenu( p_intf, p_menubar_menu, on_menubar_title_toggle );
875 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
876 p_intf->p_sys->p_popup ), "popup_navigation" ) );
877 GnomeTitleMenu( p_intf, p_popup_menu, on_popup_navigation_toggle );
879 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
880 p_intf->p_sys->p_window ), "menubar_chapter" ) );
881 GnomeChapterMenu( p_intf, p_menubar_menu, on_menubar_chapter_toggle );
884 /* look for selected ES */
888 for( i = 0 ; i < p_intf->p_input->stream.i_selected_es_number ; i++ )
890 if( p_intf->p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES )
892 p_audio_es = p_intf->p_input->stream.pp_selected_es[i];
895 if( p_intf->p_input->stream.pp_selected_es[i]->i_cat == SPU_ES )
897 p_spu_es = p_intf->p_input->stream.pp_selected_es[i];
903 /* find audio root menu */
904 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
905 p_intf->p_sys->p_window ), "menubar_audio" ) );
907 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
908 p_intf->p_sys->p_popup ), "popup_audio" ) );
910 GnomeLanguageMenus( p_intf, p_menubar_menu, p_audio_es, AUDIO_ES,
911 on_menubar_audio_toggle );
912 GnomeLanguageMenus( p_intf, p_popup_menu, p_audio_es, AUDIO_ES,
913 on_popup_audio_toggle );
915 /* sub picture menus */
917 /* find spu root menu */
918 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
919 p_intf->p_sys->p_window ), "menubar_subtitle" ) );
921 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
922 p_intf->p_sys->p_popup ), "popup_subtitle" ) );
924 GnomeLanguageMenus( p_intf, p_menubar_menu, p_spu_es, SPU_ES,
925 on_menubar_subtitle_toggle );
926 GnomeLanguageMenus( p_intf, p_popup_menu, p_spu_es, SPU_ES,
927 on_popup_subtitle_toggle );
932 /*****************************************************************************
933 * GnomeDisplayDate: display stream date
934 *****************************************************************************
935 * This function displays the current date related to the position in
936 * the stream. It is called whenever the slider changes its value.
937 *****************************************************************************/
938 void GnomeDisplayDate( GtkAdjustment *p_adj )
940 intf_thread_t *p_intf;
942 p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
944 if( p_intf->p_input != NULL )
946 #define p_area p_intf->p_input->stream.p_selected_area
947 char psz_time[ OFFSETTOTIME_MAX_SIZE ];
949 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
951 gtk_label_set_text( p_intf->p_sys->p_label_date,
952 input_OffsetToTime( p_intf->p_input, psz_time,
953 ( p_area->i_size * p_adj->value ) / 100 ) );
955 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
961 /*****************************************************************************
963 *****************************************************************************/
964 static gint GnomeDVDModeManage( intf_thread_t * p_intf )
966 GtkWidget * p_dvd_box;
967 GtkWidget * p_file_box;
968 GtkWidget * p_network_box;
970 p_file_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
971 p_intf->p_sys->p_window ), "file_box" ) );
972 gtk_widget_hide( GTK_WIDGET( p_file_box ) );
974 p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
975 p_intf->p_sys->p_window ), "network_box" ) );
976 gtk_widget_hide( GTK_WIDGET( p_network_box ) );
978 p_dvd_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
979 p_intf->p_sys->p_window ), "dvd_box" ) );
980 gtk_widget_show( GTK_WIDGET( p_dvd_box ) );
982 gtk_label_set_text( p_intf->p_sys->p_label_status,
983 "Status: playing DVD" );
988 /*****************************************************************************
989 * GnomeFileModeManage
990 *****************************************************************************/
991 static gint GnomeFileModeManage( intf_thread_t * p_intf )
993 GtkWidget * p_dvd_box;
994 GtkWidget * p_file_box;
995 GtkWidget * p_network_box;
997 p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
998 p_intf->p_sys->p_window ), "network_box" ) );
999 gtk_widget_hide( GTK_WIDGET( p_network_box ) );
1001 p_dvd_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1002 p_intf->p_sys->p_window ), "dvd_box" ) );
1003 gtk_widget_hide( GTK_WIDGET( p_dvd_box ) );
1005 p_file_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1006 p_intf->p_sys->p_window ), "file_box" ) );
1007 gtk_widget_show( GTK_WIDGET( p_file_box ) );
1009 gtk_label_set_text( p_intf->p_sys->p_label_status,
1015 /*****************************************************************************
1016 * GnomeNetworkModeManage
1017 *****************************************************************************/
1018 static gint GnomeNetworkModeManage( intf_thread_t * p_intf )
1020 GtkWidget * p_dvd_box;
1021 GtkWidget * p_file_box;
1022 GtkWidget * p_network_box;
1024 p_dvd_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1025 p_intf->p_sys->p_window ), "dvd_box" ) );
1026 gtk_widget_hide( GTK_WIDGET( p_dvd_box ) );
1028 p_file_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1029 p_intf->p_sys->p_window ), "file_box" ) );
1030 gtk_widget_hide( GTK_WIDGET( p_file_box ) );
1032 p_network_box = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1033 p_intf->p_sys->p_window ), "network_box" ) );
1034 gtk_widget_show( GTK_WIDGET( p_network_box ) );
1036 gtk_label_set_text( p_intf->p_sys->p_label_status,
1037 "Status: waiting for stream" );