1 /*****************************************************************************
2 * menu.c : functions to handle menu items.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: menu.c,v 1.9 2003/05/04 22:42:15 gbazin Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Stéphane Borel <stef@via.ecp.fr>
9 * Johan Bilien <jobi@via.ecp.fr>
10 * Laurent Aimar <fenrir@via.ecp.fr>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
30 #include <sys/types.h> /* off_t */
38 #ifdef MODULE_NAME_IS_gnome
46 #include "gtk_callbacks.h"
47 #include "gtk_interface.h"
48 #include "gtk_support.h"
56 static gint GtkLanguageMenus( gpointer , GtkWidget *, es_descriptor_t *, gint,
57 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) );
59 void GtkMenubarAudioToggle ( GtkCheckMenuItem *, gpointer );
60 void GtkPopupAudioToggle ( GtkCheckMenuItem *, gpointer );
61 void GtkMenubarSubtitleToggle( GtkCheckMenuItem *, gpointer );
62 void GtkPopupSubtitleToggle ( GtkCheckMenuItem *, gpointer );
63 static gint GtkTitleMenu( gpointer, GtkWidget *,
64 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) );
65 static gint GtkRadioMenu( intf_thread_t *, GtkWidget *, GSList *,
66 char *, int, int, int,
67 void( *pf_toggle )( GtkCheckMenuItem *, gpointer ) );
69 static void GtkMenubarDeinterlaceToggle( GtkCheckMenuItem * menuitem, gpointer user_data );
70 static void GtkPopupDeinterlaceToggle( GtkCheckMenuItem * menuitem, gpointer user_data );
71 static gint GtkDeinterlaceMenus( gpointer p_data,
73 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) );
75 gint GtkSetupMenus( intf_thread_t * p_intf );
77 /****************************************************************************
78 * Gtk*Toggle: callbacks to toggle the value of a checkmenuitem
79 ****************************************************************************
80 * We need separate functions for menubar and popup here since we can't use
81 * user_data to transmit intf_* and we need to refresh the other menu.
82 ****************************************************************************/
84 #define GTKLANGTOGGLE( window, menu, type, callback, b_update ) \
85 intf_thread_t * p_intf; \
87 es_descriptor_t * p_es; \
89 p_intf = GtkGetIntf( menuitem ); \
91 if( !p_intf->p_sys->b_update ) \
93 p_menu = GTK_WIDGET( gtk_object_get_data( \
94 GTK_OBJECT( p_intf->p_sys->window ), (menu) ) ); \
95 p_es = (es_descriptor_t*)user_data; \
97 input_ToggleES( p_intf->p_sys->p_input, \
98 p_es, menuitem->active ); \
100 p_intf->p_sys->b_update = menuitem->active; \
102 if( p_intf->p_sys->b_update ) \
104 GtkLanguageMenus( p_intf, p_menu, p_es, type, callback ); \
107 p_intf->p_sys->b_update = VLC_FALSE; \
114 void GtkMenubarAudioToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
116 GTKLANGTOGGLE( p_popup, "popup_language", AUDIO_ES,
117 GtkPopupAudioToggle, b_audio_update );
120 void GtkPopupAudioToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
122 GTKLANGTOGGLE( p_window, "menubar_audio", AUDIO_ES,
123 GtkMenubarAudioToggle, b_audio_update );
130 void GtkMenubarSubtitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
132 GTKLANGTOGGLE( p_popup, "popup_subpictures", SPU_ES,
133 GtkPopupSubtitleToggle, b_spu_update );
136 void GtkPopupSubtitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
138 GTKLANGTOGGLE( p_window, "menubar_subpictures", SPU_ES,
139 GtkMenubarSubtitleToggle, b_spu_update );
148 void GtkPopupNavigationToggle( GtkCheckMenuItem * menuitem,
151 intf_thread_t * p_intf = GtkGetIntf( menuitem );
153 if( menuitem->active &&
154 !p_intf->p_sys->b_title_update &&
155 !p_intf->p_sys->b_chapter_update )
157 input_area_t *p_area;
159 guint i_title = DATA2TITLE( user_data );
160 guint i_chapter = DATA2CHAPTER( user_data );
162 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
163 p_area = p_intf->p_sys->p_input->stream.p_selected_area;
165 i_title = __MIN( i_title,
166 p_intf->p_sys->p_input->stream.i_area_nb - 1 );
167 i_title = __MAX( i_title, 1 );
169 if( p_area != p_intf->p_sys->p_input->stream.pp_areas[i_title] )
171 p_area = p_intf->p_sys->p_input->stream.pp_areas[i_title];
172 p_intf->p_sys->b_title_update = VLC_TRUE;
175 i_chapter = __MIN( i_chapter, p_area->i_part_nb - 1 );
176 i_chapter = __MAX( i_chapter, 1 );
177 p_area->i_part = i_chapter;
179 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
181 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
183 p_intf->p_sys->b_chapter_update = VLC_TRUE;
184 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
185 GtkSetupMenus( p_intf );
186 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
188 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
195 #define GTKPROGRAMTOGGLE( ) \
196 intf_thread_t * p_intf = GtkGetIntf( menuitem ); \
198 if( menuitem->active && !p_intf->p_sys->b_program_update ) \
200 int i_program_id = (ptrdiff_t)user_data; \
202 input_ChangeProgram( p_intf->p_sys->p_input, i_program_id ); \
204 p_intf->p_sys->b_program_update = VLC_TRUE; \
206 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); \
207 GtkSetupMenus( p_intf ); \
208 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); \
210 p_intf->p_sys->b_program_update = VLC_FALSE; \
212 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); \
215 void GtkMenubarProgramToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
220 void GtkPopupProgramToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
229 void GtkMenubarTitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
231 intf_thread_t * p_intf = GtkGetIntf( menuitem );
233 if( menuitem->active && !p_intf->p_sys->b_title_update )
235 guint i_title = (ptrdiff_t)user_data;
237 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
238 i_title = __MIN( i_title,
239 p_intf->p_sys->p_input->stream.i_area_nb - 1 );
240 i_title = __MAX( i_title, 1 );
241 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
243 input_ChangeArea( p_intf->p_sys->p_input,
244 p_intf->p_sys->p_input->stream.pp_areas[i_title] );
246 p_intf->p_sys->b_title_update = VLC_TRUE;
247 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
248 GtkSetupMenus( p_intf );
249 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
250 p_intf->p_sys->b_title_update = VLC_FALSE;
252 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
260 void GtkMenubarChapterToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
262 intf_thread_t * p_intf;
263 input_area_t * p_area;
265 GtkWidget * p_popup_menu;
267 p_intf = GtkGetIntf( menuitem );
268 p_area = p_intf->p_sys->p_input->stream.p_selected_area;
269 i_chapter = (ptrdiff_t)user_data;
271 if( menuitem->active && !p_intf->p_sys->b_chapter_update )
273 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
274 i_chapter = __MIN( i_chapter, p_area->i_part_nb - 1 );
275 i_chapter = __MAX( i_chapter, 1 );
276 p_area->i_part = i_chapter;
277 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
279 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
281 p_intf->p_sys->b_chapter_update = VLC_TRUE;
282 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
283 p_intf->p_sys->p_popup ), "popup_navigation" ) );
285 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
286 GtkTitleMenu( p_intf, p_popup_menu, GtkPopupNavigationToggle );
287 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
289 p_intf->p_sys->b_chapter_update = VLC_FALSE;
291 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
296 static void GtkPopupObjectToggle( GtkCheckMenuItem * menuitem,
297 gpointer user_data, int i_object_type, char *psz_variable )
299 intf_thread_t *p_intf = GtkGetIntf( menuitem );
302 p_label = GTK_LABEL( ( GTK_BIN( menuitem )->child ) );
304 if( menuitem->active && !p_intf->p_sys->b_aout_update &&
305 !p_intf->p_sys->b_vout_update )
307 vlc_object_t * p_obj;
309 p_obj = (vlc_object_t *)vlc_object_find( p_intf, i_object_type,
317 val = (vlc_value_t)user_data;
321 gtk_label_get( p_label, &val.psz_string );
324 if( var_Set( p_obj, psz_variable, val ) < 0 )
326 msg_Warn( p_obj, "cannot set variable (%s)", val.psz_string );
328 vlc_object_release( p_obj );
332 static void GtkPopupAoutChannelsToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
334 GtkPopupObjectToggle( menuitem, user_data, VLC_OBJECT_AOUT, "audio-channels" );
337 static void GtkPopupAoutDeviceToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
339 GtkPopupObjectToggle( menuitem, user_data, VLC_OBJECT_AOUT, "audio-device" );
343 static void GtkPopupVoutDeviceToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
345 GtkPopupObjectToggle( menuitem, user_data, VLC_OBJECT_VOUT, "video-device" );
349 static void GtkDeinterlaceUpdate( intf_thread_t *p_intf, char *psz_mode )
354 psz_filter = config_GetPsz( p_intf, "filter" );
356 if( !strcmp( psz_mode, "None" ) )
358 config_PutPsz( p_intf, "filter", "" );
362 if( !psz_filter || !*psz_filter )
364 config_PutPsz( p_intf, "filter", "deinterlace" );
368 if( strstr( psz_filter, "deinterlace" ) == NULL )
370 psz_filter = realloc( psz_filter, strlen( psz_filter ) + 20 );
371 strcat( psz_filter, ",deinterlace" );
373 config_PutPsz( p_intf, "filter", psz_filter );
380 /* now restart all video stream */
381 if( p_intf->p_sys->p_input )
383 vout_thread_t *p_vout;
384 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
386 /* Warn the vout we are about to change the filter chain */
387 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
391 p_vout->b_filter_change = VLC_TRUE;
392 vlc_object_release( p_vout );
395 #define ES p_intf->p_sys->p_input->stream.pp_es[i]
396 /* create a set of language buttons and append them to the container */
397 for( i = 0 ; i < p_intf->p_sys->p_input->stream.i_es_number ; i++ )
399 if( ( ES->i_cat == VIDEO_ES ) &&
400 ES->p_decoder_fifo != NULL )
402 input_UnselectES( p_intf->p_sys->p_input, ES );
403 input_SelectES( p_intf->p_sys->p_input, ES );
407 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
410 if( strcmp( psz_mode, "None" ) )
412 vout_thread_t *p_vout;
413 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
419 val.psz_string = psz_mode;
420 if( var_Set( p_vout, "deinterlace-mode", val ) != VLC_SUCCESS )
421 config_PutPsz( p_intf, "deinterlace-mode", psz_mode );
423 vlc_object_release( p_vout );
426 config_PutPsz( p_intf, "deinterlace-mode", psz_mode );
431 static void GtkMenubarDeinterlaceToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
433 intf_thread_t *p_intf = GtkGetIntf( menuitem );
436 GtkWidget *p_popup_menu;
438 p_label = GTK_LABEL( ( GTK_BIN( menuitem )->child ) );
440 if( !p_intf->p_sys->b_deinterlace_update && menuitem->active )
442 gtk_label_get( p_label, &psz_mode );
443 GtkDeinterlaceUpdate( p_intf, psz_mode );
445 p_intf->p_sys->b_deinterlace_update = VLC_TRUE;
447 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
448 p_intf->p_sys->p_popup ), "popup_deinterlace" ) );
450 GtkDeinterlaceMenus( p_intf, p_popup_menu, GtkPopupDeinterlaceToggle );
452 p_intf->p_sys->b_deinterlace_update = VLC_FALSE;
457 static void GtkPopupDeinterlaceToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
459 intf_thread_t *p_intf = GtkGetIntf( menuitem );
462 GtkWidget *p_menubar_menu;
464 p_label = GTK_LABEL( ( GTK_BIN( menuitem )->child ) );
466 if( !p_intf->p_sys->b_deinterlace_update && menuitem->active )
468 gtk_label_get( p_label, &psz_mode );
469 GtkDeinterlaceUpdate( p_intf, psz_mode );
471 p_intf->p_sys->b_deinterlace_update = VLC_TRUE;
473 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
474 p_intf->p_sys->p_window ), "menubar_deinterlace" ) );
476 GtkDeinterlaceMenus( p_intf, p_menubar_menu, GtkMenubarDeinterlaceToggle );
478 p_intf->p_sys->b_deinterlace_update = VLC_FALSE;
482 /****************************************************************************
483 * Functions to generate menus
484 ****************************************************************************/
486 /*****************************************************************************
487 * GtkRadioMenu: update interactive menus of the interface
488 *****************************************************************************
489 * Sets up menus with information from input
490 * Warning: since this function is designed to be called by management
491 * function, the interface lock has to be taken
492 *****************************************************************************/
493 static gint GtkRadioMenu( intf_thread_t * p_intf,
494 GtkWidget * p_root, GSList * p_menu_group,
495 char * psz_item_name,
496 int i_start, int i_end, int i_selected,
497 void( *pf_toggle )( GtkCheckMenuItem *, gpointer ) )
499 char psz_name[ GTK_MENU_LABEL_SIZE ];
501 GtkWidget * p_submenu;
502 GtkWidget * p_item_group;
504 GtkWidget * p_item_selected;
508 /* temporary hack to avoid blank menu when an open menu is removed */
509 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
511 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
513 /* removes previous menu */
514 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
515 gtk_widget_set_sensitive( p_root, FALSE );
519 p_item_selected = NULL;
520 p_group = p_menu_group;
522 p_menu = gtk_menu_new();
523 gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf );
525 for( i_item = i_start ; i_item <= i_end ; i_item++ )
527 /* we group chapters in packets of ten for small screens */
528 if( ( i_item % 10 == i_start ) && ( i_end > i_start + 20 ) )
530 if( i_item != i_start )
532 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_item_group ),
534 gtk_menu_append( GTK_MENU( p_menu ), p_item_group );
537 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
538 "%ss %d to %d", psz_item_name, i_item, i_item + 9 );
539 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
540 p_item_group = gtk_menu_item_new_with_label( psz_name );
541 gtk_widget_show( p_item_group );
542 p_submenu = gtk_menu_new();
543 gtk_object_set_data( GTK_OBJECT( p_submenu ), "p_intf", p_intf );
546 snprintf( psz_name, GTK_MENU_LABEL_SIZE, "%s %d",
547 psz_item_name, i_item );
548 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
550 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
551 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
553 if( i_selected == i_item )
555 p_item_selected = p_item;
558 gtk_widget_show( p_item );
560 /* setup signal hanling */
561 gtk_signal_connect( GTK_OBJECT( p_item ),
563 GTK_SIGNAL_FUNC( pf_toggle ),
564 (gpointer)((long)(i_item)) );
566 if( i_end > i_start + 20 )
568 gtk_menu_append( GTK_MENU( p_submenu ), p_item );
572 gtk_menu_append( GTK_MENU( p_menu ), p_item );
576 if( i_end > i_start + 20 )
578 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_item_group ), p_submenu );
579 gtk_menu_append( GTK_MENU( p_menu ), p_item_group );
582 /* link the new menu to the title menu item */
583 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
585 /* toggle currently selected chapter
586 * We have to release the lock since input_ToggleES needs it */
587 if( p_item_selected != NULL )
589 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_selected ),
593 /* be sure that menu is sensitive, if there are several items */
594 if( i_end > i_start )
596 gtk_widget_set_sensitive( p_root, TRUE );
602 /*****************************************************************************
603 * GtkProgramMenu: update the programs menu of the interface
604 *****************************************************************************
605 * Builds the program menu according to what have been found in the PAT
606 * by the input. Usefull for multi-programs streams such as DVB ones.
607 *****************************************************************************/
608 static gint GtkProgramMenu( gpointer p_data,
610 pgrm_descriptor_t * p_pgrm,
611 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
613 intf_thread_t * p_intf;
616 GtkWidget * p_item_active;
618 char psz_name[ GTK_MENU_LABEL_SIZE ];
622 p_intf = (intf_thread_t *)p_data;
624 /* temporary hack to avoid blank menu when an open menu is removed */
625 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
627 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
629 /* removes previous menu */
630 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
631 gtk_widget_set_sensitive( p_root, FALSE );
636 p_menu = gtk_menu_new();
637 gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf );
639 p_item_active = NULL;
641 /* create a set of program buttons and append them to the container */
642 for( i = 0 ; i < p_intf->p_sys->p_input->stream.i_pgrm_number ; i++ )
644 snprintf( psz_name, GTK_MENU_LABEL_SIZE, "id %d",
645 p_intf->p_sys->p_input->stream.pp_programs[i]->i_number );
646 psz_name[GTK_MENU_LABEL_SIZE-1] = '\0';
648 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
650 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
652 if( p_pgrm == p_intf->p_sys->p_input->stream.pp_programs[i] )
654 /* don't lose p_item when we append into menu */
655 p_item_active = p_item;
658 gtk_widget_show( p_item );
660 /* setup signal hanling */
661 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
662 GTK_SIGNAL_FUNC( pf_toggle ),
663 (gpointer)(ptrdiff_t)( p_intf->p_sys->p_input->
664 stream.pp_programs[i]->i_number ) );
666 gtk_menu_append( GTK_MENU( p_menu ), p_item );
669 /* link the new menu to the menubar item */
670 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
672 /* activation will call signals so we can only do it
673 * when submenu is attached to menu - to get intf_window
674 * We have to release the lock since input_ToggleES needs it */
675 if( p_item_active != NULL )
677 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
681 /* be sure that menu is sensitive if more than 1 program */
682 if( p_intf->p_sys->p_input->stream.i_pgrm_number > 1 )
684 gtk_widget_set_sensitive( p_root, TRUE );
690 /*****************************************************************************
691 * GtkLanguageMenus: update interactive menus of the interface
692 *****************************************************************************
693 * Sets up menus with information from input:
696 * Warning: since this function is designed to be called by management
697 * function, the interface lock has to be taken
698 *****************************************************************************/
699 static gint GtkLanguageMenus( gpointer p_data,
701 es_descriptor_t * p_es,
703 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
705 intf_thread_t * p_intf;
707 GtkWidget * p_separator;
709 GtkWidget * p_item_active;
711 char psz_name[ GTK_MENU_LABEL_SIZE ];
715 p_intf = (intf_thread_t *)p_data;
717 /* temporary hack to avoid blank menu when an open menu is removed */
718 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
720 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
722 /* removes previous menu */
723 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
724 gtk_widget_set_sensitive( p_root, FALSE );
729 p_menu = gtk_menu_new();
730 gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf );
732 /* special case for "off" item */
733 snprintf( psz_name, GTK_MENU_LABEL_SIZE, _("None") );
734 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
736 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
737 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
739 gtk_widget_show( p_item );
741 /* signal hanling for off */
742 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
743 GTK_SIGNAL_FUNC ( pf_toggle ), NULL );
745 gtk_menu_append( GTK_MENU( p_menu ), p_item );
747 p_separator = gtk_menu_item_new();
748 gtk_widget_set_sensitive( p_separator, FALSE );
749 gtk_widget_show( p_separator );
750 gtk_menu_append( GTK_MENU( p_menu ), p_separator );
752 p_item_active = NULL;
755 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
757 #define ES p_intf->p_sys->p_input->stream.pp_es[i]
758 /* create a set of language buttons and append them to the container */
759 for( i = 0 ; i < p_intf->p_sys->p_input->stream.i_es_number ; i++ )
761 if( ( ES->i_cat == i_cat ) &&
764 p_intf->p_sys->p_input->stream.p_selected_program ) )
768 p_intf->p_sys->p_input->stream.pp_es[i]->psz_desc );
769 if( psz_name[0] == '\0' )
771 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
772 "Language %d", i_item );
773 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
776 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
778 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
780 if( p_es == p_intf->p_sys->p_input->stream.pp_es[i] )
782 /* don't lose p_item when we append into menu */
783 p_item_active = p_item;
786 gtk_widget_show( p_item );
788 /* setup signal hanling */
789 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
790 GTK_SIGNAL_FUNC( pf_toggle ),
791 (gpointer)( p_intf->p_sys->p_input->stream.pp_es[i] ) );
793 gtk_menu_append( GTK_MENU( p_menu ), p_item );
797 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
799 /* link the new menu to the menubar item */
800 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
802 /* acitvation will call signals so we can only do it
803 * when submenu is attached to menu - to get intf_window
804 * We have to release the lock since input_ToggleES needs it */
805 if( p_item_active != NULL )
807 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
811 /* be sure that menu is sensitive if non empty */
814 gtk_widget_set_sensitive( p_root, TRUE );
820 /*****************************************************************************
821 * GtkTitleMenu: sets menus for titles and chapters selection
822 *****************************************************************************
823 * Generates two types of menus:
824 * -simple list of titles
825 * -cascaded lists of chapters for each title
826 *****************************************************************************/
827 static gint GtkTitleMenu( gpointer p_data,
828 GtkWidget * p_navigation,
829 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
831 intf_thread_t * p_intf;
832 char psz_name[ GTK_MENU_LABEL_SIZE ];
833 GtkWidget * p_title_menu;
834 GtkWidget * p_title_submenu;
835 GtkWidget * p_title_item;
836 GtkWidget * p_item_active;
837 GtkWidget * p_chapter_menu;
838 GtkWidget * p_chapter_submenu;
839 GtkWidget * p_title_menu_item;
840 GtkWidget * p_chapter_menu_item;
842 GSList * p_title_group;
843 GSList * p_chapter_group;
850 p_intf = (intf_thread_t*)p_data;
852 /* temporary hack to avoid blank menu when an open menu is removed */
853 if( GTK_MENU_ITEM(p_navigation)->submenu != NULL )
855 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_navigation)->submenu ) );
857 /* removes previous menu */
858 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_navigation ) );
859 gtk_widget_set_sensitive( p_navigation, FALSE );
861 p_title_menu = gtk_menu_new();
862 p_title_group = NULL;
863 p_title_submenu = NULL;
864 p_title_menu_item = NULL;
865 p_chapter_group = NULL;
866 p_chapter_submenu = NULL;
867 p_chapter_menu_item = NULL;
868 p_item_active = NULL;
869 i_title_nb = p_intf->p_sys->p_input->stream.i_area_nb - 1;
871 gtk_object_set_data( GTK_OBJECT( p_title_menu ), "p_intf", p_intf );
874 for( i_title = 1 ; i_title <= i_title_nb ; i_title++ )
876 /* we group titles in packets of ten for small screens */
877 if( ( i_title % 10 == 1 ) && ( i_title_nb > 20 ) )
881 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),
883 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );
886 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
887 "%d - %d", i_title, i_title + 9 );
888 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
889 p_title_menu_item = gtk_menu_item_new_with_label( psz_name );
890 gtk_widget_show( p_title_menu_item );
891 p_title_submenu = gtk_menu_new();
892 gtk_object_set_data( GTK_OBJECT( p_title_submenu ),
896 snprintf( psz_name, GTK_MENU_LABEL_SIZE, _("Title %d (%d)"), i_title,
897 p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb - 1);
898 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
900 if( pf_toggle == on_menubar_title_toggle )
902 p_title_item = gtk_radio_menu_item_new_with_label( p_title_group,
905 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_title_item ) );
907 if( p_intf->p_sys->p_input->stream.pp_areas[i_title] ==
908 p_intf->p_sys->p_input->stream.p_selected_area )
910 p_item_active = p_title_item;
913 /* setup signal hanling */
914 gtk_signal_connect( GTK_OBJECT( p_title_item ),
916 GTK_SIGNAL_FUNC( pf_toggle ),
917 (gpointer)(p_intf->p_sys->p_input->stream.pp_areas[i_title]) );
919 if( p_intf->p_sys->p_input->stream.i_area_nb > 1 )
921 /* be sure that menu is sensitive */
922 gtk_widget_set_sensitive( p_navigation, TRUE );
928 p_title_item = gtk_menu_item_new_with_label( psz_name );
931 p_chapter_menu = gtk_menu_new();
932 gtk_object_set_data( GTK_OBJECT( p_chapter_menu ),
935 p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb - 1;
937 for( i_chapter = 1 ; i_chapter <= i_chapter_nb ; i_chapter++ )
939 /* we group chapters in packets of ten for small screens */
940 if( ( i_chapter % 10 == 1 ) && ( i_chapter_nb > 20 ) )
944 gtk_menu_item_set_submenu(
945 GTK_MENU_ITEM( p_chapter_menu_item ),
947 gtk_menu_append( GTK_MENU( p_chapter_menu ),
948 p_chapter_menu_item );
951 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
952 "%d - %d", i_chapter, i_chapter + 9 );
953 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
954 p_chapter_menu_item =
955 gtk_menu_item_new_with_label( psz_name );
956 gtk_widget_show( p_chapter_menu_item );
957 p_chapter_submenu = gtk_menu_new();
958 gtk_object_set_data( GTK_OBJECT( p_chapter_submenu ),
962 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
963 _("Chapter %d"), i_chapter );
964 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
966 p_item = gtk_radio_menu_item_new_with_label(
967 p_chapter_group, psz_name );
968 p_chapter_group = gtk_radio_menu_item_group(
969 GTK_RADIO_MENU_ITEM( p_item ) );
970 gtk_widget_show( p_item );
972 #define p_area p_intf->p_sys->p_input->stream.pp_areas[i_title]
974 p_intf->p_sys->p_input->stream.p_selected_area ) &&
975 ( p_area->i_part == i_chapter ) )
977 p_item_active = p_item;
981 /* setup signal hanling */
982 gtk_signal_connect( GTK_OBJECT( p_item ),
984 GTK_SIGNAL_FUNC( pf_toggle ),
985 (gpointer)POS2DATA( i_title, i_chapter ) );
987 if( i_chapter_nb > 20 )
989 gtk_menu_append( GTK_MENU( p_chapter_submenu ), p_item );
993 gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );
997 if( i_chapter_nb > 20 )
999 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter_menu_item ),
1000 p_chapter_submenu );
1001 gtk_menu_append( GTK_MENU( p_chapter_menu ),
1002 p_chapter_menu_item );
1005 /* link the new menu to the title menu item */
1006 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),
1009 if( p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb > 1 )
1011 /* be sure that menu is sensitive */
1012 gtk_widget_set_sensitive( p_navigation, TRUE );
1015 GtkRadioMenu( p_intf, p_title_item, p_chapter_group, _("Chapter"),
1016 p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb - 1,
1018 p_intf->p_sys->p_input->stream.p_selected_area->i_part +
1019 p_intf->p_sys->p_input->stream.p_selected_area->i_id *100,
1024 gtk_widget_show( p_title_item );
1026 if( i_title_nb > 20 )
1028 gtk_menu_append( GTK_MENU( p_title_submenu ), p_title_item );
1032 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_item );
1036 if( i_title_nb > 20 )
1038 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),
1040 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );
1043 /* be sure that menu is sensitive */
1044 gtk_widget_set_sensitive( p_title_menu, TRUE );
1046 /* link the new menu to the menubar item */
1047 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );
1049 /* Default selected chapter
1050 * We have to release the lock since input_ToggleES needs it */
1051 if( p_item_active != NULL )
1053 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
1057 if( p_intf->p_sys->p_input->stream.i_area_nb > 1 )
1059 /* be sure that menu is sensitive */
1060 gtk_widget_set_sensitive( p_navigation, TRUE );
1067 /*****************************************************************************
1069 *****************************************************************************
1071 *****************************************************************************/
1072 static gint GtkSetupVarMenu( intf_thread_t * p_intf,
1073 vlc_object_t * p_object,
1075 char * psz_variable,
1076 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
1078 vlc_value_t val, text, val_list, text_list;
1080 GSList * p_group = NULL;
1082 GtkWidget * p_item_active = NULL;
1086 /* temporary hack to avoid blank menu when an open menu is removed */
1087 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
1089 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
1091 /* removes previous menu */
1092 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
1093 gtk_widget_set_sensitive( p_root, FALSE );
1095 /* Check the type of the object variable */
1096 i_type = var_Type( p_object, psz_variable );
1098 /* Make sure we want to display the variable */
1099 if( i_type & VLC_VAR_HASCHOICE )
1101 var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
1102 if( val.i_int == 0 ) return FALSE;
1105 /* Get the descriptive name of the variable */
1106 var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
1108 /* get the current value */
1109 if( var_Get( p_object, psz_variable, &val ) < 0 )
1114 if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
1115 &val_list, &text_list ) < 0 )
1117 if( i_type == VLC_VAR_STRING ) free( val.psz_string );
1121 /* menu container */
1122 p_menu = gtk_menu_new();
1123 gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf );
1125 for( i_item = 0; i_item < val_list.p_list->i_count; i_item++ )
1127 switch( i_type & VLC_VAR_TYPE )
1129 case VLC_VAR_STRING:
1130 p_item = gtk_radio_menu_item_new_with_label( p_group,
1131 text_list.p_list->p_values[i_item].psz_string ?
1132 text_list.p_list->p_values[i_item].psz_string :
1133 val_list.p_list->p_values[i_item].psz_string );
1135 /* signal hanling for off */
1136 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
1137 GTK_SIGNAL_FUNC ( pf_toggle ),
1138 /* FIXME memory leak */
1139 strdup(val_list.p_list->p_values[i_item].psz_string) );
1141 if( !strcmp( val.psz_string,
1142 val_list.p_list->p_values[i_item].psz_string ) )
1144 p_item_active = p_item;
1147 case VLC_VAR_INTEGER:
1148 p_item = gtk_radio_menu_item_new_with_label( p_group,
1149 text_list.p_list->p_values[i_item].psz_string ?
1150 text_list.p_list->p_values[i_item].psz_string :
1153 /* signal hanling for off */
1154 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
1155 GTK_SIGNAL_FUNC ( pf_toggle ),
1156 (gpointer)val_list.p_list->p_values[i_item].i_int );
1158 if( val.i_int == val_list.p_list->p_values[i_item].i_int )
1160 p_item_active = p_item;
1168 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
1170 gtk_widget_show( p_item );
1172 gtk_menu_append( GTK_MENU( p_menu ), p_item );
1175 /* link the new menu to the menubar item */
1176 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
1180 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(p_item_active),
1184 if( val_list.p_list->i_count > 0 )
1186 gtk_widget_set_sensitive( p_root, TRUE );
1189 /* clean up everything */
1190 if( i_type == VLC_VAR_STRING ) free( val.psz_string );
1191 var_Change( p_object, psz_variable, VLC_VAR_FREELIST,
1192 &val_list, &text_list );
1197 /*****************************************************************************
1198 * GtkDeinterlaceMenus: update interactive menus of the interface
1199 *****************************************************************************
1200 *****************************************************************************/
1201 static gint GtkDeinterlaceMenus( gpointer p_data,
1203 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
1205 intf_thread_t * p_intf;
1207 GtkWidget * p_separator;
1209 GtkWidget * p_item_active;
1213 char *ppsz_deinterlace_mode[] = { "discard", "blend", "mean", "bob", "linear", NULL };
1214 char *psz_deinterlace_option;
1217 p_intf = (intf_thread_t *)p_data;
1219 /* temporary hack to avoid blank menu when an open menu is removed */
1220 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
1222 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
1224 /* removes previous menu */
1225 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
1226 gtk_widget_set_sensitive( p_root, FALSE );
1230 /* menu container */
1231 p_menu = gtk_menu_new();
1232 gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf );
1234 /* special case for "off" item */
1235 p_item = gtk_radio_menu_item_new_with_label( p_group, "None" );
1236 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
1238 gtk_widget_show( p_item );
1240 /* signal hanling for off */
1241 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
1242 GTK_SIGNAL_FUNC ( pf_toggle ), NULL );
1244 gtk_menu_append( GTK_MENU( p_menu ), p_item );
1246 p_separator = gtk_menu_item_new();
1247 gtk_widget_set_sensitive( p_separator, FALSE );
1248 gtk_widget_show( p_separator );
1249 gtk_menu_append( GTK_MENU( p_menu ), p_separator );
1252 /* search actual deinterlace mode */
1253 psz_filter = config_GetPsz( p_intf, "filter" );
1254 psz_deinterlace_option = strdup( "None" );
1256 if( psz_filter && *psz_filter )
1258 if( strstr ( psz_filter, "deinterlace" ) )
1261 vout_thread_t *p_vout;
1263 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1266 var_Get( p_vout, "deinterlace-mode", &val ) == VLC_SUCCESS )
1268 if( val.psz_string && *val.psz_string )
1270 free( psz_deinterlace_option );
1271 psz_deinterlace_option = val.psz_string;
1273 else if( val.psz_string ) free( val.psz_string );
1276 if( p_vout ) vlc_object_release( p_vout );
1282 p_item_active = NULL;
1285 /* create a set of deinteralce buttons and append them to the container */
1286 for( i = 0; ppsz_deinterlace_mode[i] != NULL; i++ )
1290 p_item = gtk_radio_menu_item_new_with_label( p_group, ppsz_deinterlace_mode[i] );
1291 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
1292 gtk_widget_show( p_item );
1294 if( !strcmp( ppsz_deinterlace_mode[i], psz_deinterlace_option ) )
1296 p_item_active = p_item;
1298 /* setup signal hanling */
1299 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
1300 GTK_SIGNAL_FUNC( pf_toggle ),
1303 gtk_menu_append( GTK_MENU( p_menu ), p_item );
1307 /* link the new menu to the menubar item */
1308 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
1310 /* acitvation will call signals so we can only do it
1311 * when submenu is attached to menu - to get intf_window
1312 * We have to release the lock since input_ToggleES needs it */
1313 if( p_item_active != NULL )
1315 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
1319 /* be sure that menu is sensitive if non empty */
1322 gtk_widget_set_sensitive( p_root, TRUE );
1330 /*****************************************************************************
1331 * GtkSetupMenus: function that generates title/chapter/audio/subpic
1332 * menus with help from preceding functions
1333 *****************************************************************************
1334 * Function called with the lock on stream
1335 *****************************************************************************/
1336 gint GtkSetupMenus( intf_thread_t * p_intf )
1338 es_descriptor_t * p_audio_es;
1339 es_descriptor_t * p_spu_es;
1340 GtkWidget * p_menubar_menu;
1341 GtkWidget * p_popup_menu;
1344 p_intf->p_sys->b_chapter_update |= p_intf->p_sys->b_title_update;
1345 p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_title_update |
1346 p_intf->p_sys->b_program_update;
1347 p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_title_update |
1348 p_intf->p_sys->b_program_update;
1352 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1353 p_intf->p_sys->p_window ), "menubar_deinterlace" ) );
1354 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1355 p_intf->p_sys->p_popup ), "popup_deinterlace" ) );
1357 p_intf->p_sys->b_deinterlace_update = VLC_TRUE;
1358 GtkDeinterlaceMenus( p_intf, p_menubar_menu, GtkMenubarDeinterlaceToggle );
1359 p_intf->p_sys->b_deinterlace_update = VLC_TRUE;
1360 GtkDeinterlaceMenus( p_intf, p_popup_menu, GtkPopupDeinterlaceToggle );
1362 p_intf->p_sys->b_deinterlace_update = VLC_FALSE;
1365 if( p_intf->p_sys->b_program_update )
1367 pgrm_descriptor_t * p_pgrm;
1369 if( p_intf->p_sys->p_input->stream.p_new_program )
1371 p_pgrm = p_intf->p_sys->p_input->stream.p_new_program;
1375 p_pgrm = p_intf->p_sys->p_input->stream.p_selected_program;
1378 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1379 p_intf->p_sys->p_window ), "menubar_program" ) );
1380 GtkProgramMenu( p_intf, p_menubar_menu, p_pgrm,
1381 GtkMenubarProgramToggle );
1383 p_intf->p_sys->b_program_update = VLC_TRUE;
1384 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1385 p_intf->p_sys->p_popup ), "popup_program" ) );
1386 GtkProgramMenu( p_intf, p_popup_menu, p_pgrm,
1387 GtkPopupProgramToggle );
1389 p_intf->p_sys->b_program_update = VLC_FALSE;
1392 if( p_intf->p_sys->b_title_update )
1396 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1397 p_intf->p_sys->p_window ), "menubar_title" ) );
1398 GtkRadioMenu( p_intf, p_menubar_menu, NULL, _("Title"), 1,
1399 p_intf->p_sys->p_input->stream.i_area_nb - 1,
1400 p_intf->p_sys->p_input->stream.p_selected_area->i_id,
1401 GtkMenubarTitleToggle );
1403 snprintf( psz_title, 4, "%d",
1404 p_intf->p_sys->p_input->stream.p_selected_area->i_id );
1405 psz_title[ 4 ] = '\0';
1406 gtk_label_set_text( p_intf->p_sys->p_label_title, psz_title );
1408 p_intf->p_sys->b_title_update = VLC_FALSE;
1411 if( p_intf->p_sys->b_chapter_update )
1413 char psz_chapter[5];
1415 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1416 p_intf->p_sys->p_popup ), "popup_navigation" ) );
1417 GtkTitleMenu( p_intf, p_popup_menu, GtkPopupNavigationToggle );
1419 GtkRadioMenu( p_intf, p_menubar_menu, NULL, _("Title"), 1,
1420 p_intf->p_sys->p_input->stream.i_area_nb - 1,
1421 p_intf->p_sys->p_input->stream.p_selected_area->i_id,
1422 on_menubar_chapter_toggle );
1425 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1426 p_intf->p_sys->p_window ), "menubar_chapter" ) );
1428 GtkRadioMenu( p_intf, p_menubar_menu, NULL, _("Chapter"), 1,
1429 p_intf->p_sys->p_input->stream.p_selected_area->i_part_nb - 1,
1430 p_intf->p_sys->p_input->stream.p_selected_area->i_part,
1431 GtkMenubarChapterToggle );
1434 snprintf( psz_chapter, 4, "%d",
1435 p_intf->p_sys->p_input->stream.p_selected_area->i_part );
1436 psz_chapter[ 4 ] = '\0';
1437 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
1439 p_intf->p_sys->i_part =
1440 p_intf->p_sys->p_input->stream.p_selected_area->i_part;
1442 p_intf->p_sys->b_chapter_update = VLC_FALSE;
1445 /* look for selected ES */
1449 for( i = 0 ; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ )
1451 if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES )
1453 p_audio_es = p_intf->p_sys->p_input->stream.pp_selected_es[i];
1456 if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == SPU_ES )
1458 p_spu_es = p_intf->p_sys->p_input->stream.pp_selected_es[i];
1462 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
1465 if( p_intf->p_sys->b_audio_update )
1467 /* find audio root menu */
1468 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1469 p_intf->p_sys->p_window ), "menubar_audio" ) );
1471 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1472 p_intf->p_sys->p_popup ), "popup_language" ) );
1474 p_intf->p_sys->b_audio_update = VLC_TRUE;
1475 GtkLanguageMenus( p_intf, p_menubar_menu, p_audio_es, AUDIO_ES,
1476 GtkMenubarAudioToggle );
1477 p_intf->p_sys->b_audio_update = VLC_TRUE;
1478 GtkLanguageMenus( p_intf, p_popup_menu, p_audio_es, AUDIO_ES,
1479 GtkPopupAudioToggle );
1481 p_intf->p_sys->b_audio_update = VLC_FALSE;
1484 /* sub picture menus */
1485 if( p_intf->p_sys->b_spu_update )
1487 /* find spu root menu */
1488 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1489 p_intf->p_sys->p_window ), "menubar_subpictures" ) );
1491 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1492 p_intf->p_sys->p_popup ), "popup_subpictures" ) );
1494 p_intf->p_sys->b_spu_update = VLC_TRUE;
1495 GtkLanguageMenus( p_intf, p_menubar_menu, p_spu_es, SPU_ES,
1496 GtkMenubarSubtitleToggle );
1497 p_intf->p_sys->b_spu_update = VLC_TRUE;
1498 GtkLanguageMenus( p_intf, p_popup_menu, p_spu_es, SPU_ES,
1499 GtkPopupSubtitleToggle );
1501 p_intf->p_sys->b_spu_update = VLC_FALSE;
1503 /* create audio channels and device menu (in menubar _and_ popup */
1504 if( p_intf->p_sys->b_aout_update )
1506 aout_instance_t *p_aout;
1508 p_aout = (aout_instance_t*)vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
1510 if( p_aout != NULL )
1513 val.b_bool = VLC_FALSE;
1515 var_Set( (vlc_object_t *)p_aout, "intf-change", val );
1517 /* audio-channels */
1518 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1519 p_intf->p_sys->p_window ), "menubar_audio_channels" ) );
1520 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1521 p_intf->p_sys->p_popup ), "popup_audio_channels" ) );
1522 GtkSetupVarMenu( p_intf, (vlc_object_t *)p_aout, p_popup_menu,
1523 "audio-channels", GtkPopupAoutChannelsToggle );
1524 GtkSetupVarMenu( p_intf, (vlc_object_t *)p_aout, p_menubar_menu,
1525 "audio-channels", GtkPopupAoutChannelsToggle );
1528 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1529 p_intf->p_sys->p_window ), "menubar_audio_device" ) );
1530 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1531 p_intf->p_sys->p_popup ), "popup_audio_device" ) );
1532 GtkSetupVarMenu( p_intf, (vlc_object_t *)p_aout, p_popup_menu,
1533 "audio-device", GtkPopupAoutDeviceToggle );
1534 GtkSetupVarMenu( p_intf, (vlc_object_t *)p_aout, p_menubar_menu,
1535 "audio-device", GtkPopupAoutDeviceToggle );
1537 vlc_object_release( (vlc_object_t *)p_aout );
1539 p_intf->p_sys->b_aout_update = VLC_FALSE;
1542 if( p_intf->p_sys->b_vout_update )
1544 vout_thread_t *p_vout;
1546 p_vout = (vout_thread_t*)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
1548 if( p_vout != NULL )
1551 val.b_bool = VLC_FALSE;
1553 var_Set( (vlc_object_t *)p_vout, "intf-change", val );
1556 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1557 p_intf->p_sys->p_window ), "menubar_video_device" ) );
1558 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
1559 p_intf->p_sys->p_popup ), "popup_video_device" ) );
1560 GtkSetupVarMenu( p_intf, (vlc_object_t *)p_vout, p_popup_menu,
1561 "video-device", GtkPopupVoutDeviceToggle );
1562 GtkSetupVarMenu( p_intf, (vlc_object_t *)p_vout, p_menubar_menu,
1563 "video-device", GtkPopupVoutDeviceToggle );
1566 vlc_object_release( (vlc_object_t *)p_vout );
1568 p_intf->p_sys->b_vout_update = VLC_FALSE;
1570 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );