1 /*****************************************************************************
2 * menus.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
7 * Authors: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
35 #include "wxwindows.h"
37 class wxMenuItemExt: public wxMenuItem
41 wxMenuItemExt( wxMenu* parentMenu, int id, const wxString& text,
42 const wxString& helpString, wxItemKind kind,
43 char *_psz_var, int _i_object_id, vlc_value_t _val,
46 virtual ~wxMenuItemExt();
57 class Menu: public wxMenu
61 Menu( intf_thread_t *p_intf, int i_start_id );
64 void Populate( int i_count, char **ppsz_names, int *pi_objects );
68 /* Event handlers (these functions should _not_ be virtual) */
69 void OnClose( wxCommandEvent& event );
70 void OnShowDialog( wxCommandEvent& event );
71 void OnEntrySelected( wxCommandEvent& event );
73 wxMenu *Menu::CreateDummyMenu();
74 void Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * );
75 wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t *, bool );
77 DECLARE_EVENT_TABLE();
79 intf_thread_t *p_intf;
85 /*****************************************************************************
87 *****************************************************************************/
89 /* IDs for the controls and the menu commands */
93 MenuDummy_Event = wxID_HIGHEST + 1000,
94 OpenFileSimple_Event = wxID_HIGHEST + 1100,
98 FirstAutoGenerated_Event = wxID_HIGHEST + 1999,
99 SettingsMenu_Events = wxID_HIGHEST + 5000,
100 AudioMenu_Events = wxID_HIGHEST + 2000,
101 VideoMenu_Events = wxID_HIGHEST + 3000,
102 NavigMenu_Events = wxID_HIGHEST + 4000,
103 PopupMenu_Events = wxID_HIGHEST + 6000
106 BEGIN_EVENT_TABLE(Menu, wxMenu)
109 BEGIN_EVENT_TABLE(MenuEvtHandler, wxEvtHandler)
110 EVT_MENU(OpenFileSimple_Event, MenuEvtHandler::OnShowDialog)
111 EVT_MENU(OpenFile_Event, MenuEvtHandler::OnShowDialog)
112 EVT_MENU(OpenDisc_Event, MenuEvtHandler::OnShowDialog)
113 EVT_MENU(OpenNet_Event, MenuEvtHandler::OnShowDialog)
114 EVT_MENU(-1, MenuEvtHandler::OnMenuEvent)
117 wxMenu *OpenStreamMenu( intf_thread_t *p_intf )
119 wxMenu *menu = new wxMenu;
120 menu->Append( OpenFileSimple_Event, wxU(_("Quick &Open File...")) );
121 menu->Append( OpenFile_Event, wxU(_("Open &File...")) );
122 menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")) );
123 menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")) );
127 void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
130 #define MAX_POPUP_ITEMS 35
132 vlc_object_t *p_object;
133 char *ppsz_varnames[MAX_POPUP_ITEMS];
134 int pi_objects[MAX_POPUP_ITEMS];
137 /* Initializations */
138 memset( pi_objects, 0, MAX_POPUP_ITEMS * sizeof(int) );
141 ppsz_varnames[i++] = _("Audio menu");
142 ppsz_varnames[i++] = NULL; /* Separator */
144 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
146 if( p_object != NULL )
148 ppsz_varnames[i] = "audio-device";
149 pi_objects[i++] = p_object->i_object_id;
150 ppsz_varnames[i] = "audio-channels";
151 pi_objects[i++] = p_object->i_object_id;
152 ppsz_varnames[i] = "visual";
153 pi_objects[i++] = p_object->i_object_id;
154 vlc_object_release( p_object );
158 ppsz_varnames[i++] = NULL; /* Separator */
159 ppsz_varnames[i++] = _("Video menu");
160 ppsz_varnames[i++] = NULL; /* Separator */
162 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
164 if( p_object != NULL )
166 vlc_object_t *p_dec_obj;
168 ppsz_varnames[i] = "fullscreen";
169 pi_objects[i++] = p_object->i_object_id;
170 ppsz_varnames[i] = "zoom";
171 pi_objects[i++] = p_object->i_object_id;
172 ppsz_varnames[i] = "deinterlace";
173 pi_objects[i++] = p_object->i_object_id;
174 ppsz_varnames[i] = "aspect-ratio";
175 pi_objects[i++] = p_object->i_object_id;
176 ppsz_varnames[i] = "crop";
177 pi_objects[i++] = p_object->i_object_id;
178 ppsz_varnames[i] = "video-on-top";
179 pi_objects[i++] = p_object->i_object_id;
181 p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
184 if( p_dec_obj != NULL )
186 ppsz_varnames[i] = "ffmpeg-pp-q";
187 pi_objects[i++] = p_dec_obj->i_object_id;
188 vlc_object_release( p_dec_obj );
191 vlc_object_release( p_object );
195 ppsz_varnames[i++] = NULL; /* Separator */
196 ppsz_varnames[i++] = _("Input menu");
197 ppsz_varnames[i++] = NULL; /* Separator */
199 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
201 if( p_object != NULL )
203 ppsz_varnames[i] = "bookmark";
204 pi_objects[i++] = p_object->i_object_id;
205 ppsz_varnames[i] = "title";
206 pi_objects[i++] = p_object->i_object_id;
207 ppsz_varnames[i] = "chapter";
208 pi_objects[i++] = p_object->i_object_id;
209 ppsz_varnames[i] = "program";
210 pi_objects[i++] = p_object->i_object_id;
211 ppsz_varnames[i] = "navigation";
212 pi_objects[i++] = p_object->i_object_id;
213 ppsz_varnames[i] = "dvd_menus";
214 pi_objects[i++] = p_object->i_object_id;
216 ppsz_varnames[i] = "video-es";
217 pi_objects[i++] = p_object->i_object_id;
218 ppsz_varnames[i] = "audio-es";
219 pi_objects[i++] = p_object->i_object_id;
220 ppsz_varnames[i] = "spu-es";
221 pi_objects[i++] = p_object->i_object_id;
223 vlc_object_release( p_object );
227 ppsz_varnames[i++] = NULL; /* Separator */
228 ppsz_varnames[i++] = _("Interface menu");
229 ppsz_varnames[i++] = NULL; /* Separator */
231 /* vlc_object_find is needed because of the dialogs provider case */
232 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INTF,
234 if( p_object != NULL )
236 ppsz_varnames[i] = "intf-switch";
237 pi_objects[i++] = p_object->i_object_id;
238 ppsz_varnames[i] = "intf-add";
239 pi_objects[i++] = p_object->i_object_id;
241 vlc_object_release( p_object );
245 Menu popupmenu( p_intf, PopupMenu_Events );
246 popupmenu.Populate( i, ppsz_varnames, pi_objects );
249 /* Add static entries */
250 popupmenu.AppendSeparator();
251 popupmenu.Append( MenuDummy_Event, wxU("Open..."),
252 OpenStreamMenu( p_intf ), wxT("") );
255 p_intf->p_sys->p_popup_menu = &popupmenu;
256 p_parent->PopupMenu( &popupmenu, pos.x, pos.y );
257 p_intf->p_sys->p_popup_menu = NULL;
260 wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
262 #define MAX_AUDIO_ITEMS 10
264 vlc_object_t *p_object;
265 char *ppsz_varnames[MAX_AUDIO_ITEMS];
266 int pi_objects[MAX_AUDIO_ITEMS];
269 /* Initializations */
270 memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(int) );
272 p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
274 if( p_object != NULL )
276 ppsz_varnames[i] = "audio-es";
277 pi_objects[i++] = p_object->i_object_id;
278 vlc_object_release( p_object );
281 p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT,
283 if( p_object != NULL )
285 ppsz_varnames[i] = "audio-device";
286 pi_objects[i++] = p_object->i_object_id;
287 ppsz_varnames[i] = "audio-channels";
288 pi_objects[i++] = p_object->i_object_id;
289 ppsz_varnames[i] = "visual";
290 pi_objects[i++] = p_object->i_object_id;
291 vlc_object_release( p_object );
295 Menu *p_vlc_menu = (Menu *)p_menu;
297 p_vlc_menu = new Menu( _p_intf, AudioMenu_Events );
301 p_vlc_menu->Populate( i, ppsz_varnames, pi_objects );
306 wxMenu *VideoMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
308 #define MAX_VIDEO_ITEMS 15
310 vlc_object_t *p_object;
311 char *ppsz_varnames[MAX_VIDEO_ITEMS];
312 int pi_objects[MAX_VIDEO_ITEMS];
315 /* Initializations */
316 memset( pi_objects, 0, MAX_VIDEO_ITEMS * sizeof(int) );
318 p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
320 if( p_object != NULL )
322 ppsz_varnames[i] = "video-es";
323 pi_objects[i++] = p_object->i_object_id;
324 ppsz_varnames[i] = "spu-es";
325 pi_objects[i++] = p_object->i_object_id;
326 vlc_object_release( p_object );
329 p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_VOUT,
331 if( p_object != NULL )
333 vlc_object_t *p_dec_obj;
335 ppsz_varnames[i] = "fullscreen";
336 pi_objects[i++] = p_object->i_object_id;
337 ppsz_varnames[i] = "zoom";
338 pi_objects[i++] = p_object->i_object_id;
339 ppsz_varnames[i] = "deinterlace";
340 pi_objects[i++] = p_object->i_object_id;
341 ppsz_varnames[i] = "aspect-ratio";
342 pi_objects[i++] = p_object->i_object_id;
343 ppsz_varnames[i] = "crop";
344 pi_objects[i++] = p_object->i_object_id;
345 ppsz_varnames[i] = "directx-on-top";
346 pi_objects[i++] = p_object->i_object_id;
347 ppsz_varnames[i] = "xvideo-on-top";
348 pi_objects[i++] = p_object->i_object_id;
349 ppsz_varnames[i] = "x11-on-top";
350 pi_objects[i++] = p_object->i_object_id;
352 p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
355 if( p_dec_obj != NULL )
357 ppsz_varnames[i] = "ffmpeg-pp-q";
358 pi_objects[i++] = p_dec_obj->i_object_id;
359 vlc_object_release( p_dec_obj );
362 vlc_object_release( p_object );
366 Menu *p_vlc_menu = (Menu *)p_menu;
368 p_vlc_menu = new Menu( _p_intf, VideoMenu_Events );
372 p_vlc_menu->Populate( i, ppsz_varnames, pi_objects );
377 wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent, wxMenu *p_menu )
379 #define MAX_NAVIG_ITEMS 10
381 vlc_object_t *p_object;
382 char *ppsz_varnames[MAX_NAVIG_ITEMS];
383 int pi_objects[MAX_NAVIG_ITEMS];
386 /* Initializations */
387 memset( pi_objects, 0, MAX_NAVIG_ITEMS * sizeof(int) );
389 p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
391 if( p_object != NULL )
393 ppsz_varnames[i] = "bookmark";
394 pi_objects[i++] = p_object->i_object_id;
395 ppsz_varnames[i] = "title";
396 pi_objects[i++] = p_object->i_object_id;
397 ppsz_varnames[i] = "chapter";
398 pi_objects[i++] = p_object->i_object_id;
399 ppsz_varnames[i] = "program";
400 pi_objects[i++] = p_object->i_object_id;
401 ppsz_varnames[i] = "navigation";
402 pi_objects[i++] = p_object->i_object_id;
403 ppsz_varnames[i] = "dvd_menus";
404 pi_objects[i++] = p_object->i_object_id;
406 ppsz_varnames[i] = "prev-title";
407 pi_objects[i++] = p_object->i_object_id;
408 ppsz_varnames[i] = "next-title";
409 pi_objects[i++] = p_object->i_object_id;
410 ppsz_varnames[i] = "prev-chapter";
411 pi_objects[i++] = p_object->i_object_id;
412 ppsz_varnames[i] = "next-chapter";
413 pi_objects[i++] = p_object->i_object_id;
415 vlc_object_release( p_object );
419 Menu *p_vlc_menu = (Menu *)p_menu;
421 p_vlc_menu = new Menu( _p_intf, NavigMenu_Events );
425 p_vlc_menu->Populate( i, ppsz_varnames, pi_objects );
430 wxMenu *SettingsMenu( intf_thread_t *_p_intf, wxWindow *p_parent,
433 #define MAX_SETTINGS_ITEMS 10
435 vlc_object_t *p_object;
436 char *ppsz_varnames[MAX_SETTINGS_ITEMS];
437 int pi_objects[MAX_SETTINGS_ITEMS];
440 /* Initializations */
441 memset( pi_objects, 0, MAX_SETTINGS_ITEMS * sizeof(int) );
443 p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INTF,
445 if( p_object != NULL )
447 ppsz_varnames[i] = "intf-switch";
448 pi_objects[i++] = p_object->i_object_id;
449 ppsz_varnames[i] = "intf-add";
450 pi_objects[i++] = p_object->i_object_id;
451 vlc_object_release( p_object );
455 Menu *p_vlc_menu = (Menu *)p_menu;
457 p_vlc_menu = new Menu( _p_intf, SettingsMenu_Events );
461 p_vlc_menu->Populate( i, ppsz_varnames, pi_objects );
466 /*****************************************************************************
468 *****************************************************************************/
469 Menu::Menu( intf_thread_t *_p_intf, int _i_start_id ) : wxMenu( )
471 /* Initializations */
473 i_start_id = _i_start_id;
480 /*****************************************************************************
482 *****************************************************************************/
483 void Menu::Populate( int i_count, char **ppsz_varnames, int *pi_objects )
485 vlc_object_t *p_object;
486 vlc_bool_t b_section_empty = VLC_FALSE;
489 i_item_id = i_start_id;
491 for( i = 0; i < i_count; i++ )
493 if( !ppsz_varnames[i] )
495 if( b_section_empty )
497 Append( MenuDummy_Event + i, wxU(_("Empty")) );
498 Enable( MenuDummy_Event + i, FALSE );
502 b_section_empty = VLC_TRUE;
508 Append( MenuDummy_Event, wxU(ppsz_varnames[i]) );
509 b_section_empty = VLC_FALSE;
513 p_object = (vlc_object_t *)vlc_object_get( p_intf, pi_objects[i] );
514 if( p_object == NULL ) continue;
516 b_section_empty = VLC_FALSE;
517 CreateMenuItem( this, ppsz_varnames[i], p_object );
518 vlc_object_release( p_object );
521 /* Special case for empty menus */
522 if( GetMenuItemCount() == 0 || b_section_empty )
524 Append( MenuDummy_Event + i, wxU(_("Empty")) );
525 Enable( MenuDummy_Event + i, FALSE );
529 /* Work-around helper for buggy wxGTK */
530 static void RecursiveDestroy( wxMenu *menu )
532 wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
535 wxMenuItem *item = node->GetData();
536 node = node->GetNext();
538 /* Delete the submenus */
539 wxMenu *submenu = item->GetSubMenu();
542 RecursiveDestroy( submenu );
544 menu->Destroy( item );
550 RecursiveDestroy( this );
553 /*****************************************************************************
555 *****************************************************************************/
556 static bool IsMenuEmpty( char *psz_var, vlc_object_t *p_object,
559 vlc_value_t val, val_list;
560 int i_type, i_result, i;
562 /* Check the type of the object variable */
563 i_type = var_Type( p_object, psz_var );
565 /* Check if we want to display the variable */
566 if( !(i_type & VLC_VAR_HASCHOICE) ) return FALSE;
568 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
569 if( val.i_int == 0 ) return TRUE;
571 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
573 if( val.i_int == 1 && b_root ) return TRUE;
577 /* Check children variables in case of VLC_VAR_VARIABLE */
578 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
583 for( i = 0, i_result = TRUE; i < val_list.p_list->i_count; i++ )
585 if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
593 /* clean up everything */
594 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
599 void Menu::CreateMenuItem( wxMenu *menu, char *psz_var,
600 vlc_object_t *p_object )
602 wxMenuItemExt *menuitem;
603 vlc_value_t val, text;
606 /* Check the type of the object variable */
607 i_type = var_Type( p_object, psz_var );
609 switch( i_type & VLC_VAR_TYPE )
613 case VLC_VAR_VARIABLE:
615 case VLC_VAR_INTEGER:
619 /* Variable doesn't exist or isn't handled */
623 /* Make sure we want to display the variable */
624 if( IsMenuEmpty( psz_var, p_object ) ) return;
626 /* Get the descriptive name of the variable */
627 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
629 if( i_type & VLC_VAR_HASCHOICE )
631 menu->Append( MenuDummy_Event,
632 wxU(text.psz_string ? text.psz_string : psz_var),
633 CreateChoicesMenu( psz_var, p_object, TRUE ),
634 wxT("")/* Nothing for now (maybe use a GETLONGTEXT) */ );
636 if( text.psz_string ) free( text.psz_string );
641 switch( i_type & VLC_VAR_TYPE )
644 var_Get( p_object, psz_var, &val );
645 menuitem = new wxMenuItemExt( menu, ++i_item_id,
646 wxU(text.psz_string ?
647 text.psz_string : psz_var),
648 wxT(""), wxITEM_NORMAL, strdup(psz_var),
649 p_object->i_object_id, val, i_type );
650 menu->Append( menuitem );
654 var_Get( p_object, psz_var, &val );
655 val.b_bool = !val.b_bool;
656 menuitem = new wxMenuItemExt( menu, ++i_item_id,
657 wxU(text.psz_string ?
658 text.psz_string : psz_var),
659 wxT(""), wxITEM_CHECK, strdup(psz_var),
660 p_object->i_object_id, val, i_type );
661 menu->Append( menuitem );
662 Check( i_item_id, val.b_bool ? FALSE : TRUE );
666 if( text.psz_string ) free( text.psz_string );
669 wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object,
672 vlc_value_t val, val_list, text_list;
675 /* Check the type of the object variable */
676 i_type = var_Type( p_object, psz_var );
678 /* Make sure we want to display the variable */
679 if( IsMenuEmpty( psz_var, p_object, b_root ) ) return NULL;
681 switch( i_type & VLC_VAR_TYPE )
685 case VLC_VAR_VARIABLE:
687 case VLC_VAR_INTEGER:
691 /* Variable doesn't exist or isn't handled */
695 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
696 &val_list, &text_list ) < 0 )
701 wxMenu *menu = new wxMenu;
702 for( i = 0; i < val_list.p_list->i_count; i++ )
704 vlc_value_t another_val;
705 wxMenuItemExt *menuitem;
707 switch( i_type & VLC_VAR_TYPE )
709 case VLC_VAR_VARIABLE:
710 menu->Append( MenuDummy_Event,
711 wxU(text_list.p_list->p_values[i].psz_string ?
712 text_list.p_list->p_values[i].psz_string :
713 val_list.p_list->p_values[i].psz_string),
715 val_list.p_list->p_values[i].psz_string,
716 p_object, FALSE ), wxT("") );
720 var_Get( p_object, psz_var, &val );
722 another_val.psz_string =
723 strdup(val_list.p_list->p_values[i].psz_string);
725 new wxMenuItemExt( menu, ++i_item_id,
726 wxU(text_list.p_list->p_values[i].psz_string ?
727 text_list.p_list->p_values[i].psz_string :
728 another_val.psz_string), wxT(""),
729 i_type & VLC_VAR_ISCOMMAND ?
730 wxITEM_NORMAL : wxITEM_RADIO,
732 p_object->i_object_id, another_val, i_type );
734 menu->Append( menuitem );
736 if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
737 !strcmp( val.psz_string,
738 val_list.p_list->p_values[i].psz_string ) )
739 menu->Check( i_item_id, TRUE );
741 if( val.psz_string ) free( val.psz_string );
744 case VLC_VAR_INTEGER:
745 var_Get( p_object, psz_var, &val );
748 new wxMenuItemExt( menu, ++i_item_id,
749 text_list.p_list->p_values[i].psz_string ?
751 text_list.p_list->p_values[i].psz_string) :
752 wxString::Format(wxT("%d"),
753 val_list.p_list->p_values[i].i_int), wxT(""),
754 i_type & VLC_VAR_ISCOMMAND ?
755 wxITEM_NORMAL : wxITEM_RADIO,
757 p_object->i_object_id,
758 val_list.p_list->p_values[i], i_type );
760 menu->Append( menuitem );
762 if( !(i_type & VLC_VAR_ISCOMMAND) &&
763 val_list.p_list->p_values[i].i_int == val.i_int )
764 menu->Check( i_item_id, TRUE );
768 var_Get( p_object, psz_var, &val );
771 new wxMenuItemExt( menu, ++i_item_id,
772 text_list.p_list->p_values[i].psz_string ?
774 text_list.p_list->p_values[i].psz_string) :
775 wxString::Format(wxT("%.2f"),
776 val_list.p_list->p_values[i].f_float),wxT(""),
777 i_type & VLC_VAR_ISCOMMAND ?
778 wxITEM_NORMAL : wxITEM_RADIO,
780 p_object->i_object_id,
781 val_list.p_list->p_values[i], i_type );
783 menu->Append( menuitem );
785 if( !(i_type & VLC_VAR_ISCOMMAND) &&
786 val_list.p_list->p_values[i].f_float == val.f_float )
787 menu->Check( i_item_id, TRUE );
795 /* clean up everything */
796 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
801 void Menu::OnShowDialog( wxCommandEvent& event )
803 if( p_intf->p_sys->pf_show_dialog )
807 switch( event.GetId() )
809 case OpenFileSimple_Event:
810 i_id = INTF_DIALOG_FILE_SIMPLE;
813 i_id = INTF_DIALOG_FILE;
816 i_id = INTF_DIALOG_DISC;
819 i_id = INTF_DIALOG_NET;
822 i_id = INTF_DIALOG_FILE;
827 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
831 /*****************************************************************************
832 * A small helper class which intercepts all popup menu events
833 *****************************************************************************/
834 MenuEvtHandler::MenuEvtHandler( intf_thread_t *_p_intf,
835 Interface *_p_main_interface )
837 /* Initializations */
839 p_main_interface = _p_main_interface;
842 MenuEvtHandler::~MenuEvtHandler()
846 void MenuEvtHandler::OnShowDialog( wxCommandEvent& event )
848 if( p_intf->p_sys->pf_show_dialog )
852 switch( event.GetId() )
854 case OpenFileSimple_Event:
855 i_id = INTF_DIALOG_FILE_SIMPLE;
858 i_id = INTF_DIALOG_FILE;
861 i_id = INTF_DIALOG_DISC;
864 i_id = INTF_DIALOG_NET;
867 i_id = INTF_DIALOG_FILE;
872 p_intf->p_sys->pf_show_dialog( p_intf, i_id, 1, 0 );
876 void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
878 wxMenuItem *p_menuitem = NULL;
880 /* Check if this is an auto generated menu item */
881 if( event.GetId() < FirstAutoGenerated_Event )
887 if( !p_main_interface ||
888 (p_menuitem = p_main_interface->GetMenuBar()->FindItem(event.GetId()))
891 if( p_intf->p_sys->p_popup_menu )
894 p_intf->p_sys->p_popup_menu->FindItem( event.GetId() );
900 wxMenuItemExt *p_menuitemext = (wxMenuItemExt *)p_menuitem;
901 vlc_object_t *p_object;
903 p_object = (vlc_object_t *)vlc_object_get( p_intf,
904 p_menuitemext->i_object_id );
905 if( p_object == NULL ) return;
907 var_Set( p_object, p_menuitemext->psz_var, p_menuitemext->val );
909 vlc_object_release( p_object );
915 /*****************************************************************************
916 * A small helper class which encapsulate wxMenuitem with some other useful
918 *****************************************************************************/
919 wxMenuItemExt::wxMenuItemExt( wxMenu* parentMenu, int id, const wxString& text,
920 const wxString& helpString, wxItemKind kind,
921 char *_psz_var, int _i_object_id, vlc_value_t _val, int _i_val_type ):
922 wxMenuItem( parentMenu, id, text, helpString, kind )
924 /* Initializations */
926 i_val_type = _i_val_type;
927 i_object_id = _i_object_id;
931 wxMenuItemExt::~wxMenuItemExt()
933 if( psz_var ) free( psz_var );
934 if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
935 && val.psz_string ) free( val.psz_string );