]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.cpp
Various strings change and capitalisation changes to match the guidelines.
[vlc] / modules / gui / qt4 / menus.cpp
1 /*****************************************************************************
2  * menus.cpp : Qt menus
3  *****************************************************************************
4  * Copyright © 2006-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Jean-Philippe André <jpeg@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * ( at your option ) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /** \todo
27  * - Remove static currentGroup
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <vlc_common.h>
35
36 #include <vlc_intf_strings.h>
37
38 #include "main_interface.hpp"
39 #include "menus.hpp"
40 #include "dialogs_provider.hpp"
41 #include "input_manager.hpp"
42
43 #include <QMenu>
44 #include <QMenuBar>
45 #include <QAction>
46 #include <QActionGroup>
47 #include <QSignalMapper>
48 #include <QSystemTrayIcon>
49
50 /*
51   This file defines the main menus and the pop-up menu (right-click menu)
52   and the systray menu (in that order in the file)
53
54   There are 3 menus that have to be rebuilt everytime there are called:
55   Audio, Video, Navigation
56   3 functions are building those menus: AudioMenu, VideoMenu, NavigMenu
57   and 3 functions associated are collecting the objects :
58   InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder.
59
60   A QSignalMapper decides when to rebuild those menus cf MenuFunc in the .hpp
61   Just before one of those menus are aboutToShow(), they are rebuild.
62
63
64   */
65
66 enum
67 {
68     ITEM_NORMAL,
69     ITEM_CHECK,
70     ITEM_RADIO
71 };
72
73 static QActionGroup *currentGroup;
74
75 // Add static entries to menus
76 void addDPStaticEntry( QMenu *menu,
77                        const QString text,
78                        const char *help,
79                        const char *icon,
80                        const char *member,
81                        const char *shortcut = NULL )
82 {
83     QAction *action = NULL;
84     if( !EMPTY_STR( icon ) > 0 )
85     {
86         if( !EMPTY_STR( shortcut ) > 0 )
87             action = menu->addAction( QIcon( icon ), text, THEDP,
88                                       member, qtr( shortcut ) );
89         else
90             action = menu->addAction( QIcon( icon ), text, THEDP, member );
91     }
92     else
93     {
94         if( !EMPTY_STR( shortcut ) > 0 )
95             action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
96         else
97             action = menu->addAction( text, THEDP, member );
98     }
99     action->setData( "_static_" );
100 }
101
102 void addMIMStaticEntry( intf_thread_t *p_intf,
103                         QMenu *menu,
104                         const QString text,
105                         const char *help,
106                         const char *icon,
107                         const char *member )
108 {
109     if( strlen( icon ) > 0 )
110     {
111         QAction *action = menu->addAction( text, THEMIM,  member );
112         action->setIcon( QIcon( icon ) );
113     }
114     else
115     {
116         menu->addAction( text, THEMIM, member );
117     }
118 }
119
120 void EnableDPStaticEntries( QMenu *menu, bool enable = true )
121 {
122     if( !menu )
123         return;
124
125     QAction *action;
126     foreach( action, menu->actions() )
127     {
128         if( action->data().toString() == "_static_" )
129             action->setEnabled( enable );
130     }
131 }
132
133 /**
134  * \return Number of static entries
135  */
136 int DeleteNonStaticEntries( QMenu *menu )
137 {
138     int i_ret = 0;
139     QAction *action;
140     if( !menu )
141         return VLC_EGENERIC;
142     foreach( action, menu->actions() )
143     {
144         if( action->data().toString() != "_static_" )
145             delete action;
146         else
147             i_ret++;
148     }
149 }
150
151 /*****************************************************************************
152  * Definitions of variables for the dynamic menus
153  *****************************************************************************/
154 #define PUSH_VAR( var ) varnames.push_back( var ); \
155     objects.push_back( p_object ? p_object->i_object_id : 0 )
156
157 #define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
158     objects.push_back( p_input ? p_input->i_object_id : 0 );
159
160 #define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
161     objects.push_back( 0 ); varnames.push_back( "" ); \
162     i_last_separator = objects.size(); }
163
164 static int InputAutoMenuBuilder( vlc_object_t *p_object,
165         vector<int> &objects,
166         vector<const char *> &varnames )
167 {
168     PUSH_VAR( "bookmark" );
169     PUSH_VAR( "title" );
170     PUSH_VAR( "chapter" );
171     PUSH_VAR( "program" );
172     PUSH_VAR( "navigation" );
173     PUSH_VAR( "dvd_menus" );
174     return VLC_SUCCESS;
175 }
176
177 static int VideoAutoMenuBuilder( vlc_object_t *p_object,
178         input_thread_t *p_input,
179         vector<int> &objects,
180         vector<const char *> &varnames )
181 {
182     PUSH_INPUTVAR( "video-es" );
183     PUSH_INPUTVAR( "spu-es" );
184     PUSH_VAR( "fullscreen" );
185     PUSH_VAR( "zoom" );
186     PUSH_VAR( "deinterlace" );
187     PUSH_VAR( "aspect-ratio" );
188     PUSH_VAR( "crop" );
189     PUSH_VAR( "video-on-top" );
190     PUSH_VAR( "directx-wallpaper" );
191     PUSH_VAR( "video-snapshot" );
192
193     if( p_object )
194     {
195         vlc_object_t *p_dec_obj = ( vlc_object_t * )vlc_object_find( p_object,
196                 VLC_OBJECT_DECODER,
197                 FIND_PARENT );
198         if( p_dec_obj )
199         {
200             vlc_object_t *p_object = p_dec_obj;
201             PUSH_VAR( "ffmpeg-pp-q" );
202             vlc_object_release( p_dec_obj );
203         }
204     }
205     return VLC_SUCCESS;
206 }
207
208 static int AudioAutoMenuBuilder( vlc_object_t *p_object,
209         input_thread_t *p_input,
210         vector<int> &objects,
211         vector<const char *> &varnames )
212 {
213     PUSH_INPUTVAR( "audio-es" );
214     PUSH_VAR( "audio-device" );
215     PUSH_VAR( "audio-channels" );
216     PUSH_VAR( "equalizer" );
217     PUSH_VAR( "visual" );
218     return VLC_SUCCESS;
219 }
220
221 static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
222 {
223     QAction *action;
224     foreach( action, menu->actions() )
225     {
226         if( action->data().toString() == psz_var )
227             return action;
228     }
229     return NULL;
230 }
231
232 static QAction * FindActionWithText( QMenu *menu, QString &text )
233 {
234     QAction *action;
235     foreach( action, menu->actions() )
236     {
237         if( action->text() == text )
238             return action;
239     }
240     return NULL;
241 }
242
243 /*****************************************************************************
244  * All normal menus
245  * Simple Code
246  *****************************************************************************/
247
248 #define BAR_ADD( func, title ) { \
249     QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
250
251 #define BAR_DADD( func, title, id ) { \
252     QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
253     MenuFunc *f = new MenuFunc( _menu, id ); \
254     CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
255     THEDP->menusUpdateMapper->setMapping( _menu, f ); }
256
257 #define ACT_ADD( _menu, val, title ) { \
258     QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
259     _menu->addAction( _action ); }
260
261 /**
262  * Main Menu Bar Creation
263  **/
264 void QVLCMenu::createMenuBar( MainInterface *mi,
265                               intf_thread_t *p_intf,
266                               bool visual_selector_enabled )
267 {
268     /* QMainWindows->menuBar()
269        gives the QProcess::destroyed timeout issue on Cleanlooks style with
270        setDesktopAware set to false */
271     QMenuBar *bar = mi->menuBar();
272     BAR_ADD( FileMenu(), qtr( "&Media" ) );
273     BAR_ADD( PlaylistMenu( p_intf, mi ), qtr( "&Playlist" ) );
274     BAR_ADD( ToolsMenu( p_intf, NULL, mi, visual_selector_enabled, true ),
275              qtr( "&Tools" ) );
276     BAR_DADD( AudioMenu( p_intf, NULL ), qtr( "&Audio" ), 1 );
277     BAR_DADD( VideoMenu( p_intf, NULL ), qtr( "&Video" ), 2 );
278     BAR_DADD( NavigMenu( p_intf, NULL ), qtr( "&Playback" ), 3 );
279     BAR_ADD( HelpMenu( NULL ), qtr( "&Help" ) );
280 }
281 #undef BAR_ADD
282 #undef BAR_DADD
283
284 /**
285  * Media ( File ) Menu
286  * Opening, streaming and quit
287  **/
288 QMenu *QVLCMenu::FileMenu()
289 {
290     QMenu *menu = new QMenu();
291
292     addDPStaticEntry( menu, qtr( "&Open File..." ), "",
293         ":/pixmaps/file-asym_16px.png", SLOT( openFileDialog() ), "Ctrl+O" );
294     addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ), "",
295         ":/pixmaps/folder-grey_16px.png", SLOT( PLAppendDir() ), "Ctrl+F" );
296     addDPStaticEntry( menu, qtr( "Open &Disc..." ), "",
297         ":/pixmaps/disc_16px.png", SLOT( openDiscDialog() ), "Ctrl+D" );
298     addDPStaticEntry( menu, qtr( "Open &Network..." ), "",
299         ":/pixmaps/network_16px.png", SLOT( openNetDialog() ), "Ctrl+N" );
300     addDPStaticEntry( menu, qtr( "Open &Capture Device..." ), "",
301         ":/pixmaps/capture-card_16px.png", SLOT( openCaptureDialog() ),
302         "Ctrl+C" );
303     menu->addSeparator();
304
305     addDPStaticEntry( menu, qtr( "&Streaming..." ), "",
306         ":/pixmaps/menus_stream_16px.png", SLOT( openThenStreamingDialogs() ),
307         "Ctrl+S" );
308     addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "", "",
309         SLOT( openThenTranscodingDialogs() ), "Ctrl+R" );
310     menu->addSeparator();
311
312     addDPStaticEntry( menu, qtr( "&Quit" ) , "",
313         ":/pixmaps/menus_quit_16px.png", SLOT( quit() ), "Ctrl+Q" );
314     return menu;
315 }
316
317 /* Playlist/MediaLibrary Control */
318 QMenu *QVLCMenu::PlaylistMenu( intf_thread_t *p_intf, MainInterface *mi )
319 {
320     QMenu *menu = new QMenu();
321     menu->addMenu( SDMenu( p_intf ) );
322     menu->addAction( QIcon( ":/pixmaps/playlist_16px.png" ),
323                      qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) );
324     menu->addSeparator();
325
326     addDPStaticEntry( menu, qtr( I_PL_LOAD ), "", "", SLOT( openAPlaylist() ),
327         "Ctrl+X" );
328     addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", "", SLOT( saveAPlaylist() ),
329         "Ctrl+Y" );
330     menu->addSeparator();
331     menu->addAction( qtr( "Undock from Interface" ), mi,
332                      SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );
333     return menu;
334 }
335
336 /**
337  * Tools/View Menu
338  * This is kept in the same menu for now, but could change if it gets much
339  * longer.
340  * This menu can be an interface menu but also a right click menu.
341  **/
342 QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf,
343                             QMenu *current,
344                             MainInterface *mi,
345                             bool visual_selector_enabled,
346                             bool with_intf )
347 {
348     QMenu *menu = new QMenu( current );
349     if( mi )
350     {
351         menu->addAction( QIcon( ":/pixmaps/playlist_16px.png" ),
352                          qtr( "Playlist..." ), mi, SLOT( togglePlaylist() ),
353                          qtr( "Ctrl+L" ) );
354     }
355     addDPStaticEntry( menu, qtr( I_MENU_EXT ), "",
356         ":/pixmaps/menus_settings_16px.png", SLOT( extendedDialog() ),
357         "Ctrl+E" );
358
359     menu->addSeparator();
360
361     if( with_intf )
362     {
363         QMenu *intfmenu = InterfacesMenu( p_intf, menu );
364         intfmenu->setTitle( qtr( "Add Interfaces" ) );
365         MenuFunc *f = new MenuFunc( intfmenu, 4 );
366         CONNECT( intfmenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
367         THEDP->menusUpdateMapper->setMapping( intfmenu, f );
368         menu->addMenu( intfmenu );
369         menu->addSeparator();
370     }
371     if( mi )
372     {
373         /* Minimal View */
374         QAction *action = menu->addAction( qtr( "Minimal View..." ), mi,
375                                 SLOT( toggleMinimalView() ), qtr( "Ctrl+H" ) );
376         action->setCheckable( true );
377         if( mi->getControlsVisibilityStatus() & CONTROLS_VISIBLE )
378             action->setChecked( true );
379
380         /* FullScreen View */
381         action = menu->addAction( qtr( "Toggle Fullscreen Interface" ), mi,
382                                   SLOT( toggleFullScreen() ), QString( "F11" ) );
383
384         /* Advanced Controls */
385         action = menu->addAction( qtr( "Advanced Controls" ), mi,
386                                   SLOT( toggleAdvanced() ) );
387         action->setCheckable( true );
388         if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
389             action->setChecked( true );
390 #if 0 /* For Visualisations. Not yet working */
391         adv = menu->addAction( qtr( "Visualizations selector" ),
392                 mi, SLOT( visual() ) );
393         adv->setCheckable( true );
394         if( visual_selector_enabled ) adv->setChecked( true );
395 #endif
396     }
397
398     menu->addSeparator();
399
400     addDPStaticEntry( menu, qtr( I_MENU_MSG ), "",
401         ":/pixmaps/menus_messages_16px.png", SLOT( messagesDialog() ),
402         "Ctrl+M" );
403     addDPStaticEntry( menu, qtr( I_MENU_INFO ) , "", "",
404         SLOT( mediaInfoDialog() ), "Ctrl+I" );
405     addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) , "",
406         ":/pixmaps/menus_info_16px.png", SLOT( mediaCodecDialog() ), "Ctrl+J" );
407     addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ), "","",
408                       SLOT( bookmarksDialog() ), "Ctrl+B" );
409 #ifdef ENABLE_VLM
410     addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", "", SLOT( vlmDialog() ),
411         "Ctrl+W" );
412 #endif
413
414     menu->addSeparator();
415     addDPStaticEntry( menu, qtr( "Preferences..." ), "",
416         ":/pixmaps/menus_preferences_16px.png", SLOT( prefsDialog() ), "Ctrl+P" );
417     return menu;
418 }
419
420 /**
421  * Interface Sub-Menu, to list extras interface and skins
422  **/
423 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
424 {
425     vector<int> objects;
426     vector<const char *> varnames;
427     /** \todo add "switch to XXX" */
428     varnames.push_back( "intf-add" );
429     objects.push_back( p_intf->i_object_id );
430
431     QMenu *submenu = new QMenu( current );
432     QMenu *menu = Populate( p_intf, submenu, varnames, objects );
433
434     return menu;
435 }
436
437 /**
438  * Main Audio Menu
439  */
440 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
441 {
442     vector<int> objects;
443     vector<const char *> varnames;
444     vlc_object_t *p_aout;
445     input_thread_t *p_input;
446
447     if( !current ) current = new QMenu();
448
449     if( current->isEmpty() )
450     {
451         ACT_ADD( current, "audio-es", qtr( "Audio &Track" ) );
452         ACT_ADD( current, "audio-device", qtr( "Audio &Device" ) );
453         ACT_ADD( current, "audio-channels", qtr( "Audio &Channels" ) );
454         ACT_ADD( current, "equalizer", qtr( "&Equalizer" ) );
455         current->addSeparator();
456         ACT_ADD( current, "visual", qtr( "&Visualizations" ) );
457     }
458
459     p_input = THEMIM->getInput();
460     if( p_input )
461         vlc_object_yield( p_input );
462     p_aout = ( vlc_object_t * ) vlc_object_find( p_intf,
463                                                  VLC_OBJECT_AOUT,
464                                                  FIND_ANYWHERE );
465
466     AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
467
468     if( p_aout )
469         vlc_object_release( p_aout );
470     if( p_input )
471         vlc_object_release( p_input );
472
473     return Populate( p_intf, current, varnames, objects );
474 }
475
476 /**
477  * Main Video Menu
478  * Subtitles are part of Video.
479  **/
480 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
481 {
482     vlc_object_t *p_vout;
483     input_thread_t *p_input;
484     vector<int> objects;
485     vector<const char *> varnames;
486
487     if( !current ) current = new QMenu();
488
489     if( current->isEmpty() )
490     {
491         ACT_ADD( current, "video-es", qtr( "Video &Track" ) );
492
493         QAction *action;
494         QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
495         action = current->addMenu( submenu );
496         action->setData( "spu-es" );
497         addDPStaticEntry( submenu, qtr( "Load File..." ), "", "",
498                           SLOT( loadSubtitlesFile() ) );
499         submenu->addSeparator();
500
501         ACT_ADD( current, "fullscreen", qtr( "Toggle &Fullscreen" ) );
502         ACT_ADD( current, "zoom", qtr( "&Zoom" ) );
503         ACT_ADD( current, "deinterlace", qtr( "&Deinterlace" ) );
504         ACT_ADD( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
505         ACT_ADD( current, "crop", qtr( "&Crop" ) );
506         ACT_ADD( current, "video-on-top", qtr( "Always &On Top" ) );
507         /* ACT_ADD( current, "directx-wallpaper", qtr( "DirectX Wallpaper" ) ); */
508         ACT_ADD( current, "video-snapshot", qtr( "Snapshot" ) );
509         /* ACT_ADD( current, "ffmpeg-pp-q", qtr( "Decoder" ) ); */
510     }
511
512     p_input = THEMIM->getInput();
513     if( p_input )
514         vlc_object_yield( p_input );
515     p_vout = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_VOUT,
516             FIND_ANYWHERE );
517
518     VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
519
520     if( p_vout )
521         vlc_object_release( p_vout );
522     if( p_input )
523         vlc_object_release( p_input );
524
525     return Populate( p_intf, current, varnames, objects );
526 }
527
528 /**
529  * Navigation Menu
530  * For DVD, MP4, MOV and other chapter based format
531  **/
532 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
533 {
534     vlc_object_t *p_object;
535     vector<int> objects;
536     vector<const char *> varnames;
537
538     if( !menu ) menu = new QMenu();
539
540     if( menu->isEmpty() )
541     {
542         addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ), "","",
543                           SLOT( gotoTimeDialog() ), "Ctrl+T" );
544         menu->addSeparator();
545
546         ACT_ADD( menu, "bookmark", qtr( "&Bookmarks" ) );
547         ACT_ADD( menu, "title", qtr( "&Title" ) );
548         ACT_ADD( menu, "chapter", qtr( "&Chapter" ) );
549         ACT_ADD( menu, "program", qtr( "&Program" ) );
550         ACT_ADD( menu, "navigation", qtr( "&Navigation" ) );
551     }
552
553     p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_INPUT,
554             FIND_ANYWHERE );
555     InputAutoMenuBuilder(  p_object, objects, varnames );
556     PUSH_VAR( "prev-title" );
557     PUSH_VAR( "next-title" );
558     PUSH_VAR( "prev-chapter" );
559     PUSH_VAR( "next-chapter" );
560     EnableDPStaticEntries( menu, ( p_object != NULL ) );
561     if( p_object )
562     {
563         vlc_object_release( p_object );
564     }
565     return Populate( p_intf, menu, varnames, objects, true );
566 }
567
568 /**
569  * Service Discovery SubMenu
570  **/
571 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
572 {
573     QMenu *menu = new QMenu();
574     menu->setTitle( qtr( I_PL_SD ) );
575     char **ppsz_longnames;
576     char **ppsz_names = services_discovery_GetServicesNames( p_intf,
577                                                              &ppsz_longnames );
578     if( !ppsz_names )
579         return menu;
580
581     char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
582     for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
583     {
584         QAction *a = new QAction( qfu( *ppsz_longname ), menu );
585         a->setCheckable( true );
586         if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
587             a->setChecked( true );
588         CONNECT( a , triggered(), THEDP->SDMapper, map() );
589         THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
590         menu->addAction( a );
591
592         if( !strcmp( *ppsz_name, "podcast" ) )
593         {
594             QAction *b = new QAction( qfu( "Configure podcasts..." ), menu );
595             //b->setEnabled( a->isChecked() );
596             menu->addAction( b );
597             CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
598         }
599         free( *ppsz_name );
600         free( *ppsz_longname );
601     }
602     free( ppsz_names );
603     free( ppsz_longnames );
604     return menu;
605 }
606 /**
607  * Help/About Menu
608 **/
609 QMenu *QVLCMenu::HelpMenu( QMenu *current )
610 {
611     QMenu *menu = new QMenu( current );
612     addDPStaticEntry( menu, qtr( "Help..." ) , "",
613         ":/pixmaps/menus_help_16px.png", SLOT( helpDialog() ), "F1" );
614 #ifdef UPDATE_CHECK
615     addDPStaticEntry( menu, qtr( "Check for Updates..." ) , "", "",
616                       SLOT( updateDialog() ), "");
617 #endif
618     menu->addSeparator();
619     addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), "", "", SLOT( aboutDialog() ),
620         "Ctrl+F1" );
621     return menu;
622 }
623
624 /*****************************************************************************
625  * Popup menus - Right Click menus                                           *
626  *****************************************************************************/
627 #define POPUP_BOILERPLATE \
628     unsigned int i_last_separator = 0; \
629     vector<int> objects; \
630     vector<const char *> varnames; \
631     input_thread_t *p_input = THEMIM->getInput();
632
633 #define CREATE_POPUP \
634     Populate( p_intf, menu, varnames, objects ); \
635     p_intf->p_sys->p_popup_menu = menu; \
636     menu->popup( QCursor::pos() ); \
637     p_intf->p_sys->p_popup_menu = NULL; \
638     i_last_separator = 0;
639
640 void QVLCMenu::PopupMenuControlEntries( QMenu *menu,
641                                         intf_thread_t *p_intf,
642                                         input_thread_t *p_input )
643 {
644     if( p_input )
645     {
646         vlc_value_t val;
647         var_Get( p_input, "state", &val );
648         if( val.i_int == PLAYING_S )
649             addMIMStaticEntry( p_intf, menu, qtr( "Pause" ), "",
650                     ":/pixmaps/pause_16px.png", SLOT( togglePlayPause() ) );
651         else
652             addMIMStaticEntry( p_intf, menu, qtr( "Play" ), "",
653                     ":/pixmaps/play_16px.png", SLOT( togglePlayPause() ) );
654     }
655     else if( THEPL->items.i_size )
656         addMIMStaticEntry( p_intf, menu, qtr( "Play" ), "",
657                 ":/pixmaps/play_16px.png", SLOT( togglePlayPause() ) );
658     else
659         addDPStaticEntry( menu, qtr( "Play" ), "",
660                 ":/pixmaps/play_16px.png", SLOT( openDialog() ) );
661
662     addMIMStaticEntry( p_intf, menu, qtr( "Stop" ), "",
663             ":/pixmaps/stop_16px.png", SLOT( stop() ) );
664     addMIMStaticEntry( p_intf, menu, qtr( "Previous" ), "",
665             ":/pixmaps/previous_16px.png", SLOT( prev() ) );
666     addMIMStaticEntry( p_intf, menu, qtr( "Next" ), "",
667             ":/pixmaps/next_16px.png", SLOT( next() ) );
668 }
669
670 void QVLCMenu::PopupMenuStaticEntries( intf_thread_t *p_intf, QMenu *menu )
671 {
672 #if 0
673     QMenu *toolsmenu = ToolsMenu( p_intf, menu, false, true );
674     toolsmenu->setTitle( qtr( "Tools" ) );
675     menu->addMenu( toolsmenu );
676 #endif
677
678     QMenu *openmenu = new QMenu( qtr( "Open" ), menu );
679     addDPStaticEntry( openmenu, qtr( "&Open File..." ), "",
680         ":/pixmaps/file-asym_16px.png", SLOT( openFileDialog() ) );
681     addDPStaticEntry( openmenu, qtr( I_OPEN_FOLDER ), "",
682         ":/pixmaps/folder-grey_16px.png", SLOT( PLAppendDir() ) );
683     addDPStaticEntry( openmenu, qtr( "Open &Disc..." ), "",
684         ":/pixmaps/disc_16px.png", SLOT( openDiscDialog() ) );
685     addDPStaticEntry( openmenu, qtr( "Open &Network..." ), "",
686         ":/pixmaps/network_16px.png", SLOT( openNetDialog() ) );
687     addDPStaticEntry( openmenu, qtr( "Open &Capture Device..." ), "",
688         ":/pixmaps/capture-card_16px.png", SLOT( openCaptureDialog() ) );
689     menu->addMenu( openmenu );
690
691     menu->addSeparator();
692 #if 0
693     QMenu *helpmenu = HelpMenu( menu );
694     helpmenu->setTitle( qtr( "Help" ) );
695     menu->addMenu( helpmenu );
696 #endif
697
698     addDPStaticEntry( menu, qtr( "Quit" ), "", ":/pixmaps/menus_quit_16px.png",
699                       SLOT( quit() ), "Ctrl+Q" );
700 }
701
702 /* Video Tracks and Subtitles tracks */
703 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
704 {
705     POPUP_BOILERPLATE;
706     if( p_input )
707     {
708         vlc_object_yield( p_input );
709         vlc_object_t *p_vout = ( vlc_object_t * )vlc_object_find( p_input,
710                 VLC_OBJECT_VOUT, FIND_CHILD );
711         if( p_vout )
712         {
713             VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
714             vlc_object_release( p_vout );
715         }
716         vlc_object_release( p_input );
717     }
718     QMenu *menu = new QMenu();
719     CREATE_POPUP;
720 }
721
722 /* Audio Tracks */
723 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
724 {
725     POPUP_BOILERPLATE;
726     if( p_input )
727     {
728         vlc_object_yield( p_input );
729         vlc_object_t *p_aout = ( vlc_object_t * )vlc_object_find( p_input,
730                 VLC_OBJECT_AOUT, FIND_ANYWHERE );
731         AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
732         if( p_aout )
733             vlc_object_release( p_aout );
734         vlc_object_release( p_input );
735     }
736     QMenu *menu = new QMenu();
737     CREATE_POPUP;
738 }
739
740 /* Navigation stuff, and general menus ( open ) */
741 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
742 {
743     vlc_value_t val;
744     POPUP_BOILERPLATE;
745
746     if( p_input )
747     {
748         vlc_object_yield( p_input );
749         varnames.push_back( "audio-es" );
750         InputAutoMenuBuilder( VLC_OBJECT( p_input ), objects, varnames );
751         PUSH_SEPARATOR;
752     }
753
754     QMenu *menu = new QMenu();
755     Populate( p_intf, menu, varnames, objects );
756
757     menu->addSeparator();
758     PopupMenuControlEntries( menu, p_intf, p_input );
759
760     menu->addSeparator();
761     PopupMenuStaticEntries( p_intf, menu );
762
763     p_intf->p_sys->p_popup_menu = menu;
764     menu->popup( QCursor::pos() );
765     p_intf->p_sys->p_popup_menu = NULL;
766 }
767
768 /* Main Menu that sticks everything together  */
769 void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
770 {
771     MainInterface *mi = p_intf->p_sys->p_mi;
772     if( show )
773     {
774         /* Delete and recreate a popup if there is one */
775         if( p_intf->p_sys->p_popup_menu )
776             delete p_intf->p_sys->p_popup_menu;
777
778         QMenu *menu = new QMenu();
779         QMenu *submenu;
780         QAction *action;
781         bool b_isFullscreen = false;
782
783         POPUP_BOILERPLATE;
784
785         PopupMenuControlEntries( menu, p_intf, p_input );
786         menu->addSeparator();
787
788         if( p_input )
789         {
790             vlc_object_t *p_vout = (vlc_object_t *)
791                 vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
792
793             /* Add a fullscreen switch button */
794             if( p_vout )
795             {
796                 vlc_value_t val;
797                 var_Get( p_vout, "fullscreen", &val );
798                 b_isFullscreen = !( !val.b_bool );
799                 if( b_isFullscreen )
800                     CreateAndConnect( menu, "fullscreen",
801                             qtr( "Leave Fullscreen" ),"" , ITEM_NORMAL,
802                             p_vout->i_object_id, val, VLC_VAR_BOOL,
803                             b_isFullscreen );
804                 vlc_object_release( p_vout );
805             }
806
807             menu->addSeparator();
808
809             vlc_object_yield( p_input );
810             InputAutoMenuBuilder( VLC_OBJECT( p_input ), objects, varnames );
811             vlc_object_release( p_input );
812
813             submenu = new QMenu( menu );
814             action = menu->addMenu( AudioMenu( p_intf, submenu ) );
815             action->setText( qtr( "&Audio" ) );
816             if( action->menu()->isEmpty() )
817                 action->setEnabled( false );
818
819             submenu = new QMenu( menu );
820             action = menu->addMenu( VideoMenu( p_intf, submenu ) );
821             action->setText( qtr( "&Video" ) );
822             if( action->menu()->isEmpty() )
823                 action->setEnabled( false );
824
825             submenu = new QMenu( menu );
826             action = menu->addMenu( NavigMenu( p_intf, submenu ) );
827             action->setText( qtr( "&Playback" ) );
828             if( action->menu()->isEmpty() )
829                 action->setEnabled( false );
830         }
831
832         menu->addSeparator();
833
834         /* Add some special entries for windowed mode: Interface Menu */
835         if( !b_isFullscreen )
836         {
837             submenu = new QMenu( qtr( "Interface" ), menu );
838             submenu->addAction( QIcon( ":/pixmaps/playlist_16px.png" ),
839                      qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) );
840             addDPStaticEntry( submenu, qtr( I_MENU_EXT ), "",
841                 ":/pixmaps/menus_settings_16px.png", SLOT( extendedDialog() ) );
842             action = submenu->addAction( QIcon( "" ),
843                  qtr( "Minimal View..." ), mi, SLOT( toggleMinimalView() ) );
844             action->setCheckable( true );
845             action->setChecked( !( mi->getControlsVisibilityStatus() &
846                                    CONTROLS_VISIBLE ) );
847             action = submenu->addAction( QIcon( "" ),
848                  qtr( "Toggle Fullscreen Interface" ),
849                  mi, SLOT( toggleFullScreen() ) );
850             action->setCheckable( true );
851             action->setChecked( mi->isFullScreen() );
852             menu->addMenu( submenu );
853         }
854
855         PopupMenuStaticEntries( p_intf, menu );
856
857         p_intf->p_sys->p_popup_menu = menu;
858         p_intf->p_sys->p_popup_menu->popup( QCursor::pos() );
859     }
860     else
861     {
862         // destroy popup if there is one
863         delete p_intf->p_sys->p_popup_menu;
864         p_intf->p_sys->p_popup_menu = NULL;
865     }
866 }
867
868 #undef ACT_ADD
869
870 /************************************************************************
871  * Systray Menu                                                         *
872  ************************************************************************/
873
874 void QVLCMenu::updateSystrayMenu( MainInterface *mi,
875                                   intf_thread_t *p_intf,
876                                   bool b_force_visible )
877 {
878     POPUP_BOILERPLATE;
879
880     /* Get the systray menu and clean it */
881     QMenu *sysMenu = mi->getSysTrayMenu();
882     sysMenu->clear();
883
884     /* Hide / Show VLC and cone */
885     if( mi->isVisible() || b_force_visible )
886     {
887         sysMenu->addAction( QIcon( ":/vlc16.png" ),
888                             qtr( "Hide VLC media player in taskbar" ), mi,
889                             SLOT( toggleUpdateSystrayMenu() ) );
890     }
891     else
892     {
893         sysMenu->addAction( QIcon( ":/vlc16.png" ),
894                             qtr( "Show VLC media player" ), mi,
895                             SLOT( toggleUpdateSystrayMenu() ) );
896     }
897
898     sysMenu->addSeparator();
899     PopupMenuControlEntries( sysMenu, p_intf, p_input );
900
901     sysMenu->addSeparator();
902     addDPStaticEntry( sysMenu, qtr( "&Open Media" ), "",
903             ":/pixmaps/file-wide_16px.png", SLOT( openFileDialog() ), "" );
904     addDPStaticEntry( sysMenu, qtr( "&Quit" ) , "",
905             ":/pixmaps/menus_quit_16px.png", SLOT( quit() ), "" );
906
907     /* Set the menu */
908     mi->getSysTray()->setContextMenu( sysMenu );
909 }
910
911 #undef PUSH_VAR
912 #undef PUSH_SEPARATOR
913
914 /*************************************************************************
915  * Builders for automenus
916  *************************************************************************/
917 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
918                             QMenu *current,
919                             vector< const char *> & varnames,
920                             vector<int> & objects,
921                             bool append )
922 {
923     QMenu *menu = current;
924     if( !menu ) menu = new QMenu();
925
926     /* Disable all non static entries */
927     QAction *p_action;
928     foreach( p_action, menu->actions() )
929     {
930         if( p_action->data().toString() != "_static_" )
931             p_action->setEnabled( false );
932     }
933
934     currentGroup = NULL;
935
936     vlc_object_t *p_object;
937     int i;
938
939     for( i = 0; i < ( int )objects.size() ; i++ )
940     {
941         if( !varnames[i] || !*varnames[i] )
942         {
943             menu->addSeparator();
944             continue;
945         }
946
947         if( objects[i] == 0 )
948         {
949             p_object = NULL;
950         }
951         else
952         {
953             p_object = ( vlc_object_t * )vlc_object_get( objects[i] );
954             if( !p_object )
955             {
956                 msg_Dbg( p_intf, "object %d not found !", objects[i] );
957                 continue;
958             }
959         }
960
961         /* Ugly specific stuff */
962         if( strstr( varnames[i], "intf-add" ) )
963             UpdateItem( p_intf, menu, varnames[i], p_object, false );
964         else
965             UpdateItem( p_intf, menu, varnames[i], p_object, true );
966         if( p_object )
967             vlc_object_release( p_object );
968     }
969     return menu;
970 }
971
972 /*****************************************************************************
973  * Private methods.
974  *****************************************************************************/
975
976 static bool IsMenuEmpty( const char *psz_var,
977                          vlc_object_t *p_object,
978                          bool b_root = true )
979 {
980     vlc_value_t val, val_list;
981     int i_type, i_result, i;
982
983     /* Check the type of the object variable */
984     i_type = var_Type( p_object, psz_var );
985
986     /* Check if we want to display the variable */
987     if( !( i_type & VLC_VAR_HASCHOICE ) ) return false;
988
989     var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
990     if( val.i_int == 0 ) return true;
991
992     if( ( i_type & VLC_VAR_TYPE ) != VLC_VAR_VARIABLE )
993     {
994         if( val.i_int == 1 && b_root ) return true;
995         else return false;
996     }
997
998     /* Check children variables in case of VLC_VAR_VARIABLE */
999     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
1000     {
1001         return true;
1002     }
1003
1004     for( i = 0, i_result = true; i < val_list.p_list->i_count; i++ )
1005     {
1006         if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
1007                     p_object, false ) )
1008         {
1009             i_result = false;
1010             break;
1011         }
1012     }
1013
1014     /* clean up everything */
1015     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
1016
1017     return i_result;
1018 }
1019
1020 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
1021
1022 void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
1023         const char *psz_var, vlc_object_t *p_object, bool b_submenu )
1024 {
1025     vlc_value_t val, text;
1026     int i_type;
1027
1028     QAction *action = FindActionWithVar( menu, psz_var );
1029     if( action )
1030         DeleteNonStaticEntries( action->menu() );
1031
1032     if( !p_object )
1033         return;
1034
1035     /* Check the type of the object variable */
1036     if( !strcmp( psz_var, "audio-es" )
1037      || !strcmp( psz_var, "video-es" ) )
1038         i_type = VLC_VAR_INTEGER | VLC_VAR_HASCHOICE;
1039     else
1040         i_type = var_Type( p_object, psz_var );
1041
1042     switch( i_type & VLC_VAR_TYPE )
1043     {
1044         case VLC_VAR_VOID:
1045         case VLC_VAR_BOOL:
1046         case VLC_VAR_VARIABLE:
1047         case VLC_VAR_STRING:
1048         case VLC_VAR_INTEGER:
1049         case VLC_VAR_FLOAT:
1050             break;
1051         default:
1052             /* Variable doesn't exist or isn't handled */
1053             return;
1054     }
1055
1056     /* Make sure we want to display the variable */
1057     if( menu->isEmpty() && IsMenuEmpty( psz_var, p_object ) )
1058         return;
1059
1060     /* Get the descriptive name of the variable */
1061     int i_ret = var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
1062     if( i_ret != VLC_SUCCESS )
1063     {
1064         text.psz_string = NULL;
1065     }
1066
1067     if( !action )
1068     {
1069         action = new QAction( TEXT_OR_VAR, menu );
1070         menu->addAction( action );
1071         action->setData( psz_var );
1072     }
1073
1074     /* Some specific stuff */
1075     bool forceDisabled = false;
1076     if( !strcmp( psz_var, "spu-es" ) )
1077     {
1078         vlc_object_t *p_vout = ( vlc_object_t* )( vlc_object_find( p_intf,
1079                                     VLC_OBJECT_VOUT, FIND_ANYWHERE ) );
1080         forceDisabled = ( p_vout == NULL );
1081         if( p_vout )
1082             vlc_object_release( p_vout );
1083     }
1084
1085     if( i_type & VLC_VAR_HASCHOICE )
1086     {
1087         /* Append choices menu */
1088         if( b_submenu )
1089         {
1090             QMenu *submenu;
1091             submenu = action->menu();
1092             if( !submenu )
1093             {
1094                 submenu = new QMenu( menu );
1095                 action->setMenu( submenu );
1096             }
1097
1098             action->setEnabled(
1099                CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 );
1100             if( forceDisabled )
1101                 action->setEnabled( false );
1102         }
1103         else
1104             CreateChoicesMenu( menu, psz_var, p_object, true );
1105         FREENULL( text.psz_string );
1106         return;
1107     }
1108
1109     switch( i_type & VLC_VAR_TYPE )
1110     {
1111         case VLC_VAR_VOID:
1112             var_Get( p_object, psz_var, &val );
1113             CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
1114                     p_object->i_object_id, val, i_type );
1115             break;
1116
1117         case VLC_VAR_BOOL:
1118             var_Get( p_object, psz_var, &val );
1119             val.b_bool = !val.b_bool;
1120             CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
1121                     p_object->i_object_id, val, i_type, !val.b_bool );
1122             break;
1123     }
1124     FREENULL( text.psz_string );
1125 }
1126
1127
1128 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
1129         vlc_object_t *p_object, bool b_root )
1130 {
1131     vlc_value_t val, val_list, text_list;
1132     int i_type, i;
1133
1134     /* Check the type of the object variable */
1135     i_type = var_Type( p_object, psz_var );
1136
1137     /* Make sure we want to display the variable */
1138     if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) )
1139         return VLC_EGENERIC;
1140
1141     switch( i_type & VLC_VAR_TYPE )
1142     {
1143         case VLC_VAR_VOID:
1144         case VLC_VAR_BOOL:
1145         case VLC_VAR_VARIABLE:
1146         case VLC_VAR_STRING:
1147         case VLC_VAR_INTEGER:
1148         case VLC_VAR_FLOAT:
1149             break;
1150         default:
1151             /* Variable doesn't exist or isn't handled */
1152             return VLC_EGENERIC;
1153     }
1154
1155     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
1156                 &val_list, &text_list ) < 0 )
1157     {
1158         return VLC_EGENERIC;
1159     }
1160
1161 #define NORMAL_OR_RADIO i_type & VLC_VAR_ISCOMMAND ? ITEM_NORMAL: ITEM_RADIO
1162 #define NOTCOMMAND !( i_type & VLC_VAR_ISCOMMAND )
1163 #define CURVAL val_list.p_list->p_values[i]
1164 #define CURTEXT text_list.p_list->p_values[i].psz_string
1165
1166     for( i = 0; i < val_list.p_list->i_count; i++ )
1167     {
1168         vlc_value_t another_val;
1169         QString menutext;
1170         QMenu *subsubmenu = new QMenu( submenu );
1171
1172         switch( i_type & VLC_VAR_TYPE )
1173         {
1174             case VLC_VAR_VARIABLE:
1175                 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
1176                 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
1177                 submenu->addMenu( subsubmenu );
1178                 break;
1179
1180             case VLC_VAR_STRING:
1181                 var_Get( p_object, psz_var, &val );
1182                 another_val.psz_string = strdup( CURVAL.psz_string );
1183                 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
1184                 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
1185                         p_object->i_object_id, another_val, i_type,
1186                         NOTCOMMAND && val.psz_string &&
1187                         !strcmp( val.psz_string, CURVAL.psz_string ) );
1188
1189                 free( val.psz_string );
1190                 break;
1191
1192             case VLC_VAR_INTEGER:
1193                 var_Get( p_object, psz_var, &val );
1194                 if( CURTEXT ) menutext = qfu( CURTEXT );
1195                 else menutext.sprintf( "%d", CURVAL.i_int );
1196                 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
1197                         p_object->i_object_id, CURVAL, i_type,
1198                         NOTCOMMAND && CURVAL.i_int == val.i_int );
1199                 break;
1200
1201             case VLC_VAR_FLOAT:
1202                 var_Get( p_object, psz_var, &val );
1203                 if( CURTEXT ) menutext = qfu( CURTEXT );
1204                 else menutext.sprintf( "%.2f", CURVAL.f_float );
1205                 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
1206                         p_object->i_object_id, CURVAL, i_type,
1207                         NOTCOMMAND && CURVAL.f_float == val.f_float );
1208                 break;
1209
1210             default:
1211                 break;
1212         }
1213     }
1214     currentGroup = NULL;
1215
1216     /* clean up everything */
1217     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
1218
1219 #undef NORMAL_OR_RADIO
1220 #undef NOTCOMMAND
1221 #undef CURVAL
1222 #undef CURTEXT
1223     return VLC_SUCCESS;
1224 }
1225
1226 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
1227         QString text, QString help,
1228         int i_item_type, int i_object_id,
1229         vlc_value_t val, int i_val_type,
1230         bool checked )
1231 {
1232     QAction *action = FindActionWithVar( menu, psz_var );
1233     if( !action )
1234     {
1235         /* This is a value */
1236         action = FindActionWithText( menu, text );
1237         if( !action )
1238         {
1239             action = new QAction( text, menu );
1240             menu->addAction( action );
1241         }
1242     }
1243
1244     action->setText( text );
1245     action->setToolTip( help );
1246
1247     action->setEnabled( i_object_id != 0 );
1248
1249     if( i_item_type == ITEM_CHECK )
1250     {
1251         action->setCheckable( true );
1252     }
1253     else if( i_item_type == ITEM_RADIO )
1254     {
1255         action->setCheckable( true );
1256         if( !currentGroup )
1257             currentGroup = new QActionGroup( menu );
1258         currentGroup->addAction( action );
1259     }
1260
1261     action->setChecked( checked );
1262
1263     MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
1264             val, psz_var );
1265     CONNECT( action, triggered(), THEDP->menusMapper, map() );
1266     THEDP->menusMapper->setMapping( action, itemData );
1267     menu->addAction( action );
1268 }
1269
1270 void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
1271 {
1272     MenuItemData *itemData = qobject_cast<MenuItemData *>( data );
1273     vlc_object_t *p_object = ( vlc_object_t * )vlc_object_get( itemData->i_object_id );
1274     if( p_object == NULL ) return;
1275
1276     var_Set( p_object, itemData->psz_var, itemData->val );
1277     vlc_object_release( p_object );
1278 }
1279