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