+/*****************************************************************************
+ * GtkChapterMenu: generate chapter menu for current title
+ *****************************************************************************/
+static gint GtkChapterMenu( gpointer p_data, GtkWidget * p_chapter,
+ void(*pf_activate )( GtkMenuItem *, gpointer ) )
+{
+ intf_thread_t * p_intf;
+ char psz_name[10];
+ GtkWidget * p_chapter_menu;
+ GtkWidget * p_item;
+ GSList * p_chapter_button_group;
+ gint i_title;
+ gint i_chapter;
+ gint b_active;
+
+ /* cast */
+ p_intf = (intf_thread_t*)p_data;
+
+ i_title = p_intf->p_input->stream.p_selected_area->i_id;
+ p_chapter_menu = gtk_menu_new();
+
+ for( i_chapter = 0;
+ i_chapter < p_intf->p_input->stream.pp_areas[i_title]->i_part_nb ;
+ i_chapter++ )
+ {
+ b_active = ( p_intf->p_input->stream.pp_areas[i_title]->i_part
+ == i_chapter + 1 ) ? 1 : 0;
+
+ sprintf( psz_name, "Chapter %d", i_chapter + 1 );
+
+ p_item = GtkMenuRadioItem( p_chapter_menu, &p_chapter_button_group,
+ b_active, psz_name );
+ /* setup signal hanling */
+ gtk_signal_connect( GTK_OBJECT( p_item ),
+ "activate",
+ GTK_SIGNAL_FUNC( pf_activate ),
+ (gpointer)(i_chapter + 1) );
+ }
+
+ /* link the new menu to the title menu item */
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter ),
+ p_chapter_menu );
+
+ /* be sure that chapter menu is sensitive */
+ gtk_widget_set_sensitive( p_chapter, TRUE );
+
+ return TRUE;
+}
+
+/*****************************************************************************
+ * GtkTitleMenu: sets menus for titles and chapters selection
+ *****************************************************************************
+ * Generates two type of menus:
+ * -simple list of titles
+ * -cascaded lists of chapters for each title
+ *****************************************************************************/
+static gint GtkTitleMenu( gpointer p_data,
+ GtkWidget * p_navigation,
+ void(*pf_activate )( GtkMenuItem *, gpointer ) )
+{
+ intf_thread_t * p_intf;
+ char psz_name[10];
+ GtkWidget * p_title_menu;
+ GtkWidget * p_title_item;
+ GtkWidget * p_chapter_menu;
+ GtkWidget * p_item;
+ GSList * p_title_button_group;
+ GSList * p_chapter_button_group;
+ gint i_title;
+ gint i_chapter;
+ gint b_active;
+
+ /* cast */
+ p_intf = (intf_thread_t*)p_data;
+
+ p_title_menu = gtk_menu_new();
+ p_title_button_group = NULL;
+ p_chapter_button_group = NULL;
+
+ /* loop on titles */
+ for( i_title = 1 ;
+ i_title < p_intf->p_input->stream.i_area_nb ;
+ i_title++ )
+ {
+ b_active = ( p_intf->p_input->stream.pp_areas[i_title] ==
+ p_intf->p_input->stream.p_selected_area ) ? 1 : 0;
+ sprintf( psz_name, "Title %d", i_title );
+
+ p_title_item = GtkMenuRadioItem( p_title_menu, &p_title_button_group,
+ b_active, psz_name );
+
+ if( pf_activate == on_menubar_title_activate )
+ {
+ /* setup signal hanling */
+ gtk_signal_connect( GTK_OBJECT( p_title_item ),
+ "activate",
+ GTK_SIGNAL_FUNC( pf_activate ),
+ (gpointer)(p_intf->p_input->stream.pp_areas[i_title]) );
+ }
+ else
+ {
+ p_chapter_menu = gtk_menu_new();
+
+ for( i_chapter = 0;
+ i_chapter <
+ p_intf->p_input->stream.pp_areas[i_title]->i_part_nb ;
+ i_chapter++ )
+ {
+ b_active = ( p_intf->p_input->stream.pp_areas[i_title]->i_part
+ == i_chapter + 1 ) ? 1 : 0;
+
+ sprintf( psz_name, "Chapter %d", i_chapter + 1 );
+
+ p_item = GtkMenuRadioItem( p_chapter_menu,
+ &p_chapter_button_group,
+ b_active, psz_name );
+
+ /* setup signal hanling */
+ gtk_signal_connect( GTK_OBJECT( p_item ),
+ "activate",
+ GTK_SIGNAL_FUNC( pf_activate ),
+ (gpointer)( ( i_title * 100 ) + ( i_chapter + 1) ) );
+ }
+
+ /* link the new menu to the title menu item */
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),
+ p_chapter_menu );
+ }
+
+ /* be sure that chapter menu is sensitive */
+ gtk_widget_set_sensitive( p_title_menu, TRUE );
+
+ }
+
+ /* link the new menu to the menubar audio item */
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );
+
+ /* be sure that audio menu is sensitive */
+ gtk_widget_set_sensitive( p_navigation, TRUE );
+
+
+ return TRUE;
+}
+
+void GtkDisplayDate( GtkAdjustment *p_adj )
+{
+ intf_thread_t *p_intf;
+
+ p_intf = gtk_object_get_data( GTK_OBJECT( p_adj ), "p_intf" );
+
+ if( p_intf->p_input != NULL )
+ {
+#define p_area p_intf->p_input->stream.p_selected_area
+ char psz_time[ OFFSETTOTIME_MAX_SIZE ];
+
+ vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
+
+ gtk_label_set_text( p_intf->p_sys->p_label_date,
+ input_OffsetToTime( p_intf->p_input, psz_time,
+ ( p_area->i_size * p_adj->value ) / 100 ) );
+
+ vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
+#undef p_area
+ }
+}
+
+