1 /*****************************************************************************
2 * preferences.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
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() */
37 #include "wxwindows.h"
38 #include "preferences_widgets.h"
40 #include <wx/combobox.h>
41 #include <wx/statline.h>
42 #include <wx/clntdata.h>
43 #include <wx/dynarray.h>
46 # define wxRB_SINGLE 0
49 #define GENERAL_ID 1242
50 #define PLUGIN_ID 1243
51 #define CAPABILITY_ID 1244
53 /*****************************************************************************
54 * Classes declarations.
55 *****************************************************************************/
57 class PrefsTreeCtrl : public wxTreeCtrl
62 PrefsTreeCtrl( wxWindow *parent, intf_thread_t *_p_intf,
63 PrefsDialog *p_prefs_dialog, wxBoxSizer *_p_sizer );
64 virtual ~PrefsTreeCtrl();
70 /* Event handlers (these functions should _not_ be virtual) */
71 void OnSelectTreeItem( wxTreeEvent& event );
72 void OnAdvanced( wxCommandEvent& event );
74 ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );
78 intf_thread_t *p_intf;
79 PrefsDialog *p_prefs_dialog;
82 vlc_bool_t b_advanced;
84 wxTreeItemId root_item;
85 wxTreeItemId general_item;
86 wxTreeItemId plugins_item;
89 WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
91 class PrefsPanel : public wxPanel
96 PrefsPanel( wxWindow *parent, intf_thread_t *_p_intf,
97 PrefsDialog *, int i_object_id, char *, char * );
98 virtual ~PrefsPanel() {}
101 void SwitchAdvanced( vlc_bool_t );
104 intf_thread_t *p_intf;
105 PrefsDialog *p_prefs_dialog;
107 vlc_bool_t b_advanced;
109 wxBoxSizer *config_sizer;
110 wxScrolledWindow *config_window;
112 ArrayOfConfigControls config_array;
115 class ConfigTreeData : public wxTreeItemData
119 ConfigTreeData() { b_submodule = 0; panel = NULL; psz_section = NULL;
121 virtual ~ConfigTreeData() { if( panel ) delete panel;
122 if( psz_section) free(psz_section);
123 if( psz_help) free(psz_help); }
125 vlc_bool_t b_submodule;
134 /*****************************************************************************
136 *****************************************************************************/
138 /* IDs for the controls and the menu commands */
141 Notebook_Event = wxID_HIGHEST,
147 BEGIN_EVENT_TABLE(PrefsDialog, wxFrame)
149 EVT_BUTTON(wxID_OK, PrefsDialog::OnOk)
150 EVT_BUTTON(wxID_CANCEL, PrefsDialog::OnCancel)
151 EVT_BUTTON(wxID_SAVE, PrefsDialog::OnSave)
152 EVT_BUTTON(ResetAll_Event, PrefsDialog::OnResetAll)
153 EVT_CHECKBOX(Advanced_Event, PrefsDialog::OnAdvanced)
155 /* Don't destroy the window when the user closes it */
156 EVT_CLOSE(PrefsDialog::OnCancel)
159 // menu and control ids
162 PrefsTree_Ctrl = wxID_HIGHEST
165 BEGIN_EVENT_TABLE(PrefsTreeCtrl, wxTreeCtrl)
166 EVT_TREE_SEL_CHANGED(PrefsTree_Ctrl, PrefsTreeCtrl::OnSelectTreeItem)
167 EVT_COMMAND(Advanced_Event, wxEVT_USER_FIRST, PrefsTreeCtrl::OnAdvanced)
170 /*****************************************************************************
172 *****************************************************************************/
173 PrefsDialog::PrefsDialog( intf_thread_t *_p_intf, wxWindow *p_parent)
174 : wxFrame( p_parent, -1, wxU(_("Preferences")), wxDefaultPosition,
175 wxSize(700,450), wxDEFAULT_FRAME_STYLE )
177 /* Initializations */
179 SetIcon( *p_intf->p_sys->p_icon );
181 /* Create a panel to put everything in */
182 wxPanel *panel = new wxPanel( this, -1 );
183 panel->SetAutoLayout( TRUE );
185 /* Create the preferences tree control */
186 wxBoxSizer *controls_sizer = new wxBoxSizer( wxHORIZONTAL );
188 new PrefsTreeCtrl( panel, p_intf, this, controls_sizer );
191 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
193 /* Create the buttons */
194 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
195 ok_button->SetDefault();
196 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
198 wxButton *save_button = new wxButton( panel, wxID_SAVE, wxU(_("Save")) );
199 wxButton *reset_button = new wxButton( panel, ResetAll_Event,
200 wxU(_("Reset All")) );
202 wxPanel *dummy_panel = new wxPanel( this, -1 );
203 wxCheckBox *advanced_checkbox =
204 new wxCheckBox( panel, Advanced_Event, wxU(_("Advanced options")) );
206 if( config_GetInt( p_intf, "advanced" ) )
208 advanced_checkbox->SetValue(TRUE);
209 wxCommandEvent dummy_event;
210 dummy_event.SetInt(TRUE);
211 OnAdvanced( dummy_event );
214 /* Place everything in sizers */
215 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
216 button_sizer->Add( ok_button, 0, wxALL, 5 );
217 button_sizer->Add( cancel_button, 0, wxALL, 5 );
218 button_sizer->Add( save_button, 0, wxALL, 5 );
219 button_sizer->Add( reset_button, 0, wxALL, 5 );
220 button_sizer->Add( dummy_panel, 1, wxALL, 5 );
221 button_sizer->Add( advanced_checkbox, 0, wxALL | wxALIGN_RIGHT |
222 wxALIGN_CENTER_VERTICAL, 0 );
223 button_sizer->Layout();
225 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
226 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
227 panel_sizer->Add( controls_sizer, 1, wxEXPAND | wxALL, 5 );
228 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
229 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
230 wxALL | wxEXPAND, 5 );
231 panel_sizer->Layout();
232 panel->SetSizer( panel_sizer );
233 main_sizer->Add( panel, 1, wxEXPAND, 0 );
234 main_sizer->Layout();
235 SetSizer( main_sizer );
238 PrefsDialog::~PrefsDialog()
242 /*****************************************************************************
244 *****************************************************************************/
247 /*****************************************************************************
249 *****************************************************************************/
250 void PrefsDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
252 prefs_tree->ApplyChanges();
254 prefs_tree->CleanChanges();
257 void PrefsDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
260 prefs_tree->CleanChanges();
263 void PrefsDialog::OnSave( wxCommandEvent& WXUNUSED(event) )
265 prefs_tree->ApplyChanges();
266 config_SaveConfigFile( p_intf, NULL );
270 void PrefsDialog::OnResetAll( wxCommandEvent& WXUNUSED(event) )
272 wxMessageDialog dlg( this,
273 wxU(_("Beware this will reset your VLC media player preferences.\n"
274 "Are you sure you want to continue?")),
275 wxU(_("Reset Preferences")), wxYES_NO|wxNO_DEFAULT|wxCENTRE );
277 if ( dlg.ShowModal() == wxID_YES )
279 /* TODO: need to reset all the controls */
280 config_ResetAll( p_intf );
281 prefs_tree->CleanChanges();
282 config_SaveConfigFile( p_intf, NULL );
286 void PrefsDialog::OnAdvanced( wxCommandEvent& event )
288 wxCommandEvent newevent( wxEVT_USER_FIRST, Advanced_Event );
289 newevent.SetInt( event.GetInt() );
291 prefs_tree->AddPendingEvent( newevent );
294 /*****************************************************************************
295 * PrefsTreeCtrl class definition.
296 *****************************************************************************/
297 PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
298 PrefsDialog *_p_prefs_dialog,
299 wxBoxSizer *_p_sizer )
300 : wxTreeCtrl( _p_parent, PrefsTree_Ctrl, wxDefaultPosition, wxDefaultSize,
301 wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT |
302 wxTR_LINES_AT_ROOT | wxTR_HIDE_ROOT |
303 wxTR_HAS_BUTTONS | wxTR_TWIST_BUTTONS | wxSUNKEN_BORDER )
307 module_config_t *p_item;
310 /* Initializations */
312 p_prefs_dialog = _p_prefs_dialog;
314 p_parent = _p_parent;
315 b_advanced = VLC_FALSE;
317 root_item = AddRoot( wxT("") );
319 /* List the plugins */
320 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
321 if( !p_list ) return;
324 * Build a tree of the main options
326 ConfigTreeData *config_data = new ConfigTreeData;
327 config_data->i_object_id = GENERAL_ID;
328 config_data->psz_help = wraptext( GENERAL_HELP, 72 , ISUTF8 );
329 config_data->psz_section = strdup( GENERAL_TITLE );
330 general_item = AppendItem( root_item, wxU(_("General settings")),
331 -1, -1, config_data );
333 for( i_index = 0; i_index < p_list->i_count; i_index++ )
335 p_module = (module_t *)p_list->p_values[i_index].p_object;
336 if( !strcmp( p_module->psz_object_name, "main" ) )
339 if( i_index < p_list->i_count )
341 /* We found the main module */
343 /* Enumerate config categories and store a reference so we can
344 * generate their config panel them when it is asked by the user. */
345 p_item = p_module->p_config;
349 switch( p_item->i_type )
351 case CONFIG_HINT_CATEGORY:
352 ConfigTreeData *config_data = new ConfigTreeData;
353 config_data->psz_section = strdup(p_item->psz_text);
354 if( p_item->psz_longtext )
356 config_data->psz_help =
357 wraptext( p_item->psz_longtext, 72 , ISUTF8 );
361 config_data->psz_help = NULL;
363 config_data->i_object_id = p_module->i_object_id;
365 /* Add the category to the tree */
366 AppendItem( general_item, wxU(p_item->psz_text),
367 -1, -1, config_data );
371 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
373 SortChildren( general_item );
378 * Build a tree of all the plugins
380 config_data = new ConfigTreeData;
381 config_data->i_object_id = PLUGIN_ID;
382 config_data->psz_help = wraptext( PLUGIN_HELP, 72, ISUTF8 );
383 config_data->psz_section = strdup( PLUGIN_TITLE );
384 plugins_item = AppendItem( root_item, wxU(_("Modules")),
385 -1, -1,config_data );
387 for( i_index = 0; i_index < p_list->i_count; i_index++ )
389 p_module = (module_t *)p_list->p_values[i_index].p_object;
391 /* Exclude the main module */
392 if( !strcmp( p_module->psz_object_name, "main" ) )
395 /* Exclude empty plugins (submodules don't have config options, they
396 * are stored in the parent module) */
397 if( p_module->b_submodule )
398 p_item = ((module_t *)p_module->p_parent)->p_config;
400 p_item = p_module->p_config;
402 if( !p_item ) continue;
405 if( p_item->i_type & CONFIG_ITEM )
408 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
409 if( p_item->i_type == CONFIG_HINT_END ) continue;
411 /* Find the capability child item */
412 long cookie; size_t i_child_index;
413 wxTreeItemId capability_item = GetFirstChild( plugins_item, cookie);
414 for( i_child_index = 0;
415 i_child_index < GetChildrenCount( plugins_item, FALSE );
418 if( !GetItemText(capability_item).Cmp(
419 wxU(p_module->psz_capability ) ) )
423 capability_item = GetNextChild( plugins_item, cookie );
426 if( i_child_index == GetChildrenCount( plugins_item, FALSE ) &&
427 p_module->psz_capability && *p_module->psz_capability )
429 /* We didn't find it, add it */
430 ConfigTreeData *config_data = new ConfigTreeData;
431 config_data->psz_section =
432 wraptext( GetCapabilityHelp( p_module->psz_capability , 1 ),
434 config_data->psz_help =
435 wraptext( GetCapabilityHelp( p_module->psz_capability , 2 ),
437 config_data->i_object_id = CAPABILITY_ID;
438 capability_item = AppendItem( plugins_item,
439 wxU(p_module->psz_capability),
443 /* Add the plugin to the tree */
444 ConfigTreeData *config_data = new ConfigTreeData;
445 config_data->b_submodule = p_module->b_submodule;
446 config_data->i_object_id = p_module->b_submodule ?
447 ((module_t *)p_module->p_parent)->i_object_id :
448 p_module->i_object_id;
449 config_data->psz_help = NULL;
450 AppendItem( capability_item, wxU(p_module->psz_object_name), -1, -1,
454 /* Sort all this mess */
455 long cookie; size_t i_child_index;
456 SortChildren( plugins_item );
457 wxTreeItemId capability_item = GetFirstChild( plugins_item, cookie);
458 for( i_child_index = 0;
459 i_child_index < GetChildrenCount( plugins_item, FALSE );
462 SortChildren( capability_item );
463 capability_item = GetNextChild( plugins_item, cookie );
466 /* Clean-up everything */
467 vlc_list_release( p_list );
469 p_sizer->Add( this, 1, wxEXPAND | wxALL, 0 );
472 /* Update Tree Ctrl */
473 #ifndef WIN32 /* Workaround a bug in win32 implementation */
474 SelectItem( GetFirstChild( root_item, cookie ) );
477 Expand( general_item );
480 PrefsTreeCtrl::~PrefsTreeCtrl()
484 void PrefsTreeCtrl::ApplyChanges()
486 long cookie, cookie2;
487 ConfigTreeData *config_data;
489 /* Apply changes to the main module */
490 wxTreeItemId item = GetFirstChild( general_item, cookie );
491 for( size_t i_child_index = 0;
492 i_child_index < GetChildrenCount( general_item, FALSE );
495 config_data = (ConfigTreeData *)GetItemData( item );
496 if( config_data && config_data->panel )
498 config_data->panel->ApplyChanges();
501 item = GetNextChild( general_item, cookie );
504 /* Apply changes to the plugins */
505 item = GetFirstChild( plugins_item, cookie );
506 for( size_t i_child_index = 0;
507 i_child_index < GetChildrenCount( plugins_item, FALSE );
510 wxTreeItemId item2 = GetFirstChild( item, cookie2 );
511 for( size_t i_child_index = 0;
512 i_child_index < GetChildrenCount( item, FALSE );
515 config_data = (ConfigTreeData *)GetItemData( item2 );
516 if( config_data && config_data->panel )
518 config_data->panel->ApplyChanges();
521 item2 = GetNextChild( item, cookie2 );
524 item = GetNextChild( plugins_item, cookie );
528 void PrefsTreeCtrl::CleanChanges()
530 long cookie, cookie2;
531 ConfigTreeData *config_data;
533 config_data = !GetSelection() ? NULL :
534 FindModuleConfig( (ConfigTreeData *)GetItemData( GetSelection() ) );
537 config_data->panel->Hide();
538 p_sizer->Remove( config_data->panel );
541 /* Clean changes for the main module */
542 wxTreeItemId item = GetFirstChild( general_item, cookie );
543 for( size_t i_child_index = 0;
544 i_child_index < GetChildrenCount( general_item, FALSE );
547 config_data = (ConfigTreeData *)GetItemData( item );
548 if( config_data && config_data->panel )
550 delete config_data->panel;
551 config_data->panel = NULL;
554 item = GetNextChild( general_item, cookie );
557 /* Clean changes for the plugins */
558 item = GetFirstChild( plugins_item, cookie );
559 for( size_t i_child_index = 0;
560 i_child_index < GetChildrenCount( plugins_item, FALSE );
563 wxTreeItemId item2 = GetFirstChild( item, cookie2 );
564 for( size_t i_child_index = 0;
565 i_child_index < GetChildrenCount( item, FALSE );
568 config_data = (ConfigTreeData *)GetItemData( item2 );
570 if( config_data && config_data->panel )
572 delete config_data->panel;
573 config_data->panel = NULL;
576 item2 = GetNextChild( item, cookie2 );
579 item = GetNextChild( plugins_item, cookie );
585 OnSelectTreeItem( event );
589 ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
591 /* We need this complexity because submodules don't have their own config
592 * options. They use the parent module ones. */
594 if( !config_data || !config_data->b_submodule )
599 long cookie, cookie2;
600 ConfigTreeData *config_new;
601 wxTreeItemId item = GetFirstChild( plugins_item, cookie );
602 for( size_t i_child_index = 0;
603 i_child_index < GetChildrenCount( plugins_item, FALSE );
606 wxTreeItemId item2 = GetFirstChild( item, cookie2 );
607 for( size_t i_child_index = 0;
608 i_child_index < GetChildrenCount( item, FALSE );
611 config_new = (ConfigTreeData *)GetItemData( item2 );
612 if( config_new && !config_new->b_submodule &&
613 config_new->i_object_id == config_data->i_object_id )
618 item2 = GetNextChild( item, cookie2 );
621 item = GetNextChild( plugins_item, cookie );
628 void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event )
630 ConfigTreeData *config_data = NULL;
632 if( event.GetOldItem() )
633 config_data = FindModuleConfig( (ConfigTreeData *)GetItemData(
634 event.GetOldItem() ) );
635 if( config_data && config_data->panel )
637 config_data->panel->Hide();
638 p_sizer->Remove( config_data->panel );
641 /* Don't use event.GetItem() because we also send fake events */
642 config_data = FindModuleConfig( (ConfigTreeData *)GetItemData(
646 if( !config_data->panel )
648 /* The panel hasn't been created yet. Let's do it. */
650 new PrefsPanel( p_parent, p_intf, p_prefs_dialog,
651 config_data->i_object_id,
652 config_data->psz_section,
653 config_data->psz_help );
654 config_data->panel->SwitchAdvanced( b_advanced );
658 config_data->panel->SwitchAdvanced( b_advanced );
659 config_data->panel->Show();
662 p_sizer->Add( config_data->panel, 3, wxEXPAND | wxALL, 0 );
667 void PrefsTreeCtrl::OnAdvanced( wxCommandEvent& event )
669 b_advanced = event.GetInt();
671 ConfigTreeData *config_data = !GetSelection() ? NULL :
672 FindModuleConfig( (ConfigTreeData *)GetItemData( GetSelection() ) );
675 config_data->panel->Hide();
676 p_sizer->Remove( config_data->panel );
682 OnSelectTreeItem( event );
686 /*****************************************************************************
687 * PrefsPanel class definition.
688 *****************************************************************************/
689 PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
690 PrefsDialog *_p_prefs_dialog,
691 int i_object_id, char *psz_section, char *psz_help )
692 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize )
694 module_config_t *p_item;
700 module_t *p_module = NULL;
702 /* Initializations */
704 p_prefs_dialog =_p_prefs_dialog,
706 b_advanced = VLC_TRUE;
707 SetAutoLayout( TRUE );
710 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
713 if( i_object_id == PLUGIN_ID || i_object_id == GENERAL_ID ||
714 i_object_id == CAPABILITY_ID )
716 label = new wxStaticText( this, -1,wxU(_( psz_section )));
717 wxFont heading_font = label->GetFont();
718 heading_font.SetPointSize( heading_font.GetPointSize() + 5 );
719 label->SetFont( heading_font );
720 sizer->Add( label, 0, wxEXPAND | wxLEFT, 10 );
721 sizer->Add( new wxStaticLine( this, 0 ), 0,
722 wxEXPAND | wxLEFT | wxRIGHT, 2 );
724 help = new wxStaticText( this, -1, wxU(_( psz_help ) ) );
725 sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );
727 config_sizer = NULL; config_window = NULL;
731 /* Get a pointer to the module */
732 p_module = (module_t *)vlc_object_get( p_intf, i_object_id );
733 if( p_module->i_object_type != VLC_OBJECT_MODULE )
735 /* 0OOoo something went really bad */
739 /* Enumerate config options and add corresponding config boxes
740 * (submodules don't have config options, they are stored in the
742 if( p_module->b_submodule )
743 p_item = ((module_t *)p_module->p_parent)->p_config;
745 p_item = p_module->p_config;
747 /* Find the category if it has been specified */
748 if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY )
750 while( !p_item->i_type == CONFIG_HINT_CATEGORY ||
751 strcmp( psz_section, p_item->psz_text ) )
753 if( p_item->i_type == CONFIG_HINT_END )
759 /* Add a head title to the panel */
760 label = new wxStaticText( this, -1,
761 wxU(_(psz_section ? p_item->psz_text :
762 p_module->psz_longname )));
763 wxFont heading_font = label->GetFont();
764 heading_font.SetPointSize( heading_font.GetPointSize() + 5 );
765 label->SetFont( heading_font );
766 sizer->Add( label, 0, wxEXPAND | wxLEFT, 10 );
767 sizer->Add( new wxStaticLine( this, 0 ), 0,
768 wxEXPAND | wxLEFT | wxRIGHT, 2 );
770 /* Now put all the config options into a scrolled window */
771 config_sizer = new wxBoxSizer( wxVERTICAL );
772 config_window = new wxScrolledWindow( this, -1, wxDefaultPosition,
773 wxDefaultSize, wxBORDER_NONE | wxHSCROLL | wxVSCROLL );
774 config_window->SetAutoLayout( TRUE );
775 config_window->SetScrollRate( 5, 5 );
779 /* If a category has been specified, check we finished the job */
780 if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY &&
781 strcmp( psz_section, p_item->psz_text ) )
784 ConfigControl *control =
785 CreateConfigControl( VLC_OBJECT(p_intf),
786 p_item, config_window );
788 /* Don't add items that were not recognized */
789 if( control == NULL ) continue;
791 /* Add the config data to our array so we can keep a trace of it */
792 config_array.Add( control );
794 config_sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
796 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
798 config_sizer->Layout();
799 config_window->SetSizer( config_sizer );
800 sizer->Add( config_window, 1, wxEXPAND | wxALL, 5 );
802 /* And at last put a useful help string if available */
803 if( psz_help && *psz_help )
805 sizer->Add( new wxStaticLine( this, 0 ), 0,
806 wxEXPAND | wxLEFT | wxRIGHT, 2 );
807 help = new wxStaticText( this, -1, wxU(_(psz_help)),
808 wxDefaultPosition, wxDefaultSize,
811 sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );
814 vlc_object_release( p_module );
821 void PrefsPanel::ApplyChanges()
825 for( size_t i = 0; i < config_array.GetCount(); i++ )
827 ConfigControl *control = config_array.Item(i);
829 switch( control->GetType() )
831 case CONFIG_ITEM_STRING:
832 case CONFIG_ITEM_FILE:
833 case CONFIG_ITEM_DIRECTORY:
834 case CONFIG_ITEM_MODULE:
835 config_PutPsz( p_intf, control->GetName().mb_str(),
836 control->GetPszValue().mb_str() );
838 case CONFIG_ITEM_KEY:
839 /* So you don't need to restart to have the changes take effect */
840 val.i_int = control->GetIntValue();
841 var_Set( p_intf->p_vlc, control->GetName().mb_str(), val );
842 case CONFIG_ITEM_INTEGER:
843 case CONFIG_ITEM_BOOL:
844 config_PutInt( p_intf, control->GetName().mb_str(),
845 control->GetIntValue() );
847 case CONFIG_ITEM_FLOAT:
848 config_PutFloat( p_intf, control->GetName().mb_str(),
849 control->GetFloatValue() );
855 void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced )
857 if( b_advanced == b_new_advanced ) return;
859 if( config_sizer && config_window )
861 b_advanced = b_new_advanced;
863 for( size_t i = 0; i < config_array.GetCount(); i++ )
865 ConfigControl *control = config_array.Item(i);
866 if( control->IsAdvanced() )
868 control->Show( b_advanced );
869 config_sizer->Show( control, b_advanced );
873 config_sizer->Layout();
874 config_window->FitInside();
875 config_window->Refresh();