macosx: same as previous commit plus revert of [24799] for prefs.m (unintended commit)
[vlc.git] / modules / gui / macosx / prefs.m
1 /*****************************************************************************
2  * prefs.m: MacOS X module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Derk-Jan Hartman <hartman at videolan dot org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 /* VLCPrefs manages the main preferences dialog
26    the class is related to wxwindows intf, PrefsPanel */
27 /* VLCTreeItem should contain:
28    - the children of the treeitem
29    - the associated prefs widgets
30    - the documentview with all the prefs widgets in it
31    - a saveChanges action
32    - a revertChanges action
33    - an advanced action (to hide/show advanced options)
34    - a redraw view action
35    - the children action should generate a list of the treeitems children (to be used by VLCPrefs datasource)
36
37    The class is sort of a mix of wxwindows intfs, PrefsTreeCtrl and ConfigTreeData
38 */
39 /* VLCConfigControl are subclassed NSView's containing and managing individual config items
40    the classes are VERY closely related to wxwindows ConfigControls */
41
42 /*****************************************************************************
43  * Preamble
44  *****************************************************************************/
45 #include <stdlib.h>                                      /* malloc(), free() */
46 #include <sys/param.h>                                    /* for MAXPATHLEN */
47 #include <string.h>
48
49 #ifdef HAVE_CONFIG_H
50 # include "config.h"
51 #endif
52
53 #include <vlc/vlc.h>
54 #include <vlc_config_cat.h>
55
56 #include "intf.h"
57 #include "prefs.h"
58 #include "prefs_widgets.h"
59 #include "vlc_keys.h"
60
61 /*****************************************************************************
62  * VLCPrefs implementation
63  *****************************************************************************/
64 @implementation VLCPrefs
65
66 static VLCPrefs *_o_sharedMainInstance = nil;
67
68 + (VLCPrefs *)sharedInstance
69 {
70     return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init];
71 }
72
73 - (id)init
74 {
75     if( _o_sharedMainInstance ) {
76         [self dealloc];
77     }
78     else
79     {
80         _o_sharedMainInstance = [super init];
81         p_intf = VLCIntf;
82         o_empty_view = [[NSView alloc] init];
83     }
84
85     return _o_sharedMainInstance;
86 }
87
88 - (void)dealloc
89 {
90     [o_empty_view release];
91     [super dealloc];
92 }
93
94 - (void)awakeFromNib
95 {
96     p_intf = VLCIntf;
97     b_advanced = config_GetInt( p_intf, "advanced" );
98
99     [self initStrings];
100     [o_advanced_ckb setState: b_advanced];
101     [o_prefs_view setBorderType: NSGrooveBorder];
102     [o_prefs_view setHasVerticalScroller: YES];
103     [o_prefs_view setDrawsBackground: NO];
104     [o_prefs_view setDocumentView: o_empty_view];
105     [o_tree selectRow:0 byExtendingSelection:NO];
106 }
107
108 - (void)setTitle: (NSString *) o_title_name
109 {
110     [o_title setStringValue: o_title_name];
111 }
112
113 - (void)showPrefs
114 {
115     [o_prefs_window center];
116     [o_prefs_window makeKeyAndOrderFront:self];
117 }
118
119 - (void)initStrings
120 {
121     [o_prefs_window setTitle: _NS("Preferences")];
122     [o_save_btn setTitle: _NS("Save")];
123     [o_cancel_btn setTitle: _NS("Cancel")];
124     [o_reset_btn setTitle: _NS("Reset All")];
125     [o_advanced_ckb setTitle: _NS("Advanced")];
126 }
127
128 - (IBAction)savePrefs: (id)sender
129 {
130     /* TODO: call savePrefs on Root item */
131     [[VLCTreeItem rootItem] applyChanges];
132     config_SaveConfigFile( p_intf, NULL );
133     [o_prefs_window orderOut:self];
134 }
135
136 - (IBAction)closePrefs: (id)sender
137 {
138     [o_prefs_window orderOut:self];
139 }
140
141 - (IBAction)resetAll: (id)sender
142 {
143     NSBeginInformationalAlertSheet(_NS("Reset Preferences"), _NS("Cancel"),
144         _NS("Continue"), nil, o_prefs_window, self,
145         @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
146         _NS("Beware this will reset the VLC media player preferences.\n"
147             "Are you sure you want to continue?") );
148 }
149
150 - (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return
151     contextInfo:(void *)o_context
152 {
153     if( i_return == NSAlertAlternateReturn )
154     {
155         [o_prefs_view setDocumentView: o_empty_view];
156         config_ResetAll( p_intf );
157         [[VLCTreeItem rootItem] resetView];
158         [[o_tree itemAtRow:[o_tree selectedRow]]
159             showView:o_prefs_view advancedView:
160             ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
161     }
162 }
163
164 - (IBAction)advancedToggle: (id)sender
165 {
166     b_advanced = !b_advanced;
167     [o_advanced_ckb setState: b_advanced];
168     /* refresh the view of the current treeitem */
169     [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView:
170         ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
171 }
172
173 - (void)loadConfigTree
174 {
175 }
176
177 - (void)outlineViewSelectionIsChanging:(NSNotification *)o_notification
178 {
179 }
180
181 /* update the document view to the view of the selected tree item */
182 - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
183 {
184     [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view
185         advancedView:( [o_advanced_ckb state] == NSOnState ) ?
186         VLC_TRUE : VLC_FALSE];
187 }
188
189 @end
190
191 @implementation VLCPrefs (NSTableDataSource)
192
193 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
194     return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] :
195                             [item numberOfChildren];
196 }
197
198 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
199 {
200     return (item == nil) ? YES : ( ([item numberOfChildren] != -1) &&
201                                    ([item numberOfChildren] != 0));
202 }
203
204 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item {
205     return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] :
206                             (id)[item childAtIndex:index];
207 }
208
209 - (id)outlineView:(NSOutlineView *)outlineView
210     objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
211 {
212     return (item == nil) ? @"" : (id)[item getName];
213 }
214
215 @end
216
217 @implementation VLCTreeItem
218
219 static VLCTreeItem *o_root_item = nil;
220
221 #define IsALeafNode ((id)-1)
222
223 - (id)initWithName: (NSString *)o_item_name
224     withTitle: (NSString *)o_item_title
225     withHelp: (NSString *)o_item_help
226     ID: (int)i_id
227     parent:(VLCTreeItem *)o_parent_item
228     children:(NSMutableArray *)o_children_array
229     whithCategory: (int) i_category
230 {
231     self = [super init];
232
233     if( self != nil )
234     {
235         o_name = [o_item_name copy];
236         o_title= [o_item_title copy];
237         o_help= [o_item_help copy];
238         i_object_id = i_id;
239         o_parent = o_parent_item;
240         o_children = o_children_array;
241         i_object_category = i_category;
242         o_subviews = nil;
243     }
244     return( self );
245 }
246
247 + (VLCTreeItem *)rootItem
248 {
249    if (o_root_item == nil)
250         o_root_item = [[VLCTreeItem alloc] initWithName:@"main" withTitle:@"main" withHelp:@"" ID:0
251             parent:nil children:[[NSMutableArray alloc] initWithCapacity:10]
252             whithCategory: -1];
253    return o_root_item;
254 }
255
256 - (void)dealloc
257 {
258     if (o_children != IsALeafNode) [o_children release];
259     [o_name release];
260     [o_title release];
261     [o_help release];
262     [super dealloc];
263 }
264
265 /* Creates and returns the array of children
266  * Loads children incrementally */
267 - (NSArray *)children
268 {
269     if( o_children == IsALeafNode )
270         return o_children;
271     if( [ o_children count] == 0 )
272     {
273         intf_thread_t   *p_intf = VLCIntf;
274         vlc_list_t      *p_list;
275         module_t        *p_module = NULL;
276         module_t        *p_parser;
277         module_config_t *p_item,
278                         *p_end;
279         int             i_index = 0;
280
281         /* List the modules */
282         p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
283         if( !p_list ) return nil;
284
285         /* get parser */
286         p_parser = (module_t *)p_list->p_values[i_index].p_object;
287
288         if( [[self getName] isEqualToString: @"main"] )
289         {
290             /*
291             * Find the main module
292             */
293             for( i_index = 0; i_index < p_list->i_count; i_index++ )
294             {
295                 p_module = (module_t *)p_list->p_values[i_index].p_object;
296                 if( !strcmp( module_GetObjName( p_module ), "main" ) )
297                     break;
298             }
299             if( p_module == NULL )
300             {
301                 msg_Err( p_intf,
302                     "could not load the preferences" );
303                 return nil;
304             }
305             if( i_index < p_list->i_count )
306             {
307                 /* We found the main module */
308                 /* Enumerate config categories and store a reference so we can
309                  * generate their config panel them when it is asked by the user. */
310                 VLCTreeItem *p_last_category = NULL;
311                 unsigned int i_confsize;
312                 p_item = module_GetConfig( p_parser, &i_confsize );
313                 p_end = p_item + i_confsize;
314                 o_children = [[NSMutableArray alloc] initWithCapacity:10];
315                 if( p_item ) do
316                 {
317                     NSString *o_child_name;
318                     NSString *o_child_title;
319                     NSString *o_child_help;
320                     switch( p_item->i_type )
321                     {
322                     case CONFIG_CATEGORY:
323                         if( p_item->value.i == -1 ) break;
324
325                         o_child_name = [[VLCMain sharedInstance]
326                             localizedString: config_CategoryNameGet( p_item->value.i )];
327                         o_child_title = o_child_name;
328                         o_child_help = [[VLCMain sharedInstance]
329                             localizedString: config_CategoryHelpGet( p_item->value.i )];
330                         p_last_category = [VLCTreeItem alloc];
331                         [o_children addObject:[p_last_category
332                             initWithName: o_child_name
333                             withTitle: o_child_title
334                             withHelp: o_child_help
335                             ID: p_item->value.i
336                             parent:self
337                             children:[[NSMutableArray alloc]
338                                 initWithCapacity:10]
339                             whithCategory: p_item - module_GetConfig( p_module, &i_confsize )]];
340                         break;
341                     case CONFIG_SUBCATEGORY:
342                         if( p_item->value.i == -1 ) break;
343
344                         if( p_item->value.i != SUBCAT_PLAYLIST_GENERAL &&
345                             p_item->value.i != SUBCAT_VIDEO_GENERAL &&
346                             p_item->value.i != SUBCAT_INPUT_GENERAL &&
347                             p_item->value.i != SUBCAT_INTERFACE_GENERAL &&
348                             p_item->value.i != SUBCAT_SOUT_GENERAL &&
349                             p_item->value.i != SUBCAT_ADVANCED_MISC &&
350                             p_item->value.i != SUBCAT_AUDIO_GENERAL )
351                         {
352                             o_child_name = [[VLCMain sharedInstance]
353                                 localizedString: config_CategoryNameGet( p_item->value.i ) ];
354                             o_child_title = o_child_name;
355                             o_child_help = [[VLCMain sharedInstance]
356                                 localizedString: config_CategoryHelpGet( p_item->value.i ) ];
357
358                             [p_last_category->o_children
359                                 addObject:[[VLCTreeItem alloc]
360                                 initWithName: o_child_name
361                                 withTitle: o_child_title
362                                 withHelp: o_child_help
363                                 ID: p_item->value.i
364                                 parent:p_last_category
365                                 children:[[NSMutableArray alloc]
366                                     initWithCapacity:10]
367                                 whithCategory: p_item - module_GetConfig( p_parser, &i_confsize )]];
368                         }
369  
370                         break;
371                     default:
372                         break;
373                     }
374                 } while( p_item < p_end && p_item++ );
375             }
376
377             /* Build a tree of the plugins */
378             /* Add the capabilities */
379             for( i_index = 0; i_index < p_list->i_count; i_index++ )
380             {
381                 unsigned int confsize;
382                 p_module = (module_t *)p_list->p_values[i_index].p_object;
383
384                 /* Exclude the main module */
385                 if( !strcmp( module_GetObjName( p_module ), "main" ) )
386                     continue;
387
388                 /* Exclude empty plugins (submodules don't have config */
389                 /* options, they are stored in the parent module) */
390 // Does not work
391 //                if( modules_IsSubModule( p_module ) )
392 //                    continue;
393                 p_item = module_GetConfig( p_module, &confsize );
394
395                 if( !p_item ) continue;
396                 int i_category = -1;
397                 int i_subcategory = -1;
398                 int i_options = 0;
399                 do
400                 {
401                     if( p_item->i_type == CONFIG_CATEGORY )
402                         i_category = p_item->value.i;
403                     else if( p_item->i_type == CONFIG_SUBCATEGORY )
404                         i_subcategory = p_item->value.i;
405
406                     if( p_item->i_type & CONFIG_ITEM )
407                         i_options ++;
408                     if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
409                         break;
410                 } while( p_item < p_end && p_item++ );
411                 if( !i_options ) continue;
412
413                 /* Find the right category item */
414
415                 long cookie;
416                 vlc_bool_t b_found = VLC_FALSE;
417                 unsigned int i;
418                 VLCTreeItem* p_category_item, * p_subcategory_item;
419                 for (i = 0 ; i < [o_children count] ; i++)
420                 {
421                     p_category_item = [o_children objectAtIndex: i];
422                     if( p_category_item->i_object_id == i_category )
423                     {
424                         b_found = VLC_TRUE;
425                         break;
426                     }
427                 }
428                 if( !b_found ) continue;
429
430                 /* Find subcategory item */
431                 b_found = VLC_FALSE;
432                 cookie = -1;
433                 for (i = 0 ; i < [p_category_item->o_children count] ; i++)
434                 {
435                     p_subcategory_item = [p_category_item->o_children
436                                             objectAtIndex: i];
437                     if( p_subcategory_item->i_object_id == i_subcategory )
438                     {
439                         b_found = VLC_TRUE;
440                         break;
441                     }
442                 }
443                 if( !b_found )
444                     p_subcategory_item = p_category_item;
445
446                 [p_subcategory_item->o_children addObject:[[VLCTreeItem alloc]
447                     initWithName:[[VLCMain sharedInstance]
448                         localizedString: module_GetName( p_module, VLC_FALSE ) ]
449                     withTitle:[[VLCMain sharedInstance]
450                         localizedString:  module_GetLongName( p_module ) ]
451                     withHelp: @""
452                     ID: ((vlc_object_t*)p_module)->i_object_id
453                     parent:p_subcategory_item
454                     children:IsALeafNode
455                     whithCategory: -1]];
456                 }
457         }
458         vlc_list_release( p_list );
459     }
460     return o_children;
461 }
462
463 - (int)getObjectID
464 {
465     return i_object_id;
466 }
467
468 - (NSString *)getName
469 {
470     return o_name;
471 }
472
473 - (NSString *)getTitle
474 {
475     return o_title;
476 }
477
478 - (NSString *)getHelp
479 {
480     return o_help;
481 }
482
483 - (VLCTreeItem *)childAtIndex:(int)i_index
484 {
485     return [[self children] objectAtIndex:i_index];
486 }
487
488 - (int)numberOfChildren {
489     id i_tmp = [self children];
490     return (i_tmp == IsALeafNode) ? (-1) : (int)[i_tmp count];
491 }
492
493 - (BOOL)hasPrefs:(NSString *)o_module_name
494 {
495     intf_thread_t *p_intf = VLCIntf;
496     module_t *p_parser;
497     vlc_list_t *p_list;
498     char *psz_module_name;
499     int i_index;
500
501     psz_module_name = (char *)[o_module_name UTF8String];
502
503     /* look for module */
504     p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
505
506     for( i_index = 0; i_index < p_list->i_count; i_index++ )
507     {
508         p_parser = (module_t *)p_list->p_values[i_index].p_object ;
509
510         if( !strcmp( module_GetObjName( p_parser ), psz_module_name ) )
511         {
512             unsigned int confsize;
513             module_GetConfig( p_parser, &confsize );
514             BOOL b_has_prefs = confsize != 0;
515             vlc_list_release( p_list );
516             return( b_has_prefs );
517         }
518     }
519
520     vlc_list_release( p_list );
521
522     return( NO );
523 }
524
525 - (NSView *)showView:(NSScrollView *)o_prefs_view
526     advancedView:(vlc_bool_t) b_advanced
527 {
528     NSRect          s_vrc;
529     NSView          *o_view;
530
531     [[VLCPrefs sharedInstance] setTitle: [self getTitle]];
532     /* NSLog( [self getHelp] ); */
533     s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
534     o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
535     [o_view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin |
536                                     NSViewMaxYMargin];
537
538 /* Create all subviews if it isn't already done because we cannot use */
539 /* setHiden for MacOS < 10.3*/
540     if( o_subviews == nil )
541     {
542         intf_thread_t   *p_intf = VLCIntf;
543         vlc_list_t      *p_list;
544         module_t        *p_parser = NULL;
545         module_config_t *p_item,
546                         *p_end;
547         unsigned int confsize;
548
549         o_subviews = [[NSMutableArray alloc] initWithCapacity:10];
550         /* Get a pointer to the module */
551         if( i_object_category == -1 )
552         {
553             p_parser = (module_t *) vlc_object_get( i_object_id );
554             if( !p_parser || ((vlc_object_t*)p_parser)->i_object_type != VLC_OBJECT_MODULE )
555             {
556                 /* 0OOoo something went really bad */
557                 return nil;
558             }
559             p_item = module_GetConfig( p_parser, &confsize );
560             p_end = p_item + confsize;
561
562             do
563             {
564                 if( !p_item )
565                 {
566                     msg_Err( p_intf, "invalid preference item found" );
567                     break;
568                 }
569                 if( p_item > p_end )
570                     break;
571                 switch(p_item->i_type)
572                 {
573                 case CONFIG_SUBCATEGORY:
574                     break;
575                 case CONFIG_CATEGORY:
576                     break;
577                 case CONFIG_SECTION:
578                     break;
579                 case CONFIG_HINT_USAGE:
580                     break;
581                 default:
582                 {
583                     VLCConfigControl *o_control = nil;
584                     o_control = [VLCConfigControl newControl:p_item
585                                                   withView:o_view];
586                     if( o_control != nil )
587                     {
588                         [o_control setAutoresizingMask: NSViewMaxYMargin |
589                             NSViewWidthSizable];
590                         [o_subviews addObject: o_control];
591                     }
592                 }
593                     break;
594                 }
595             } while( p_item < p_end && p_item++ );
596
597             vlc_object_release( (vlc_object_t*)p_parser );
598         }
599         else
600         {
601             int i_index;
602             p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
603             if( !p_list ) return o_view;
604
605             /*
606             * Find the main module
607             */
608             for( i_index = 0; i_index < p_list->i_count; i_index++ )
609             {
610                 p_parser = (module_t *)p_list->p_values[i_index].p_object;
611                 if( !strcmp( module_GetObjName( p_parser ), "main" ) )
612                     break;
613             }
614             if( p_parser == NULL )
615             {
616                 msg_Err( p_intf, "could not load preferences" );
617                 return o_view;
618             }
619             unsigned int confsize;
620             p_item = module_GetConfig( p_parser, &confsize );
621             p_end = p_item + confsize;
622             p_item += i_object_category;
623
624             if( ( p_item->i_type == CONFIG_CATEGORY ) &&
625               ( ( p_item->value.i == CAT_PLAYLIST )  ||
626                 ( p_item->value.i == CAT_AUDIO )  ||
627                 ( p_item->value.i == CAT_VIDEO ) ||
628                 ( p_item->value.i == CAT_INTERFACE ) ||
629                 ( p_item->value.i == CAT_INPUT ) ||
630                 ( p_item->value.i == CAT_SOUT ) ) )
631                 p_item++;
632
633             do
634             {
635                 p_item++;
636                 if( !p_item || !p_item->i_type )
637                 {
638                     msg_Err( p_intf, "invalid preference item found" );
639                     break;
640                 }
641                 if( p_item > p_end )
642                     break;
643                 switch( p_item->i_type )
644                 {
645                 case CONFIG_SUBCATEGORY:
646                     break;
647                 case CONFIG_CATEGORY:
648                     break;
649                 case CONFIG_SECTION:
650                     break;
651                 case CONFIG_HINT_USAGE:
652                     break;
653                 default:
654                 {
655                     VLCConfigControl *o_control = nil;
656                     o_control = [VLCConfigControl newControl:p_item
657                                                   withView:o_view];
658                     if( o_control != nil )
659                     {
660                         [o_control setAutoresizingMask: NSViewMaxYMargin |
661                                                         NSViewWidthSizable];
662                         [o_subviews addObject: o_control];
663                     }
664                     break;
665                 }
666                 }
667             } while ( ( p_item < p_end ) &&
668                       ( p_item->i_type != CONFIG_SUBCATEGORY ) );
669
670             vlc_list_release( p_list );
671         }
672     }
673
674     if( o_view != nil )
675     {
676         int i_lastItem = 0;
677         int i_yPos = -2;
678         int i_max_label = 0;
679         int i_show_advanced = 0;
680
681         NSEnumerator *enumerator = [o_subviews objectEnumerator];
682         VLCConfigControl *o_widget;
683         NSRect o_frame;
684  
685         while( ( o_widget = [enumerator nextObject] ) )
686             if( ( [o_widget isAdvanced] ) && (! b_advanced) )
687                 continue;
688             else if( i_max_label < [o_widget getLabelSize] )
689                 i_max_label = [o_widget getLabelSize];
690
691         enumerator = [o_subviews objectEnumerator];
692         while( ( o_widget = [enumerator nextObject] ) )
693         {
694             int i_widget;
695             if( ( [o_widget isAdvanced] ) && (! b_advanced) )
696             {
697                 i_show_advanced++;
698                 continue;
699             }
700
701             i_widget = [o_widget getViewType];
702             i_yPos += [VLCConfigControl calcVerticalMargin:i_widget
703                 lastItem:i_lastItem];
704             [o_widget setYPos:i_yPos];
705             o_frame = [o_widget frame];
706             o_frame.size.width = [o_view frame].size.width -
707                                     LEFTMARGIN - RIGHTMARGIN;
708             [o_widget setFrame:o_frame];
709             [o_widget alignWithXPosition: i_max_label];
710             i_yPos += [o_widget frame].size.height;
711             i_lastItem = i_widget;
712             [o_view addSubview:o_widget];
713          }
714         if( i_show_advanced != 0 )
715         {
716             /* We add the advanced notice... */
717             NSRect s_rc = [o_view frame];
718             NSTextField *o_label;
719             s_rc.size.height = 17;
720             s_rc.origin.x = LEFTMARGIN;
721             s_rc.origin.y = i_yPos += [VLCConfigControl
722                                         calcVerticalMargin:CONFIG_ITEM_STRING
723                                         lastItem:i_lastItem];
724             o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
725             [o_label setDrawsBackground: NO];
726             [o_label setBordered: NO];
727             [o_label setEditable: NO];
728             [o_label setSelectable: NO];
729             [o_label setStringValue: _NS("Some options are hidden. " \
730                                 "Check \"Advanced\" to display them.")];
731             [o_label setFont:[NSFont systemFontOfSize:10]];
732             [o_label sizeToFit];
733             [o_view addSubview:o_label];
734             i_yPos += [o_label frame].size.height;
735         }
736         o_frame = [o_view frame];
737         o_frame.size.height = i_yPos;
738         [o_view setFrame:o_frame];
739         [o_prefs_view setDocumentView:o_view];
740
741     }
742     return o_view;
743 }
744
745 - (void)applyChanges
746 {
747     unsigned int i;
748     if( o_subviews != nil )
749         //Item has been shown
750         for( i = 0 ; i < [o_subviews count] ; i++ )
751             [[o_subviews objectAtIndex:i] applyChanges];
752
753     if( o_children != IsALeafNode )
754         for( i = 0 ; i < [o_children count] ; i++ )
755             [[o_children objectAtIndex:i] applyChanges];
756 }
757
758 - (void)resetView
759 {
760     unsigned int i;
761     if( o_subviews != nil )
762     {
763         //Item has been shown
764         [o_subviews release];
765         o_subviews = nil;
766     }
767
768     if( o_children != IsALeafNode )
769         for( i = 0 ; i < [o_children count] ; i++ )
770             [[o_children objectAtIndex:i] resetView];
771 }
772
773 @end
774
775
776 @implementation VLCFlippedView
777
778 - (BOOL)isFlipped
779 {
780     return( YES );
781 }
782
783 @end