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