]> git.sesse.net Git - vlc/blob - plugins/kde/kde_menu.cpp
Some heavy changes today:
[vlc] / plugins / kde / kde_menu.cpp
1 /***************************************************************************
2                           kde_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 "kde_menu.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 #if 0
59     /* link the new menu to the menubar item */
60     gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
61
62     /* acitvation will call signals so we can only do it
63      * when submenu is attached to menu - to get intf_window */
64     if( p_item_active != NULL )
65     {
66         gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
67                                         TRUE );
68     }
69 #endif
70
71     /* be sure that menu is sensitive if non empty */
72     if ( i_item > 0 )
73     {
74         fLanguageList->setEnabled( true );
75     }
76 }
77
78 /** this method is called when the user selects a language */
79 void KTitleMenu::languageSelectedSlot()
80 {
81 }