1 /***************************************************************************
2 kde_menu.cpp - description
4 begin : Thu Apr 12 2001
5 copyright : (C) 2001 by andres
7 ***************************************************************************/
9 #include "kde_interface.h"
15 KTitleMenu::KTitleMenu( intf_thread_t *p_intf, QWidget *parent, const char *name ) : KPopupMenu( parent, name )
17 fInterfaceThread = p_intf;
18 connect( this, SIGNAL( aboutToShow() ), this, SLOT( regenerateSlot() ) );
19 fLanguageList = new KActionMenu( "Language", 0, this );
22 KTitleMenu::~KTitleMenu()
26 void KTitleMenu::regenerateSlot()
28 // removal of elements and disconnection of signal/slots happen transparently on delete
30 fLanguageList = new KActionMenu( "Language", 0, this );
33 vlc_mutex_lock( &fInterfaceThread->p_sys->p_input->stream.stream_lock );
35 for( int i = 0 ; i < fInterfaceThread->p_sys->p_input->stream.i_es_number ; i++ )
37 if( fInterfaceThread->p_sys->p_input->stream.pp_es[i]->i_cat /* == i_cat */ )
40 QString language( fInterfaceThread->p_sys->p_input->stream.pp_es[i]->psz_desc );
41 if ( QString::null == language )
43 language += i18n( "Language" );
44 language += " " + i_item;
46 KRadioAction *action = new KRadioAction( language, 0, this, "language_action" );
47 fLanguageList->insert( action );
49 if( /* p_es == */ fInterfaceThread->p_sys->p_input->stream.pp_es[i] )
51 /* don't lose p_item when we append into menu */
52 //p_item_active = p_item;
57 vlc_mutex_unlock( &fInterfaceThread->p_sys->p_input->stream.stream_lock );
60 /* link the new menu to the menubar item */
61 gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
63 /* acitvation will call signals so we can only do it
64 * when submenu is attached to menu - to get intf_window */
65 if( p_item_active != NULL )
67 gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
72 /* be sure that menu is sensitive if non empty */
75 fLanguageList->setEnabled( true );
79 /** this method is called when the user selects a language */
80 void KTitleMenu::languageSelectedSlot()