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