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