]> git.sesse.net Git - vlc/blob - modules/gui/macosx/prefs.m
- added macosx version detection at runtime with /System/Library/CoreServices/SystemV...
[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_view = 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     if( o_view == nil )
468     {
469         intf_thread_t   *p_intf = VLCIntf;
470         vlc_list_t      *p_list;
471         module_t        *p_parser = NULL;
472         module_config_t *p_item;
473         NSRect          s_vrc;
474
475         s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
476         o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
477         [o_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
478
479         /* Get a pointer to the module */
480         if( i_object_category == -1 )
481         {
482             p_parser = (module_t *) vlc_object_get( p_intf, i_object_id );
483             if( !p_parser || p_parser->i_object_type != VLC_OBJECT_MODULE )
484             {
485                 /* 0OOoo something went really bad */
486                 return nil;
487             }
488             p_item = p_parser->p_config;
489             int i = 0;
490             int i_yPos = -2;
491             int i_lastItem = 0;
492
493             p_item = p_parser->p_config + 1;
494
495             do
496             {
497                 if( !p_item )
498                 {
499                     msg_Err( "null item found" );
500                     break;
501                 }
502                 switch(p_item->i_type)
503                 {
504                 case CONFIG_SUBCATEGORY:
505 fprintf( stderr, "drawing subcategory %s\n", [o_name UTF8String] );
506                     break;
507                 case CONFIG_SECTION:
508 fprintf( stderr, "drawing section %s\n", p_item->psz_text );
509                     break;
510                 case CONFIG_CATEGORY:
511 fprintf( stderr, "drawing category %s\n", [o_name UTF8String] );
512                     break;
513                 case CONFIG_HINT_END:
514 fprintf( stderr, "end of (sub)category\n" );
515                     break;
516                 case CONFIG_HINT_USAGE:
517 fprintf( stderr, "skipping hint usage\n" );
518                     break;
519                 default:
520 fprintf( stderr, "%s (%d) is ", p_item->psz_name, p_item->i_type );
521                 {
522                     VLCConfigControl *o_control = nil;
523                     int i_widget = 0;
524                     if( p_item->b_advanced && (! b_advanced) )
525                         break;
526                     switch( p_item->i_type )
527                     {
528                     case CONFIG_ITEM_STRING:
529 fprintf( stderr, "CONFIG_ITEM_STRING" );
530                         if( !p_item->i_list )
531                             i_widget = CONFIG_ITEM_STRING;
532                         else
533                             i_widget = CONFIG_ITEM_STRING_LIST;
534                         break;
535                     case CONFIG_ITEM_FILE:
536                     case CONFIG_ITEM_DIRECTORY:
537 fprintf( stderr, "CONFIG_ITEM_FILE" );
538                         i_widget = CONFIG_ITEM_FILE;
539                         break;
540                     case CONFIG_ITEM_MODULE:
541                     case CONFIG_ITEM_MODULE_CAT:
542 fprintf( stderr, "CONFIG_ITEM_MODULE" );
543                         i_widget = CONFIG_ITEM_MODULE;
544                         break;
545                     case CONFIG_ITEM_INTEGER:
546 fprintf( stderr, "CONFIG_ITEM_INTEGER" );
547                         if( p_item->i_list )
548                             i_widget = CONFIG_ITEM_STRING_LIST;
549                         else if( p_item->i_min != 0 || p_item->i_max != 0 )
550                             i_widget = CONFIG_ITEM_RANGED_INTEGER;
551                         else
552                             i_widget = CONFIG_ITEM_INTEGER;
553                         break;
554                     case CONFIG_ITEM_FLOAT:
555 fprintf( stderr, "CONFIG_ITEM_FLOAT" );
556                         if( p_item->f_min != 0 || p_item->f_max != 0 )
557                             i_widget = CONFIG_ITEM_RANGED_INTEGER;
558                         else
559                             i_widget = CONFIG_ITEM_INTEGER;
560                         break;
561                     case CONFIG_ITEM_BOOL:
562 fprintf( stderr, "CONFIG_ITEM_BOOL" );
563                         i_widget = CONFIG_ITEM_BOOL;
564                         break;
565                     case CONFIG_ITEM_KEY:
566 fprintf( stderr, "CONFIG_ITEM_KEY" );
567                         if( MACOS_VERSION < 10.3 )
568                             i_widget = CONFIG_ITEM_KEY_BEFORE_10_3;
569                         else
570                             i_widget = CONFIG_ITEM_KEY_AFTER_10_3;
571                         break;
572                     case CONFIG_ITEM_MODULE_LIST:
573                     case CONFIG_ITEM_MODULE_LIST_CAT:
574 fprintf( stderr, "CONFIG_ITEM_MODULE_LIST" );
575                         i_widget = CONFIG_ITEM_MODULE_LIST;
576                         break;
577                     default:
578 fprintf( stderr, "***UNKNOWN***" );
579                     }
580                     if( i_widget != 0 )
581                     {
582                         i_yPos += [VLCConfigControl
583                             calcVerticalMargin:i_widget lastItem:i_lastItem];
584                         o_control = [VLCConfigControl newControl:p_item
585                                                       withView:o_view
586                                                       yOffset: i_yPos
587                                                       lastItem: i_lastItem];
588                         if( o_control != nil )
589                         {
590                             i_yPos += [o_control frame].size.height;
591                             i_lastItem = i_widget;
592                             [o_control setAutoresizingMask: NSViewMaxYMargin |
593                                 NSViewWidthSizable];
594                             [o_view addSubview: o_control];
595                         }
596                     }
597 fprintf( stderr, "\n" );
598                     break;
599                 }
600                 }
601             } while( p_item++->i_type != CONFIG_HINT_END );
602
603             vlc_object_release( p_parser );
604         }
605         else
606         {
607             int i = 0;
608             int i_yPos = -2;
609             int i_lastItem = 0;
610             int i_index;
611             p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
612             if( !p_list ) return o_view;
613
614             /*
615             * Find the main module
616             */
617             for( i_index = 0; i_index < p_list->i_count; i_index++ )
618             {
619                 p_parser = (module_t *)p_list->p_values[i_index].p_object;
620                 if( !strcmp( p_parser->psz_object_name, "main" ) )
621                     break;
622             }
623             if( p_parser == NULL )
624             {
625                 msg_Err( p_intf, "could not find the main module in our "
626                                     "preferences" );
627                 return o_view;
628             }
629             p_item = (p_parser->p_config + i_object_category);
630             if( ( p_item->i_type == CONFIG_CATEGORY ) &&
631               ( ( p_item->i_value == CAT_AUDIO )  ||
632                 ( p_item->i_value == CAT_VIDEO ) ) )
633                 p_item++;
634
635             do
636             {
637                 p_item++;
638                 if( !p_item )
639                 {
640                     msg_Err( "null item found" );
641                     break;
642                 }
643                 switch(p_item->i_type)
644                 {
645                 case CONFIG_SUBCATEGORY:
646 fprintf( stderr, "drawing subcategory %s\n", [o_name UTF8String] );
647                     break;
648                 case CONFIG_SECTION:
649 fprintf( stderr, "drawing section %s\n", p_item->psz_text );
650                     break;
651                 case CONFIG_CATEGORY:
652 fprintf( stderr, "drawing category %s\n", [o_name UTF8String] );
653                     break;
654                 case CONFIG_HINT_END:
655 fprintf( stderr, "end of (sub)category\n" );
656                     break;
657                 case CONFIG_HINT_USAGE:
658 fprintf( stderr, "skipping hint usage\n" );
659                     break;
660                 default:
661 fprintf( stderr, "%s (%d) is ", p_item->psz_name, p_item->i_type );
662                 {
663                     VLCConfigControl *o_control = nil;
664                     int i_widget = 0;
665                     switch( p_item->i_type )
666                     {
667                     case CONFIG_ITEM_STRING:
668 fprintf( stderr, "CONFIG_ITEM_STRING" );
669                         if( !p_item->i_list )
670                             i_widget = CONFIG_ITEM_STRING;
671                         else
672                             i_widget = CONFIG_ITEM_STRING_LIST;
673                         break;
674                     case CONFIG_ITEM_FILE:
675                     case CONFIG_ITEM_DIRECTORY:
676 fprintf( stderr, "CONFIG_ITEM_FILE" );
677                         i_widget = CONFIG_ITEM_FILE;
678                         break;
679                     case CONFIG_ITEM_MODULE:
680                     case CONFIG_ITEM_MODULE_CAT:
681 fprintf( stderr, "CONFIG_ITEM_MODULE" );
682                         i_widget = CONFIG_ITEM_MODULE;
683                         break;
684                     case CONFIG_ITEM_INTEGER:
685 fprintf( stderr, "CONFIG_ITEM_INTEGER" );
686                         if( p_item->i_list )
687                             i_widget = CONFIG_ITEM_STRING_LIST;
688                         else if( p_item->i_min != 0 || p_item->i_max != 0 )
689                             i_widget = CONFIG_ITEM_RANGED_INTEGER;
690                         else
691                             i_widget = CONFIG_ITEM_INTEGER;
692                         break;
693                     case CONFIG_ITEM_FLOAT:
694 fprintf( stderr, "CONFIG_ITEM_FLOAT" );
695                         if( p_item->f_min != 0 || p_item->f_max != 0 )
696                             i_widget = CONFIG_ITEM_RANGED_INTEGER;
697                         else
698                             i_widget = CONFIG_ITEM_INTEGER;
699                         break;
700                     case CONFIG_ITEM_BOOL:
701 fprintf( stderr, "CONFIG_ITEM_BOOL" );
702                         i_widget = CONFIG_ITEM_BOOL;
703                         break;
704                     case CONFIG_ITEM_KEY:
705 fprintf( stderr, "CONFIG_ITEM_KEY" );
706                         if( MACOS_VERSION < 10.3 )
707                             i_widget = CONFIG_ITEM_KEY_BEFORE_10_3;
708                         else
709                             i_widget = CONFIG_ITEM_KEY_AFTER_10_3;
710                         break;
711                     case CONFIG_ITEM_MODULE_LIST:
712                     case CONFIG_ITEM_MODULE_LIST_CAT:
713 fprintf( stderr, "CONFIG_ITEM_MODULE_LIST" );
714                         i_widget = CONFIG_ITEM_MODULE_LIST;
715                         break;
716                     default:
717 fprintf( stderr, "***UNKNOWN***" );
718                     }
719                     if( i_widget != 0 )
720                     {
721                         i_yPos += [VLCConfigControl
722                             calcVerticalMargin:i_widget lastItem:i_lastItem];
723                         o_control = [VLCConfigControl newControl:p_item
724                                                       withView:o_view
725                                                       yOffset: i_yPos
726                                                       lastItem: i_lastItem];
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_view addSubview: 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     else
748     {
749         NSRect s_vrc;
750         s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
751         [o_view setFrame: s_vrc];
752     }
753     if( o_view != nil )
754         [o_prefs_view setDocumentView:o_view];
755     return o_view;
756 }
757
758 - (void)applyChanges
759 {
760     unsigned int i;
761     if( o_view != nil )
762     {
763     //Item has been shown
764 fprintf( stderr, "[%s] applying changes\n", [o_name cString]);
765         NSArray *o_subviews = [o_view subviews];
766         for( i = 0 ; i < [o_subviews count] ; i++ )
767             [[o_subviews objectAtIndex:i] applyChanges];
768     }
769     if( o_children != IsALeafNode )
770         for( i = 0 ; i < [o_children count] ; i++ )
771             [[o_children objectAtIndex:i] applyChanges];
772 }
773
774 @end
775
776
777 @implementation VLCFlippedView
778
779 - (BOOL)isFlipped
780 {
781     return( YES );
782 }
783
784 @end