1 /*****************************************************************************
2 * gtk_menu.c : functions to handle menu items.
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
5 * $Id: gtk_menu.c,v 1.3 2001/05/19 00:39:30 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 gtk
26 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
32 #include <sys/types.h> /* off_t */
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
47 #include "interface.h"
48 #include "intf_playlist.h"
52 #include "video_output.h"
53 #include "audio_output.h"
55 #include "gtk_callbacks.h"
56 #include "gtk_interface.h"
57 #include "gtk_support.h"
58 #include "gtk_playlist.h"
66 static gint GtkLanguageMenus( gpointer , GtkWidget *, es_descriptor_t *, gint,
67 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) );
69 void GtkMenubarAudioToggle ( GtkCheckMenuItem *, gpointer );
70 void GtkPopupAudioToggle ( GtkCheckMenuItem *, gpointer );
71 void GtkMenubarSubtitleToggle( GtkCheckMenuItem *, gpointer );
72 void GtkPopupSubtitleToggle ( GtkCheckMenuItem *, gpointer );
73 static gint GtkTitleMenu( gpointer, GtkWidget *,
74 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) );
75 static gint GtkRadioMenu( intf_thread_t *, GtkWidget *, GSList *,
77 void( *pf_toggle )( GtkCheckMenuItem *, gpointer ) );
78 void GtkMenubarAngleToggle( GtkCheckMenuItem *, gpointer );
79 void GtkPopupAngleToggle( GtkCheckMenuItem *, gpointer );
81 gint GtkSetupMenus( intf_thread_t * p_intf );
83 /****************************************************************************
84 * Gtk*Toggle: callbacks to toggle the value of a checkmenuitem
85 ****************************************************************************
86 * We need separate functions for menubar and popup here since we can't use
87 * user_data to transmit intf_* and we need to refresh the other menu.
88 ****************************************************************************/
90 #define GtkLangToggle( intf, menu, type, callback, b_update ) \
91 intf_thread_t * p_intf; \
93 es_descriptor_t * p_es; \
95 p_intf = GetIntf( GTK_WIDGET(menuitem), (intf) ); \
97 if( !p_intf->p_sys->b_update ) \
99 p_menu = GTK_WIDGET( gtk_object_get_data( \
100 GTK_OBJECT( p_intf->p_sys->p_popup ), (menu) ) ); \
101 p_es = (es_descriptor_t*)user_data; \
103 input_ToggleES( p_intf->p_input, p_es, menuitem->active ); \
105 p_intf->p_sys->b_update = menuitem->active; \
107 if( p_intf->p_sys->b_update ) \
109 GtkLanguageMenus( p_intf, p_menu, p_es, type, callback ); \
112 p_intf->p_sys->b_update = 0; \
119 void GtkMenubarAudioToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
121 GtkLangToggle( "intf_window", "popup_audio", AUDIO_ES,
122 GtkPopupAudioToggle, b_audio_update );
125 void GtkPopupAudioToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
127 GtkLangToggle( "intf_popup", "menubar_audio", AUDIO_ES,
128 GtkMenubarAudioToggle, b_audio_update );
135 void GtkMenubarSubtitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
137 GtkLangToggle( "intf_window", "popup_subpictures", SPU_ES,
138 GtkPopupSubtitleToggle, b_spu_update );
141 void GtkPopupSubtitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
143 GtkLangToggle( "intf_popup", "menubar_subpictures", SPU_ES,
144 GtkMenubarSubtitleToggle, b_spu_update );
153 void GtkPopupNavigationToggle( GtkCheckMenuItem * menuitem,
156 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
158 if( menuitem->active &&
159 !p_intf->p_sys->b_title_update &&
160 !p_intf->p_sys->b_chapter_update )
162 input_area_t *p_area;
164 gint i_title = DATA2TITLE( user_data );
165 gint i_chapter = DATA2CHAPTER( user_data );
167 p_area = p_intf->p_input->stream.p_selected_area;
169 if( p_area != p_intf->p_input->stream.pp_areas[i_title] )
171 p_area = p_intf->p_input->stream.pp_areas[i_title];
172 p_intf->p_sys->b_title_update = 1;
175 p_area->i_part = i_chapter;
177 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
179 p_intf->p_sys->b_chapter_update = 1;
180 GtkSetupMenus( p_intf );
182 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
190 void GtkMenubarTitleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
192 intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
194 if( menuitem->active && !p_intf->p_sys->b_title_update )
196 gint i_title = (gint)user_data;
197 input_ChangeArea( p_intf->p_input,
198 p_intf->p_input->stream.pp_areas[i_title] );
200 p_intf->p_sys->b_title_update = 1;
201 GtkSetupMenus( p_intf );
202 p_intf->p_sys->b_title_update = 0;
204 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
213 void GtkMenubarChapterToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
215 intf_thread_t * p_intf;
216 input_area_t * p_area;
219 GtkWidget * p_popup_menu;
221 p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
222 p_area = p_intf->p_input->stream.p_selected_area;
223 i_chapter = (gint)user_data;
225 if( menuitem->active && !p_intf->p_sys->b_chapter_update )
227 p_area->i_part = i_chapter;
228 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area );
230 snprintf( psz_chapter, 4, "%02d", p_area->i_part );
231 psz_chapter[ 4 ] = '\0';
232 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
234 p_intf->p_sys->b_chapter_update = 1;
235 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
236 p_intf->p_sys->p_popup ), "popup_navigation" ) );
238 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
239 GtkTitleMenu( p_intf, p_popup_menu, GtkPopupNavigationToggle );
240 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
242 p_intf->p_sys->b_chapter_update = 0;
244 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
253 #define GtkAngleToggle( intf, window, menu, callback ) \
254 intf_thread_t * p_intf; \
255 GtkWidget * p_menu; \
256 input_area_t * p_area; \
258 p_intf = GetIntf( GTK_WIDGET(menuitem), (intf) ); \
260 if( menuitem->active && !p_intf->p_sys->b_angle_update ) \
262 p_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT( \
263 p_intf->p_sys->window ), (menu) ) ); \
264 p_area = p_intf->p_input->stream.p_selected_area; \
265 p_area->i_angle = (gint)user_data; \
267 input_ChangeArea( p_intf->p_input, (input_area_t*)p_area ); \
269 p_intf->p_sys->b_angle_update = 1; \
270 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock ); \
271 GtkRadioMenu( p_intf, p_menu, NULL, "Angle", \
272 p_area->i_angle_nb, p_area->i_angle, (callback) ); \
273 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock ); \
274 p_intf->p_sys->b_angle_update = 0; \
277 void GtkMenubarAngleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
279 GtkAngleToggle( "intf_window", p_popup, "popup_angle",
280 GtkPopupAngleToggle );
283 void GtkPopupAngleToggle( GtkCheckMenuItem * menuitem, gpointer user_data )
285 GtkAngleToggle( "intf_popup", p_window, "menubar_angle",
286 GtkMenubarAngleToggle );
289 #undef GtkAngleToggle
291 /****************************************************************************
292 * Functions to generate menus
293 ****************************************************************************/
295 /*****************************************************************************
296 * GtkRadioMenu: update interactive menus of the interface
297 *****************************************************************************
298 * Sets up menus with information from input
299 * Warning: since this function is designed to be called by management
300 * function, the interface lock has to be taken
301 *****************************************************************************/
302 static gint GtkRadioMenu( intf_thread_t * p_intf,
303 GtkWidget * p_root, GSList * p_menu_group,
304 char * psz_item_name,
305 int i_nb, int i_selected,
306 void( *pf_toggle )( GtkCheckMenuItem *, gpointer ) )
308 char psz_name[ GTK_MENU_LABEL_SIZE ];
310 GtkWidget * p_submenu;
311 GtkWidget * p_item_group;
313 GtkWidget * p_item_selected;
317 /* temporary hack to avoid blank menu when an open menu is removed */
318 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
320 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
322 /* removes previous menu */
323 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
324 gtk_widget_set_sensitive( p_root, FALSE );
328 p_item_selected = NULL;
329 p_group = p_menu_group;
331 p_menu = gtk_menu_new();
333 for( i_item = 0 ; i_item < i_nb ; i_item++ )
335 /* we group chapters in packets of ten for small screens */
336 if( ( i_item % 10 == 0 ) && ( i_nb > 20 ) )
340 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_item_group ),
342 gtk_menu_append( GTK_MENU( p_menu ), p_item_group );
345 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
346 "%ss %d to %d", psz_item_name, i_item + 1, i_item + 10);
347 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
348 p_item_group = gtk_menu_item_new_with_label( psz_name );
349 gtk_widget_show( p_item_group );
350 p_submenu = gtk_menu_new();
353 snprintf( psz_name, GTK_MENU_LABEL_SIZE, "%s %d",
354 psz_item_name, i_item + 1 );
355 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
357 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
358 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
360 if( i_selected == i_item + 1 )
362 p_item_selected = p_item;
365 gtk_widget_show( p_item );
367 /* setup signal hanling */
368 gtk_signal_connect( GTK_OBJECT( p_item ),
370 GTK_SIGNAL_FUNC( pf_toggle ),
371 (gpointer)(i_item + 1) );
375 gtk_menu_append( GTK_MENU( p_submenu ), p_item );
379 gtk_menu_append( GTK_MENU( p_menu ), p_item );
385 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_item_group ), p_submenu );
386 gtk_menu_append( GTK_MENU( p_menu ), p_item_group );
389 /* link the new menu to the title menu item */
390 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
392 /* toggle currently selected chapter
393 * We have to release the lock since input_ToggleES needs it */
394 if( p_item_selected != NULL )
396 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
397 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_selected ),
399 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
402 /* be sure that menu is sensitive, if there are several items */
405 gtk_widget_set_sensitive( p_root, TRUE );
411 /*****************************************************************************
412 * GtkLanguageMenus: update interactive menus of the interface
413 *****************************************************************************
414 * Sets up menus with information from input:
417 * Warning: since this function is designed to be called by management
418 * function, the interface lock has to be taken
419 *****************************************************************************/
420 static gint GtkLanguageMenus( gpointer p_data,
422 es_descriptor_t * p_es,
424 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
426 intf_thread_t * p_intf;
428 GtkWidget * p_separator;
430 GtkWidget * p_item_active;
432 char psz_name[ GTK_MENU_LABEL_SIZE ];
439 p_intf = (intf_thread_t *)p_data;
441 /* temporary hack to avoid blank menu when an open menu is removed */
442 if( GTK_MENU_ITEM(p_root)->submenu != NULL )
444 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );
446 /* removes previous menu */
447 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );
448 gtk_widget_set_sensitive( p_root, FALSE );
453 p_menu = gtk_menu_new();
455 /* special case for "off" item */
456 snprintf( psz_name, GTK_MENU_LABEL_SIZE, "None" );
457 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
459 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
460 p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
462 gtk_widget_show( p_item );
464 /* signal hanling for off */
465 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
466 GTK_SIGNAL_FUNC ( pf_toggle ), NULL );
468 gtk_menu_append( GTK_MENU( p_menu ), p_item );
470 p_separator = gtk_menu_item_new();
471 gtk_widget_set_sensitive( p_separator, FALSE );
472 gtk_widget_show( p_separator );
473 gtk_menu_append( GTK_MENU( p_menu ), p_separator );
475 p_item_active = NULL;
478 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
480 /* create a set of language buttons and append them to the container */
481 for( i = 0 ; i < p_intf->p_input->stream.i_es_number ; i++ )
483 if( p_intf->p_input->stream.pp_es[i]->i_cat == i_cat )
486 strcpy( psz_name, p_intf->p_input->stream.pp_es[i]->psz_desc );
487 if( psz_name[0] == '\0' )
489 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
490 "Language %d", i_item );
491 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
494 p_item = gtk_radio_menu_item_new_with_label( p_group, psz_name );
496 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );
498 if( p_es == p_intf->p_input->stream.pp_es[i] )
500 /* don't lose p_item when we append into menu */
501 p_item_active = p_item;
504 gtk_widget_show( p_item );
506 /* setup signal hanling */
507 gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",
508 GTK_SIGNAL_FUNC( pf_toggle ),
509 (gpointer)( p_intf->p_input->stream.pp_es[i] ) );
511 gtk_menu_append( GTK_MENU( p_menu ), p_item );
515 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
517 /* link the new menu to the menubar item */
518 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
520 /* acitvation will call signals so we can only do it
521 * when submenu is attached to menu - to get intf_window
522 * We have to release the lock since input_ToggleES needs it */
523 if( p_item_active != NULL )
525 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
529 /* be sure that menu is sensitive if non empty */
532 gtk_widget_set_sensitive( p_root, TRUE );
538 /*****************************************************************************
539 * GtkTitleMenu: sets menus for titles and chapters selection
540 *****************************************************************************
541 * Generates two types of menus:
542 * -simple list of titles
543 * -cascaded lists of chapters for each title
544 *****************************************************************************/
545 static gint GtkTitleMenu( gpointer p_data,
546 GtkWidget * p_navigation,
547 void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) )
549 intf_thread_t * p_intf;
550 char psz_name[ GTK_MENU_LABEL_SIZE ];
551 GtkWidget * p_title_menu;
552 GtkWidget * p_title_submenu;
553 GtkWidget * p_title_item;
554 GtkWidget * p_item_active;
555 GtkWidget * p_chapter_menu;
556 GtkWidget * p_chapter_submenu;
557 GtkWidget * p_title_menu_item;
558 GtkWidget * p_chapter_menu_item;
560 GSList * p_title_group;
561 GSList * p_chapter_group;
568 p_intf = (intf_thread_t*)p_data;
570 /* temporary hack to avoid blank menu when an open menu is removed */
571 if( GTK_MENU_ITEM(p_navigation)->submenu != NULL )
573 gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_navigation)->submenu ) );
575 /* removes previous menu */
576 gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_navigation ) );
577 gtk_widget_set_sensitive( p_navigation, FALSE );
579 p_title_menu = gtk_menu_new();
580 p_title_group = NULL;
581 p_title_submenu = NULL;
582 p_title_menu_item = NULL;
583 p_chapter_group = NULL;
584 p_chapter_submenu = NULL;
585 p_chapter_menu_item = NULL;
586 p_item_active = NULL;
587 i_title_nb = p_intf->p_input->stream.i_area_nb;
590 for( i_title = 1 ; i_title < i_title_nb ; i_title++ )
592 /* we group titles in packets of ten for small screens */
593 if( ( i_title % 10 == 1 ) && ( i_title_nb > 20 ) )
597 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),
599 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );
602 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
603 "%d - %d", i_title, i_title + 9 );
604 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
605 p_title_menu_item = gtk_menu_item_new_with_label( psz_name );
606 gtk_widget_show( p_title_menu_item );
607 p_title_submenu = gtk_menu_new();
610 snprintf( psz_name, GTK_MENU_LABEL_SIZE, "Title %d (%d)", i_title,
611 p_intf->p_input->stream.pp_areas[i_title]->i_part_nb );
612 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
614 if( pf_toggle == on_menubar_title_toggle )
616 p_title_item = gtk_radio_menu_item_new_with_label( p_title_group,
619 gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_title_item ) );
621 if( p_intf->p_input->stream.pp_areas[i_title] ==
622 p_intf->p_input->stream.p_selected_area )
624 p_item_active = p_title_item;
627 /* setup signal hanling */
628 gtk_signal_connect( GTK_OBJECT( p_title_item ),
630 GTK_SIGNAL_FUNC( pf_toggle ),
631 (gpointer)(p_intf->p_input->stream.pp_areas[i_title]) );
633 if( p_intf->p_input->stream.i_area_nb > 1 )
635 /* be sure that menu is sensitive */
636 gtk_widget_set_sensitive( p_navigation, TRUE );
642 p_title_item = gtk_menu_item_new_with_label( psz_name );
645 p_chapter_menu = gtk_menu_new();
647 p_intf->p_input->stream.pp_areas[i_title]->i_part_nb;
649 for( i_chapter = 0 ; i_chapter < i_chapter_nb ; i_chapter++ )
651 /* we group chapters in packets of ten for small screens */
652 if( ( i_chapter % 10 == 0 ) && ( i_chapter_nb > 20 ) )
656 gtk_menu_item_set_submenu(
657 GTK_MENU_ITEM( p_chapter_menu_item ),
659 gtk_menu_append( GTK_MENU( p_chapter_menu ),
660 p_chapter_menu_item );
663 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
664 "%d - %d", i_chapter + 1, i_chapter + 10 );
665 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
666 p_chapter_menu_item =
667 gtk_menu_item_new_with_label( psz_name );
668 gtk_widget_show( p_chapter_menu_item );
669 p_chapter_submenu = gtk_menu_new();
672 snprintf( psz_name, GTK_MENU_LABEL_SIZE,
673 "Chapter %d", i_chapter + 1 );
674 psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';
676 p_item = gtk_radio_menu_item_new_with_label(
677 p_chapter_group, psz_name );
678 p_chapter_group = gtk_radio_menu_item_group(
679 GTK_RADIO_MENU_ITEM( p_item ) );
680 gtk_widget_show( p_item );
682 #define p_area p_intf->p_input->stream.pp_areas[i_title]
683 if( ( p_area == p_intf->p_input->stream.p_selected_area ) &&
684 ( p_area->i_part == i_chapter + 1 ) )
686 p_item_active = p_item;
690 /* setup signal hanling */
691 gtk_signal_connect( GTK_OBJECT( p_item ),
693 GTK_SIGNAL_FUNC( pf_toggle ),
694 (gpointer)POS2DATA( i_title, i_chapter + 1) );
696 if( i_chapter_nb > 20 )
698 gtk_menu_append( GTK_MENU( p_chapter_submenu ), p_item );
702 gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );
706 if( i_chapter_nb > 20 )
708 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter_menu_item ),
710 gtk_menu_append( GTK_MENU( p_chapter_menu ),
711 p_chapter_menu_item );
714 /* link the new menu to the title menu item */
715 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),
718 if( p_intf->p_input->stream.pp_areas[i_title]->i_part_nb > 1 )
720 /* be sure that menu is sensitive */
721 gtk_widget_set_sensitive( p_navigation, TRUE );
724 GtkRadioMenu( p_intf, p_title_item, p_chapter_group, "Chapter",
725 p_intf->p_input->stream.pp_areas[i_title]->i_part_nb,
727 p_intf->p_input->stream.p_selected_area->i_part +
728 p_intf->p_input->stream.p_selected_area->i_id *100,
733 gtk_widget_show( p_title_item );
735 if( i_title_nb > 20 )
737 gtk_menu_append( GTK_MENU( p_title_submenu ), p_title_item );
741 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_item );
745 if( i_title_nb > 20 )
747 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),
749 gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );
752 /* be sure that menu is sensitive */
753 gtk_widget_set_sensitive( p_title_menu, TRUE );
755 /* link the new menu to the menubar item */
756 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );
758 /* Default selected chapter
759 * We have to release the lock since input_ToggleES needs it */
760 if( p_item_active != NULL )
762 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
763 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
765 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
768 if( p_intf->p_input->stream.i_area_nb > 1 )
770 /* be sure that menu is sensitive */
771 gtk_widget_set_sensitive( p_navigation, TRUE );
778 /*****************************************************************************
779 * GtkSetupMenus: function that generates title/chapter/audio/subpic
780 * menus with help from preceding functions
781 *****************************************************************************/
782 gint GtkSetupMenus( intf_thread_t * p_intf )
784 es_descriptor_t * p_audio_es;
785 es_descriptor_t * p_spu_es;
786 GtkWidget * p_menubar_menu;
787 GtkWidget * p_popup_menu;
790 p_intf->p_sys->b_chapter_update |= p_intf->p_sys->b_title_update;
791 p_intf->p_sys->b_angle_update |= p_intf->p_sys->b_title_update;
792 p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_title_update;
793 p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_title_update;
795 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
797 if( p_intf->p_sys->b_title_update )
801 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
802 p_intf->p_sys->p_window ), "menubar_title" ) );
803 GtkRadioMenu( p_intf, p_menubar_menu, NULL, "Title",
804 p_intf->p_input->stream.i_area_nb - 1,
805 p_intf->p_input->stream.p_selected_area->i_id,
806 GtkMenubarTitleToggle );
808 snprintf( psz_title, 4, "%d",
809 p_intf->p_input->stream.p_selected_area->i_id );
810 psz_title[ 4 ] = '\0';
811 gtk_label_set_text( p_intf->p_sys->p_label_title, psz_title );
813 p_intf->p_sys->b_title_update = 0;
816 if( p_intf->p_sys->b_chapter_update )
820 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
821 p_intf->p_sys->p_popup ), "popup_navigation" ) );
822 GtkTitleMenu( p_intf, p_popup_menu, GtkPopupNavigationToggle );
824 GtkRadioMenu( p_intf, p_menubar_menu, NULL, "Title",
825 p_intf->p_input->stream.i_area_nb - 1,
826 p_intf->p_input->stream.p_selected_area->i_id,
827 on_menubar_chapter_toggle );
830 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
831 p_intf->p_sys->p_window ), "menubar_chapter" ) );
832 GtkRadioMenu( p_intf, p_menubar_menu, NULL, "Chapter",
833 p_intf->p_input->stream.p_selected_area->i_part_nb,
834 p_intf->p_input->stream.p_selected_area->i_part,
835 GtkMenubarChapterToggle );
838 snprintf( psz_chapter, 4, "%d",
839 p_intf->p_input->stream.p_selected_area->i_part );
840 psz_chapter[ 4 ] = '\0';
841 gtk_label_set_text( p_intf->p_sys->p_label_chapter, psz_chapter );
843 p_intf->p_sys->i_part =
844 p_intf->p_input->stream.p_selected_area->i_part;
846 p_intf->p_sys->b_chapter_update = 0;
849 if( p_intf->p_sys->b_angle_update )
851 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
852 p_intf->p_sys->p_window ), "menubar_angle" ) );
853 GtkRadioMenu( p_intf, p_menubar_menu, NULL, "Angle",
854 p_intf->p_input->stream.p_selected_area->i_angle_nb,
855 p_intf->p_input->stream.p_selected_area->i_angle,
856 GtkMenubarAngleToggle );
858 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
859 p_intf->p_sys->p_popup ), "popup_angle" ) );
860 GtkRadioMenu( p_intf, p_popup_menu, NULL, "Angle",
861 p_intf->p_input->stream.p_selected_area->i_angle_nb,
862 p_intf->p_input->stream.p_selected_area->i_angle,
863 GtkPopupAngleToggle );
865 p_intf->p_sys->b_angle_update = 0;
868 /* look for selected ES */
872 for( i = 0 ; i < p_intf->p_input->stream.i_selected_es_number ; i++ )
874 if( p_intf->p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES )
876 p_audio_es = p_intf->p_input->stream.pp_selected_es[i];
879 if( p_intf->p_input->stream.pp_selected_es[i]->i_cat == SPU_ES )
881 p_spu_es = p_intf->p_input->stream.pp_selected_es[i];
885 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
888 if( p_intf->p_sys->b_audio_update )
890 /* find audio root menu */
891 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
892 p_intf->p_sys->p_window ), "menubar_audio" ) );
894 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
895 p_intf->p_sys->p_popup ), "popup_audio" ) );
897 p_intf->p_sys->b_audio_update = 1;
898 GtkLanguageMenus( p_intf, p_menubar_menu, p_audio_es, AUDIO_ES,
899 GtkMenubarAudioToggle );
900 p_intf->p_sys->b_audio_update = 1;
901 GtkLanguageMenus( p_intf, p_popup_menu, p_audio_es, AUDIO_ES,
902 GtkPopupAudioToggle );
904 p_intf->p_sys->b_audio_update = 0;
907 /* sub picture menus */
908 if( p_intf->p_sys->b_spu_update )
910 /* find spu root menu */
911 p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
912 p_intf->p_sys->p_window ), "menubar_subpictures" ) );
914 p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
915 p_intf->p_sys->p_popup ), "popup_subpictures" ) );
917 p_intf->p_sys->b_spu_update = 1;
918 GtkLanguageMenus( p_intf, p_menubar_menu, p_spu_es, SPU_ES,
919 GtkMenubarSubtitleToggle );
920 p_intf->p_sys->b_spu_update = 1;
921 GtkLanguageMenus( p_intf, p_popup_menu, p_spu_es, SPU_ES,
922 GtkPopupSubtitleToggle );
924 p_intf->p_sys->b_spu_update = 0;