* ./modules/gui/kde/kde.cpp: the interface rc file defaults to the one in
[vlc.git] / modules / gui / kde / menu.cpp
1 /***************************************************************************
2                           menu.cpp  -  description
3                              -------------------
4     begin                : Thu Apr 12 2001
5     copyright            : (C) 2001 by andres
6     email                : dae@chez.com
7  ***************************************************************************/
8
9 #include "interface.h"
10 #include "menu.h"
11
12 #include <kaction.h>
13 #include <klocale.h>
14
15 KTitleMenu::KTitleMenu( intf_thread_t *p_intf, QWidget *parent, const char *name ) : KPopupMenu( parent, name )
16 {
17     fInterfaceThread = p_intf;
18     connect( this, SIGNAL( aboutToShow() ), this, SLOT( regenerateSlot() ) );
19     fLanguageList = new KActionMenu( "Language", 0, this );
20 }
21
22 KTitleMenu::~KTitleMenu()
23 {
24 }
25
26 void KTitleMenu::regenerateSlot()
27 {
28     // removal of elements and disconnection of signal/slots happen transparently on delete
29     delete fLanguageList;
30     fLanguageList = new KActionMenu( "Language", 0, this );
31
32     int i_item = 0;
33     vlc_mutex_lock( &fInterfaceThread->p_sys->p_input->stream.stream_lock );
34
35     for( unsigned int i = 0 ;
36          i < fInterfaceThread->p_sys->p_input->stream.i_es_number ;
37          i++ )
38     {
39         if( fInterfaceThread->p_sys->p_input->stream.pp_es[i]->i_cat /* == i_cat */ )
40         {
41             i_item++;
42             QString language( fInterfaceThread->p_sys->p_input->stream.pp_es[i]->psz_desc );
43             if ( QString::null == language )
44             {
45                 language += i18n( "Language" );
46                 language += " " + i_item;
47             }
48             KRadioAction *action = new KRadioAction( language, 0, this, "language_action" );
49             fLanguageList->insert( action );
50
51             if( /* p_es == */ fInterfaceThread->p_sys->p_input->stream.pp_es[i] )
52             {
53                 /* don't lose p_item when we append into menu */
54                 //p_item_active = p_item;
55             }
56         }
57     }
58
59     vlc_mutex_unlock( &fInterfaceThread->p_sys->p_input->stream.stream_lock );
60
61 #if 0
62     /* link the new menu to the menubar item */
63     gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
64
65     /* acitvation will call signals so we can only do it
66      * when submenu is attached to menu - to get intf_window */
67     if( p_item_active != NULL )
68     {
69         gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
70                                         TRUE );
71     }
72 #endif
73
74     /* be sure that menu is sensitive if non empty */
75     if ( i_item > 0 )
76     {
77         fLanguageList->setEnabled( true );
78     }
79 }
80
81 /** this method is called when the user selects a language */
82 void KTitleMenu::languageSelectedSlot()
83 {
84 }