1 /*****************************************************************************
2 * preferences.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
43 #include <vlc_config_cat.h>
45 #include "preferences_widgets.h"
47 #define TYPE_CATEGORY 0
48 #define TYPE_CATSUBCAT 1 /* Category with embedded subcategory */
49 #define TYPE_SUBCATEGORY 2
52 /*****************************************************************************
54 *****************************************************************************/
56 /* IDs for the controls and the menu commands */
65 /*****************************************************************************
66 * Classes declarations.
67 *****************************************************************************/
74 PrefsTreeCtrl( intf_thread_t *_p_intf, PrefsDialog *p_prefs_dialog,
75 HWND hwnd, HINSTANCE _hInst );
76 virtual ~PrefsTreeCtrl();
79 /*void CleanChanges();*/
81 void OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent, HINSTANCE hInst );
83 ConfigTreeData *FindModuleConfig( ConfigTreeData *config_data );
88 intf_thread_t *p_intf;
89 PrefsDialog *p_prefs_dialog;
92 HTREEITEM general_item;
93 HTREEITEM plugins_item;
101 PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
102 PrefsDialog *, module_t *p_module, char *, char *, ConfigTreeData * );
103 virtual ~PrefsPanel() {}
116 intf_thread_t *p_intf;
117 PrefsDialog *p_prefs_dialog;
123 vector<ConfigControl *> config_array;
130 ConfigTreeData() { b_submodule = 0; panel = NULL; psz_name = NULL;
132 virtual ~ConfigTreeData() { delete panel;
147 /*****************************************************************************
149 *****************************************************************************/
150 PrefsDialog::PrefsDialog( intf_thread_t *p_intf, CBaseWindow *p_parent,
152 : CBaseWindow( p_intf, p_parent, h_inst )
154 /* Initializations */
158 /***********************************************************************
164 Processes messages sent to the main window.
166 ***********************************************************************/
167 LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
176 shidi.dwMask = SHIDIM_FLAGS;
177 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
178 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
180 SHInitDialog( &shidi );
183 memset( &mbi, 0, sizeof (SHMENUBARINFO) );
184 mbi.cbSize = sizeof (SHMENUBARINFO);
185 mbi.hwndParent = hwnd;
186 mbi.dwFlags = SHCMBF_EMPTYBAR;
187 mbi.hInstRes = hInst;
189 if( !SHCreateMenuBar(&mbi) )
191 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
197 // Get the client area rect to put the panels in
198 GetClientRect(hwnd, &rcClient);
200 /* Create the buttons */
202 CreateWindow( _T("BUTTON"), _T("Advanced options"),
203 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
204 5, 10, 15, 15, hwnd, NULL, hInst, NULL );
205 SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
207 advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"),
208 WS_CHILD | WS_VISIBLE | SS_LEFT,
209 5 + 15 + 5, 10, 110, 15,
210 hwnd, NULL, hInst, NULL);
212 if( config_GetInt( p_intf, "advanced" ) )
214 SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
215 /*dummy_event.SetInt(TRUE);
216 OnAdvanced( dummy_event );*/
219 reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"),
220 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
221 rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6,
222 hwnd, NULL, hInst, NULL );
224 /* Create the preferences tree control */
225 prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst );
227 UpdateWindow( hwnd );
231 EndDialog( hwnd, LOWORD( wp ) );
235 SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
239 if( LOWORD(wp) == IDOK )
242 EndDialog( hwnd, LOWORD( wp ) );
248 if( lp && prefs_tree &&
249 ((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV &&
250 ((LPNMHDR)lp)->code == TVN_SELCHANGED )
252 prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp,
260 tvi.mask = TVIF_PARAM;
261 tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
262 if( !tvi.hItem ) break;
264 if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;
266 ConfigTreeData *config_data =
267 prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
268 if( config_data && hwnd == config_data->panel->config_window )
272 GetWindowRect( hwnd, &rc);
273 int newvalue = config_data->panel->oldvalue;
274 switch ( GET_WM_VSCROLL_CODE(wp,lp) )
276 case SB_BOTTOM : newvalue = 0; break;
277 case SB_TOP : newvalue = config_data->panel->maxvalue; break;
278 case SB_LINEDOWN : newvalue += 10; break;
279 case SB_PAGEDOWN : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length
280 case SB_LINEUP : newvalue -= 10; break;
281 case SB_PAGEUP : newvalue -= rc.bottom - rc.top - 25; break;
282 case SB_THUMBPOSITION:
283 case SB_THUMBTRACK : newvalue = GET_WM_VSCROLL_POS(wp,lp); break;
285 newvalue = max(0,min(config_data->panel->maxvalue,newvalue));
286 SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);//SB_CTL si hwnd=hwndScrollBar, SB_VERT si window
287 dy = config_data->panel->oldvalue - newvalue;
289 ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );
290 UpdateWindow ( hwnd);
292 config_data->panel->oldvalue = newvalue;
304 /*****************************************************************************
306 *****************************************************************************/
308 /*****************************************************************************
310 *****************************************************************************/
311 void PrefsDialog::OnOk( void )
313 prefs_tree->ApplyChanges();
314 config_SaveConfigFile( p_intf, NULL );
317 /*****************************************************************************
318 * PrefsTreeCtrl class definition.
319 *****************************************************************************/
320 PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
321 PrefsDialog *_p_prefs_dialog, HWND hwnd,
324 module_t *p_module = NULL;
325 module_config_t *p_item;
327 INITCOMMONCONTROLSEX iccex;
330 TVINSERTSTRUCT tvins = {0};
333 size_t i_capability_count = 0;
334 size_t i_child_index;
336 HTREEITEM category_item, subcategory_item;
338 /* Initializations */
340 p_prefs_dialog = _p_prefs_dialog;
343 /* Create a tree view */
344 // Initialize the INITCOMMONCONTROLSEX structure.
345 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
346 iccex.dwICC = ICC_TREEVIEW_CLASSES;
348 // Registers Statusbar control classes from the common control dll
349 InitCommonControlsEx( &iccex );
351 // Get the client area rect to put the tv in
352 GetClientRect(hwnd, &rcClient);
354 // Create the tree-view control.
355 hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,
356 WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
357 TVS_LINESATROOT | TVS_HASBUTTONS,
358 5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
359 hwnd, NULL, hInst, NULL );
361 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
364 * Build a tree of the main options
366 ConfigTreeData *config_data = new ConfigTreeData;
367 config_data->i_object_id = TYPE_CATEGORY;
368 config_data->psz_help = strdup(MAIN_HELP);
369 config_data->psz_name = strdup( "General" );
370 tvi.pszText = _T("General settings");
371 tvi.cchTextMax = lstrlen(_T("General settings"));
372 tvi.lParam = (long)config_data;
374 tvins.hInsertAfter = TVI_FIRST;
375 tvins.hParent = TVI_ROOT;
377 // Add the item to the tree-view control.
378 hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
379 general_item = hPrev;
381 /* Build the categories list */
382 p_module = module_get_main();
384 unsigned int confsize;
385 const char *psz_help;
386 module_config_t * p_config;
388 /* Enumerate config categories and store a reference so we can
389 * generate their config panel when it is asked by the user. */
390 p_config = module_config_get (p_module, &confsize);
392 for( size_t i = 0; i < confsize; i++ )
394 /* Work on a new item */
395 module_config_t *p_item = p_config + i;
397 switch( p_item->i_type )
399 case CONFIG_CATEGORY:
400 if( p_item->value.i == -1 ) break; // Don't display it
401 config_data = new ConfigTreeData;
402 config_data->psz_name = strdup( config_CategoryNameGet(p_item->value.i ) );
403 psz_help = config_CategoryHelpGet( p_item->value.i );
406 config_data->psz_help = wraptext( strdup( psz_help ), 72 );
410 config_data->psz_help = NULL;
413 config_data->i_type = TYPE_CATEGORY;
414 config_data->i_object_id = p_item->value.i;
415 config_data->p_module = p_module;
416 tvi.pszText = _FROMMB(config_data->psz_name);
417 tvi.cchTextMax = _tcslen(tvi.pszText);
419 /* Add the category to the tree */
420 tvi.lParam = (long)config_data;
422 tvins.hInsertAfter = hPrev;
423 tvins.hParent = general_item; //level 3
425 // Add the item to the tree-view control.
426 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
429 case CONFIG_SUBCATEGORY:
430 if( p_item->value.i == -1 ) break; // Don't display it
431 /* Special case: move the "general" subcategories to their parent category */
432 if(config_data && p_item->value.i == SUBCAT_VIDEO_GENERAL ||
433 p_item->value.i == SUBCAT_ADVANCED_MISC ||
434 p_item->value.i == SUBCAT_INPUT_GENERAL ||
435 p_item->value.i == SUBCAT_INTERFACE_GENERAL ||
436 p_item->value.i == SUBCAT_SOUT_GENERAL||
437 p_item->value.i == SUBCAT_PLAYLIST_GENERAL||
438 p_item->value.i == SUBCAT_AUDIO_GENERAL )
441 config_data->i_type = TYPE_CATSUBCAT;
442 config_data->i_subcat_id = p_item->value.i;
443 free( config_data->psz_name );
444 config_data->psz_name = strdup( config_CategoryNameGet( p_item->value.i ) );
446 free( config_data->psz_help );
447 const char *psz_help = config_CategoryHelpGet( p_item->value.i );
450 config_data->psz_help = wraptext( strdup( psz_help ), 72 );
454 config_data->psz_help = NULL;
459 config_data = new ConfigTreeData;
461 config_data->psz_name = strdup( config_CategoryNameGet( p_item->value.i ) );
462 psz_help = config_CategoryHelpGet( p_item->value.i );
465 config_data->psz_help = wraptext( strdup( psz_help ), 72 );
469 config_data->psz_help = NULL;
471 config_data->i_type = TYPE_SUBCATEGORY;
472 config_data->i_object_id = p_item->value.i;
474 tvi.pszText = _FROMMB(config_data->psz_name);
475 tvi.cchTextMax = _tcslen(tvi.pszText);
477 tvi.lParam = (long)config_data;
479 tvins.hInsertAfter = hPrev;
480 tvins.hParent = hPrev;
482 // Add the item to the tree-view control.
483 TreeView_InsertItem( hwndTV, &tvins );
488 TreeView_SortChildren( hwndTV, general_item, 0 );
489 module_config_free( p_config );
491 /* List the plugins */
492 module_t **p_list = module_list_get( NULL );
495 * Build a tree of all the plugins
497 for( size_t i_index = 0; p_list[i_index]; i_index++ )
499 /* Take every module */
500 p_module = p_list[i_index];
502 /* Exclude the main module */
503 if( module_is_main( p_module ) )
506 /* Exclude empty plugins (submodules don't have config options, they
507 * are stored in the parent module) */
509 unsigned int confsize;
511 int i_category = 0, i_subcategory = 0, i_options = 0;
512 bool b_options = false;
514 p_config = module_config_get( (module_t *) p_module,&confsize);
516 /* Loop through the configurations items */
517 for( size_t i = 0; i < confsize; i++ )
519 module_config_t *p_item = p_config + i;
520 if( p_item->i_type == CONFIG_CATEGORY )
521 i_category = p_item->value.i;
522 else if( p_item->i_type == CONFIG_SUBCATEGORY )
523 i_subcategory = p_item->value.i;
525 if( p_item->i_type & CONFIG_ITEM )
528 if( b_options && i_category && i_subcategory )
531 module_config_free (p_config);
533 /* Dummy item, please proceed */
534 if( !b_options || i_category == 0 || i_subcategory == 0 ) continue;
536 category_item = TreeView_GetChild( hwndTV, general_item );
537 while(category_item != 0)
539 TVITEM category_tvi = {0};
541 category_tvi.mask = TVIF_PARAM;
542 category_tvi.lParam = NULL;
543 category_tvi.hItem = category_item;
544 TreeView_GetItem( hwndTV, &category_tvi );
546 ConfigTreeData * data = (ConfigTreeData *)category_tvi.lParam;
548 if( data->i_object_id == i_category )
550 subcategory_item = TreeView_GetChild( hwndTV, category_item );
552 while(subcategory_item != 0)
554 TVITEM subcategory_tvi = {0};
556 subcategory_tvi.mask = TVIF_PARAM;
557 subcategory_tvi.lParam = NULL;
558 subcategory_tvi.hItem = subcategory_item;
559 TreeView_GetItem( hwndTV, &subcategory_tvi );
561 ConfigTreeData * subdata = (ConfigTreeData *)subcategory_tvi.lParam;
563 if( subdata->i_object_id == i_subcategory )
565 config_data = new ConfigTreeData;
567 config_data->psz_name = strdup( module_get_object( p_module ) );
568 config_data->psz_help = NULL;
569 config_data->i_type = TYPE_MODULE;
570 config_data->i_object_id = p_item->value.i;
571 config_data->p_module = p_module;
573 tvi.pszText = _FROMMB(module_get_name( p_module, false ));
574 tvi.cchTextMax = _tcslen(tvi.pszText);
576 tvi.lParam = (long)config_data;
578 tvins.hInsertAfter = subcategory_item;
579 tvins.hParent = subcategory_item;
581 // Add the item to the tree-view control.
582 hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );
585 subcategory_item = TreeView_GetNextSibling( hwndTV, subcategory_item );
591 category_item = TreeView_GetNextSibling( hwndTV, category_item );
596 /* Sort all this mess */
597 TreeView_SortChildren( hwndTV, general_item, 0 );
598 category_item = TreeView_GetChild( hwndTV, general_item );
599 while( category_item != 0 )
601 TreeView_SortChildren( hwndTV, category_item, 0 );
602 category_item = TreeView_GetNextSibling( hwndTV, category_item );
605 /* Clean-up everything */
606 module_list_free( p_list );
608 TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
611 PrefsTreeCtrl::~PrefsTreeCtrl()
615 void PrefsTreeCtrl::ApplyChanges()
617 ConfigTreeData *config_data;
619 /* Apply changes to the main module */
620 HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
624 tvi.mask = TVIF_PARAM;
626 TreeView_GetItem( hwndTV, &tvi );
627 config_data = (ConfigTreeData *)tvi.lParam;
628 if( config_data && config_data->panel )
630 config_data->panel->ApplyChanges();
633 item = TreeView_GetNextSibling( hwndTV, item );
636 /* Apply changes to the plugins */
637 item = TreeView_GetChild( hwndTV, general_item );
640 HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
643 HTREEITEM item3 = TreeView_GetChild( hwndTV, item2 );
647 tvi.mask = TVIF_PARAM;
649 TreeView_GetItem( hwndTV, &tvi );
650 config_data = (ConfigTreeData *)tvi.lParam;
651 if( config_data && config_data->panel )
653 config_data->panel->ApplyChanges();
655 item3 = TreeView_GetNextSibling( hwndTV, item3 );
657 item2 = TreeView_GetNextSibling( hwndTV, item2 );
659 item = TreeView_GetNextSibling( hwndTV, item );
663 ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
665 if( !config_data || !config_data->p_module )
670 ConfigTreeData *config_new;
671 HTREEITEM item = TreeView_GetChild( hwndTV, general_item );
674 HTREEITEM item2 = TreeView_GetChild( hwndTV, item );
677 HTREEITEM item3 = TreeView_GetChild( hwndTV, item2 );
681 tvi.mask = TVIF_PARAM;
683 TreeView_GetItem( hwndTV, &tvi );
684 config_new = (ConfigTreeData *)tvi.lParam;
685 if( config_new && config_new->p_module == config_data->p_module )
689 item3 = TreeView_GetNextSibling( hwndTV, item3 );
691 item2 = TreeView_GetNextSibling( hwndTV, item2 );
693 item = TreeView_GetNextSibling( hwndTV, item );
700 void PrefsTreeCtrl::OnSelectTreeItem( LPNM_TREEVIEW pnmtv, HWND parent,
703 ConfigTreeData *config_data = NULL;
705 if( pnmtv->itemOld.hItem )
706 config_data = FindModuleConfig( (ConfigTreeData *)pnmtv->itemOld.lParam );
708 if( config_data && config_data->panel )
710 config_data->panel->Hide();
713 /* Don't use event.GetItem() because we also send fake events */
715 tvi.mask = TVIF_PARAM;
716 tvi.hItem = TreeView_GetSelection( hwndTV );
717 TreeView_GetItem( hwndTV, &tvi );
718 config_data = FindModuleConfig( (ConfigTreeData *)tvi.lParam );
721 if( !config_data->panel )
723 /* The panel hasn't been created yet. Let's do it. */
725 new PrefsPanel( parent, hInst, p_intf, p_prefs_dialog,
726 config_data->p_module,
727 config_data->psz_name,
728 config_data->psz_help, config_data );
732 config_data->panel->Show();
737 /*****************************************************************************
738 * PrefsPanel class definition.
739 *****************************************************************************/
740 PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
741 PrefsDialog *_p_prefs_dialog,
742 module_t *p_module, char *psz_name, char *psz_help, ConfigTreeData * config_data )
744 module_config_t *p_item, *p_config, *p_end;
746 /* Initializations */
748 p_prefs_dialog = _p_prefs_dialog;
753 if( config_data->i_type == TYPE_CATEGORY )
755 label = CreateWindow( _T("STATIC"), _FROMMB(psz_name),
756 WS_CHILD | WS_VISIBLE | SS_LEFT,
757 5, 10 + (15 + 10), 200, 15,
758 parent, NULL, hInst, NULL );
759 config_window = NULL;
763 /* Get a pointer to the module */
764 if( config_data->i_type == TYPE_MODULE )
766 p_module = config_data->p_module;
770 /* List the plugins */
772 bool b_found = false;
773 p_list = module_list_get( NULL );
775 for( i_index = 0; p_list[i_index]; i_index++ )
777 p_module = p_list[i_index];
778 if( !strcmp( module_get_object(p_module), "main" ) )
784 if( !p_module && !b_found )
786 msg_Warn( p_intf, "unable to create preferences "
787 "(main module not found)" );
792 /* Enumerate config options and add corresponding config boxes
793 * (submodules don't have config options, they are stored in the
796 p_config = module_config_get( (module_t *) p_module,&confsize);
799 p_end = p_config + confsize;
801 /* Find the category if it has been specified */
802 if( config_data->i_type == TYPE_SUBCATEGORY ||
803 config_data->i_type == TYPE_CATSUBCAT )
805 for( ; p_item && p_item < p_end ; p_item++ )
807 if( p_item->i_type == CONFIG_SUBCATEGORY &&
808 ( config_data->i_type == TYPE_SUBCATEGORY &&
809 p_item->value.i == config_data->i_object_id ) ||
810 ( config_data->i_type == TYPE_CATSUBCAT &&
811 p_item->value.i == config_data->i_subcat_id ) )
818 /* Add a head title to the panel */
819 const char *psz_head;
820 if( config_data->i_type == TYPE_SUBCATEGORY ||
821 config_data->i_type == TYPE_CATSUBCAT )
823 psz_head = config_data->psz_name;
828 psz_head = module_GetLongName(p_module);
831 label = CreateWindow( _T("STATIC"), _FROMMB(psz_head ?
832 psz_head : _("Unknown")),
833 WS_CHILD | WS_VISIBLE | SS_LEFT,
834 5, 10 + (15 + 10), 250, 15,
835 parent, NULL, hInst, NULL );
838 memset( &wc, 0, sizeof(wc) );
839 wc.style = CS_HREDRAW | CS_VREDRAW;
840 wc.lpfnWndProc = (WNDPROC) _p_prefs_dialog->BaseWndProc;
843 wc.hInstance = hInst;
846 wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
848 wc.lpszClassName = _T("PrefsPanelClass");
852 GetWindowRect( parent, &rc);
853 config_window = CreateWindow( _T("PrefsPanelClass"),
855 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER,
856 5, 10 + 2*(15 + 10), rc.right - 5 - 7, 105,
857 parent, NULL, hInst, (void *) _p_prefs_dialog );
860 for( ; p_item && p_item < p_end ; p_item++ )
862 /* If a category has been specified, check we finished the job */
863 if( ( ( config_data->i_type == TYPE_SUBCATEGORY &&
864 p_item->value.i != config_data->i_object_id ) ||
865 ( config_data->i_type == TYPE_CATSUBCAT &&
866 p_item->value.i != config_data->i_subcat_id ) ) &&
867 (p_item->i_type == CONFIG_CATEGORY ||
868 p_item->i_type == CONFIG_SUBCATEGORY ) )
871 ConfigControl *control = NULL;
873 control = CreateConfigControl( VLC_OBJECT(p_intf),
874 p_item, config_window,
877 /* Don't add items that were not recognized */
878 if( control == NULL ) continue;
880 /* Add the config data to our array so we can keep a trace of it */
881 config_array.push_back( control );
883 GetWindowRect( config_window, &rc);
884 maxvalue = y_pos - (rc.bottom - rc.top) + 5;
886 SetScrollRange( config_window, SB_VERT, 0, maxvalue, TRUE );
890 void PrefsPanel::Hide()
892 ShowWindow( label, SW_HIDE );
893 if( config_window ) ShowWindow( config_window, SW_HIDE );
896 void PrefsPanel::Show()
898 ShowWindow( label, SW_SHOW );
899 if( config_window ) ShowWindow( config_window, SW_SHOW );
902 void PrefsPanel::ApplyChanges()
905 for( size_t i = 0; i < config_array.size(); i++ )
907 ConfigControl *control = config_array[i];
909 switch( control->GetType() )
911 case CONFIG_ITEM_STRING:
912 case CONFIG_ITEM_FILE:
913 case CONFIG_ITEM_DIRECTORY:
914 case CONFIG_ITEM_MODULE:
915 config_PutPsz( p_intf, control->GetName(),
916 control->GetPszValue() );
918 case CONFIG_ITEM_KEY:
919 /* So you don't need to restart to have the changes take effect */
920 val.i_int = control->GetIntValue();
921 var_Set( p_intf->p_libvlc, control->GetName(), val );
922 case CONFIG_ITEM_INTEGER:
923 case CONFIG_ITEM_BOOL:
924 config_PutInt( p_intf, control->GetName(),
925 control->GetIntValue() );
927 case CONFIG_ITEM_FLOAT:
928 config_PutFloat( p_intf, control->GetName(),
929 control->GetFloatValue() );