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