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