]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/prefs.m
macosx: get rid of the infamous 'get' prefixes everywhere and finally respect Cocoa...
[vlc] / modules / gui / macosx / prefs.m
index 52577b12d437c8b77edf7b52d4fbd286e63ece62..91dab2bec1a9996f03869177bd309c10ec3abafa 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * prefs.m: MacOS X module for vlc
  *****************************************************************************
- * Copyright (C) 2002-2005 VideoLAN
+ * Copyright (C) 2002-2006 the VideoLAN team
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-/* VLCPrefs manages the main preferences dialog 
+/* VLCPrefs manages the main preferences dialog
    the class is related to wxwindows intf, PrefsPanel */
 /* VLCTreeItem should contain:
    - the children of the treeitem
@@ -30,7 +30,6 @@
    - the documentview with all the prefs widgets in it
    - a saveChanges action
    - a revertChanges action
-   - an advanced action (to hide/show advanced options)
    - a redraw view action
    - the children action should generate a list of the treeitems children (to be used by VLCPrefs datasource)
 
 #include <sys/param.h>                                    /* for MAXPATHLEN */
 #include <string.h>
 
-#include "intf.h"
-#include "prefs.h"
-#include "vlc_keys.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_config_cat.h>
+
+#import "intf.h"
+#import "prefs.h"
+#import "simple_prefs.h"
+#import "prefs_widgets.h"
+#import "vlc_keys.h"
+
+/* /!\ Warning: Unreadable code :/ */
+
+@interface VLCTreeItem : NSObject
+{
+    NSString *_name;
+    NSMutableArray *_children;
+    NSMutableArray *_subviews;
+    module_config_t * _configItem;
+}
+- (id)initWithConfigItem:(module_config_t *)configItem;
+
+- (id)initWithName:(NSString*)name andConfigItem:(module_config_t *)configItem;
+
+- (int)numberOfChildren;
+- (VLCTreeItem *)childAtIndex:(int)i_index;
+
+- (module_config_t *)configItem;
+
+- (NSString *)name;
+- (NSMutableArray *)children;
+- (void)showView:(NSScrollView *)o_prefs_view;
+- (void)applyChanges;
+- (void)resetView;
+
+@end
+
+@interface VLCTreeSubCategoryItem : VLCTreeItem
+{
+    int _subCategory;
+}
++ (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)category;
+- (id)initWithSubCategory:(int)subCategory;
+- (int)subCategory;
+@end
+
+@interface VLCTreeCategoryItem : VLCTreeItem
+{
+    int _category;
+}
++ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category;
+- (id)initWithCategory:(int)category;
+- (int)category;
+- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)category;
+@end
+
+
+@interface VLCTreeLeafItem : VLCTreeItem
+{ }
+@end
+
+@interface VLCTreeMainItem : VLCTreeItem
+{
+    module_config_t * _configItems;
+}
+- (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category;
+@end
+
+#pragma mark -
 
 /*****************************************************************************
  * VLCPrefs implementation
@@ -72,40 +139,41 @@ static VLCPrefs *_o_sharedMainInstance = nil;
         _o_sharedMainInstance = [super init];
         p_intf = VLCIntf;
         o_empty_view = [[NSView alloc] init];
+        _rootTreeItem = [[VLCTreeMainItem alloc] init];
     }
-    
+
     return _o_sharedMainInstance;
 }
 
 - (void)dealloc
 {
     [o_empty_view release];
+    [_rootTreeItem release];
     [super dealloc];
 }
 
 - (void)awakeFromNib
 {
     p_intf = VLCIntf;
-    b_advanced = config_GetInt( p_intf, "advanced" );
 
     [self initStrings];
-    [o_advanced_ckb setState: b_advanced];
     [o_prefs_view setBorderType: NSGrooveBorder];
     [o_prefs_view setHasVerticalScroller: YES];
     [o_prefs_view setDrawsBackground: NO];
-    [o_prefs_view setRulersVisible: NO];
     [o_prefs_view setDocumentView: o_empty_view];
     [o_tree selectRow:0 byExtendingSelection:NO];
 }
 
+- (void)setTitle: (NSString *) o_title_name
+{
+    [o_title setStringValue: o_title_name];
+}
+
 - (void)showPrefs
 {
-    /* load our nib (if not already loaded) */
-    [NSBundle loadNibNamed:@"Preferences" owner:self];
+    [[o_basicFull_matrix cellAtRow:0 column:0] setState: NSOffState];
+    [[o_basicFull_matrix cellAtRow:0 column:1] setState: NSOnState];
     
-    /* Show View for the currently select treeitem */
-    /* [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
-        andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]]; */
     [o_prefs_window center];
     [o_prefs_window makeKeyAndOrderFront:self];
 }
@@ -116,12 +184,14 @@ static VLCPrefs *_o_sharedMainInstance = nil;
     [o_save_btn setTitle: _NS("Save")];
     [o_cancel_btn setTitle: _NS("Cancel")];
     [o_reset_btn setTitle: _NS("Reset All")];
-    [o_advanced_ckb setTitle: _NS("Advanced")];
+    [[o_basicFull_matrix cellAtRow: 0 column: 0] setStringValue: _NS("Basic")];
+    [[o_basicFull_matrix cellAtRow: 0 column: 1] setStringValue: _NS("All")];
 }
 
 - (IBAction)savePrefs: (id)sender
 {
     /* TODO: call savePrefs on Root item */
+    [_rootTreeItem applyChanges];
     config_SaveConfigFile( p_intf, NULL );
     [o_prefs_window orderOut:self];
 }
@@ -133,29 +203,32 @@ static VLCPrefs *_o_sharedMainInstance = nil;
 
 - (IBAction)resetAll: (id)sender
 {
-    NSBeginInformationalAlertSheet(_NS("Reset Preferences"), _NS("Cancel"), _NS("Continue"), 
-        nil, o_prefs_window, self, @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
-        _NS("Beware this will reset your VLC media player preferences.\n"
+    NSBeginInformationalAlertSheet(_NS("Reset Preferences"), _NS("Cancel"),
+        _NS("Continue"), nil, o_prefs_window, self,
+        @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
+        _NS("Beware this will reset the VLC media player preferences.\n"
             "Are you sure you want to continue?") );
 }
 
-- (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return contextInfo:(void *)o_context
+- (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return
+    contextInfo:(void *)o_context
 {
     if( i_return == NSAlertAlternateReturn )
     {
+        [o_prefs_view setDocumentView: o_empty_view];
         config_ResetAll( p_intf );
-        [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
-            andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];
+        [_rootTreeItem resetView];
+        [[o_tree itemAtRow:[o_tree selectedRow]]
+            showView:o_prefs_view];
     }
 }
 
-- (IBAction)advancedToggle: (id)sender
+- (IBAction)buttonAction: (id)sender
 {
-    b_advanced = !b_advanced;
-    [o_advanced_ckb setState: b_advanced];
-    /* refresh the view of the current treeitem */
-    /* [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
-        andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]]; */
+    [o_prefs_window orderOut: self];
+    [[o_basicFull_matrix cellAtRow:0 column:0] setState: NSOnState];
+    [[o_basicFull_matrix cellAtRow:0 column:1] setState: NSOffState];
+    [[[VLCMain sharedInstance] simplePreferences] showSimplePrefs];
 }
 
 - (void)loadConfigTree
@@ -169,314 +242,328 @@ static VLCPrefs *_o_sharedMainInstance = nil;
 /* update the document view to the view of the selected tree item */
 - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
 {
-    /*
-    [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
-        andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];*/
+    [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view];
 }
 
 @end
 
 @implementation VLCPrefs (NSTableDataSource)
 
-- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
-    return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] : [item numberOfChildren];
+- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
+{
+    return (item == nil) ? [_rootTreeItem numberOfChildren] : [item numberOfChildren];
 }
 
-- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
-    return (item == nil) ? YES : ([item numberOfChildren] != -1);
+- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
+{
+    return ![item isKindOfClass:[VLCTreeSubCategoryItem class]];
 }
 
-- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item {
-    return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] : [item childAtIndex:index];
+- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
+{
+    return (item == nil) ? (id)[_rootTreeItem childAtIndex:index]: (id)[item childAtIndex:index];
 }
 
-- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
-    return (item == nil) ? @"" : (id)[item getName];
+- (id)outlineView:(NSOutlineView *)outlineView
+    objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
+{
+    return (item == nil) ? @"" : [item name];
 }
 
 @end
 
-@implementation VLCTreeItem
-
-static VLCTreeItem *o_root_item = nil;
-
-#define IsALeafNode ((id)-1)
+#pragma mark -
+@implementation VLCTreeMainItem
 
-- (id)initWithName: (NSString *)o_item_name ID: (int)i_id parent:(VLCTreeItem *)o_parent_item
+- (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category
 {
-    self = [super init];
-
-    if( self != nil )
+    for( int i = 0; i < [[self children] count]; i++ )
     {
-        o_name = [o_item_name copy];
-        i_object_id = i_id;
-        o_parent = o_parent_item;
+        VLCTreeCategoryItem * categoryItem = [[self children] objectAtIndex:i];
+        if( [categoryItem category] == category )
+            return categoryItem;
     }
-    return( self );
-}
-
-+ (VLCTreeItem *)rootItem {
-   if (o_root_item == nil) o_root_item = [[VLCTreeItem alloc] initWithName:@"main" ID: 0 parent:nil];
-   return o_root_item;       
+    return nil;
 }
 
 - (void)dealloc
 {
-    if (o_children != IsALeafNode) [o_children release];
-    [o_name release];
+    module_config_free( _configItems );
     [super dealloc];
 }
 
 /* Creates and returns the array of children
  * Loads children incrementally */
-- (NSArray *)children
+- (NSMutableArray *)children
 {
-    if( o_children == NULL )
+    if( _children ) return _children;
+    _children = [[NSMutableArray alloc] init];
+
+    intf_thread_t   *p_intf = VLCIntf;
+
+    /* List the modules */
+    size_t count, i;
+    module_t ** modules = module_list_get( &count );
+    if( !modules ) return nil;
+
+    /* Build a tree of the plugins */
+    /* Add the capabilities */
+    for( i = 0; i < count; i++ )
     {
-        intf_thread_t *p_intf = VLCIntf;
-        vlc_list_t      *p_list;
-        module_t        *p_module = NULL;
-        module_config_t *p_item;
-        int i_index,j;
+        module_t * p_module = modules[i];
+
+        /* Exclude empty plugins (submodules don't have config */
+        /* options, they are stored in the parent module) */
+        unsigned int confsize;
+        _configItems = module_config_get( p_module, &confsize );
 
-        /* List the modules */
-        p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
-        if( !p_list ) return nil;
+        VLCTreeCategoryItem * categoryItem = nil;
+        VLCTreeSubCategoryItem * subCategoryItem = nil;
 
-        if( [[self getName] isEqualToString: @"main"] )
+        unsigned int j;
+        for( j = 0; j < confsize; j++ )
         {
-            /*
-            * Find the main module
-            */
-            for( i_index = 0; i_index < p_list->i_count; i_index++ )
-            {
-                p_module = (module_t *)p_list->p_values[i_index].p_object;
-                if( !strcmp( p_module->psz_object_name, "main" ) )
-                    break;
-            }
-            if( p_module == NULL )
+            int configType = _configItems[j].i_type;
+            if( configType == CONFIG_CATEGORY )
             {
-                msg_Err( p_intf, "could not find the main module in our preferences" );
-                return nil;
-            }
-            if( i_index < p_list->i_count )
-            {
-                /* We found the main module */
-        
-                /* Enumerate config categories and store a reference so we can
-                 * generate their config panel them when it is asked by the user. */
-                p_item = p_module->p_config;
-                o_children = [[NSMutableArray alloc] initWithCapacity:10];
-
-                if( p_item ) do
+                categoryItem = [self itemRepresentingCategory:_configItems[j].value.i];
+                if(!categoryItem)
                 {
-                    NSString *o_child_name;
-                    
-                    switch( p_item->i_type )
-                    {
-                    case CONFIG_HINT_CATEGORY:
-                        o_child_name = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
-                        [o_children addObject:[[VLCTreeItem alloc] initWithName: o_child_name
-                            ID: p_module->i_object_id parent:self]];
-                        break;
-                    }
+                    categoryItem = [VLCTreeCategoryItem categoryTreeItemWithCategory:_configItems[j].value.i];
+                    if(categoryItem) [[self children] addObject:categoryItem];
                 }
-                while( p_item->i_type != CONFIG_HINT_END && p_item++ );
-                
-                /* Add the modules item */
-                [o_children addObject:[[VLCTreeItem alloc] initWithName: _NS("Modules")
-                    ID: 0 parent:self]];
-            }
-            else
-            {
-                o_children = IsALeafNode;
             }
-        }
-        else if( [[self getName] isEqualToString: _NS("Modules")] )
-        {
-            /* Add the capabilities */
-            o_children = [[NSMutableArray alloc] initWithCapacity:10];
-            for( i_index = 0; i_index < p_list->i_count; i_index++ )
+            else if( configType == CONFIG_SUBCATEGORY && categoryItem )
             {
-                p_module = (module_t *)p_list->p_values[i_index].p_object;
-        
-                /* Exclude the main module */
-                if( !strcmp( p_module->psz_object_name, "main" ) )
-                    continue;
-        
-                /* Exclude empty modules */
-                p_item = p_module->p_config;
-                if( !p_item ) continue;
-                do
-                {
-                    if( p_item->i_type & CONFIG_ITEM )
-                        break;
-                }
-                while( p_item->i_type != CONFIG_HINT_END && p_item++ );
-                if( p_item->i_type == CONFIG_HINT_END ) continue;
-        
-                /* Create the capability tree if it doesn't already exist */
-                NSString *o_capability;
-                o_capability = [[VLCMain sharedInstance] localizedString: p_module->psz_capability];
-                if( !p_module->psz_capability || !*p_module->psz_capability )
-                {
-                    /* Empty capability ? Let's look at the submodules */
-                    module_t * p_submodule;
-                    for( j = 0; j < p_module->i_children; j++ )
-                    {
-                        p_submodule = (module_t*)p_module->pp_children[ j ];
-                        if( p_submodule->psz_capability && *p_submodule->psz_capability )
-                        {
-                            o_capability = [[VLCMain sharedInstance] localizedString: p_submodule->psz_capability];
-                            BOOL b_found = FALSE;
-                            for( j = 0; j < (int)[o_children count]; j++ )
-                            {
-                                if( [[[o_children objectAtIndex:j] getName] isEqualToString: o_capability] )
-                                {
-                                    b_found = TRUE;
-                                    break;
-                                }
-                            }
-                            if( !b_found )
-                            {
-                                [o_children addObject:[[VLCTreeItem alloc] initWithName: o_capability
-                                ID: 0 parent:self]];
-                            }
-                        }
-                    }
-                }
-
-                BOOL b_found = FALSE;
-                for( j = 0; j < (int)[o_children count]; j++ )
-                {
-                    if( [[[o_children objectAtIndex:j] getName] isEqualToString: o_capability] )
-                    {
-                        b_found = TRUE;
-                        break;
-                    }
-                }
-                if( !b_found )
+                subCategoryItem = [categoryItem itemRepresentingSubCategory:_configItems[j].value.i];
+                if(!subCategoryItem)
                 {
-                    [o_children addObject:[[VLCTreeItem alloc] initWithName: o_capability
-                    ID: 0 parent:self]];
+                    subCategoryItem = [VLCTreeSubCategoryItem subCategoryTreeItemWithSubCategory:_configItems[j].value.i];
+                    if(subCategoryItem) [[categoryItem children] addObject:subCategoryItem];
                 }
             }
-        }
-        else if( [[o_parent getName] isEqualToString: _NS("Modules")] )
-        {
-            /* Now add the modules */
-            o_children = [[NSMutableArray alloc] initWithCapacity:10];
-            for( i_index = 0; i_index < p_list->i_count; i_index++ )
+            else if( (configType & CONFIG_ITEM) && subCategoryItem )
             {
-                p_module = (module_t *)p_list->p_values[i_index].p_object;
-        
-                /* Exclude the main module */
-                if( !strcmp( p_module->psz_object_name, "main" ) )
-                    continue;
-        
-                /* Exclude empty modules */
-                p_item = p_module->p_config;
-                if( !p_item ) continue;
-                do
-                {
-                    if( p_item->i_type & CONFIG_ITEM )
-                        break;
-                }
-                while( p_item->i_type != CONFIG_HINT_END && p_item++ );
-                if( p_item->i_type == CONFIG_HINT_END ) continue;
-        
-                /* Check the capability */
-                NSString *o_capability;
-                o_capability = [[VLCMain sharedInstance] localizedString: p_module->psz_capability];
-                if( !p_module->psz_capability || !*p_module->psz_capability )
-                {
-                    /* Empty capability ? Let's look at the submodules */
-                    module_t * p_submodule;
-                    for( j = 0; j < p_module->i_children; j++ )
-                    {
-                        p_submodule = (module_t*)p_module->pp_children[ j ];
-                        if( p_submodule->psz_capability && *p_submodule->psz_capability )
-                        {
-                            o_capability = [[VLCMain sharedInstance] localizedString: p_submodule->psz_capability];
-                            if( [o_capability isEqualToString: [self getName]] )
-                            {
-                            [o_children addObject:[[VLCTreeItem alloc] initWithName:
-                                [[VLCMain sharedInstance] localizedString: p_module->psz_object_name ]
-                                ID: p_module->i_object_id parent:self]];
-                            }
-                        }
-                    }
-                }
-                else if( [o_capability isEqualToString: [self getName]] )
-                {
-                    [o_children addObject:[[VLCTreeItem alloc] initWithName:
-                        [[VLCMain sharedInstance] localizedString: p_module->psz_object_name ]
-                        ID: p_module->i_object_id parent:self]];
-                }
+                [[subCategoryItem children] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
             }
+
         }
-        else
-        {
-            /* all the other stuff are leafs */
-            o_children = IsALeafNode;
-        }
-        vlc_list_release( p_list );
     }
-    return o_children;
+    module_list_free( modules );
+    return _children;
+}
+@end
+
+#pragma mark -
+@implementation VLCTreeCategoryItem
++ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category
+{
+    return [[[[self class] alloc] initWithCategory:category] autorelease];
+}
+- (id)initWithCategory:(int)category
+{
+    if(!config_CategoryNameGet( category )) return nil;
+    NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( category )];
+    if(self = [super initWithName:name andConfigItem:nil])
+    {
+        _category = category;
+        //_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( category )] retain];
+    }
+    return self;
+}
+
+- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)subCategory
+{
+    assert( [self isKindOfClass:[VLCTreeCategoryItem class]] );
+    for( int i = 0; i < [[self children] count]; i++ )
+    {
+        VLCTreeSubCategoryItem * subCategoryItem = [[self children] objectAtIndex:i];
+        if( [subCategoryItem subCategory] == subCategory )
+            return subCategoryItem;
+    }
+    return nil;
+}
+
+- (int)category
+{
+    return _category;
+}
+@end
+
+#pragma mark -
+@implementation VLCTreeSubCategoryItem
+- (id)initWithSubCategory:(int)subCategory
+{
+    if(!config_CategoryNameGet( subCategory )) return nil;
+    NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( subCategory )];
+    if(self = [super initWithName:name andConfigItem:NULL])
+    {
+        _subCategory = subCategory;
+        //_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
+    }
+    return self;
+}
+
++ (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)subCategory
+{
+    return [[[[self class] alloc] initWithSubCategory:subCategory] autorelease];
+}
+
+- (int)subCategory
+{
+    return _subCategory;
+}
+
+@end
+
+#pragma mark -
+@implementation VLCTreeLeafItem
+@end
+
+#pragma mark -
+#pragma mark (Root class for all TreeItems)
+@implementation VLCTreeItem
+
+- (id)initWithConfigItem: (module_config_t *) configItem
+{
+    NSString * name = [[VLCMain sharedInstance] localizedString:configItem->psz_name];
+    return [self initWithName:name andConfigItem:configItem];
 }
 
-- (int)getObjectID
+- (id)initWithName:(NSString*)name andConfigItem:(module_config_t *)configItem
 {
-    return i_object_id;
+    self = [super init];
+    if( self != nil )
+    {
+        _name = [name retain];
+        _configItem = configItem;
+    }
+    return self;
 }
 
-- (NSString *)getName
+- (void)dealloc
 {
-    return o_name;
+    [_children release];
+    [_name release];
+    [_subviews release];
+    [super dealloc];
 }
 
-- (VLCTreeItem *)childAtIndex:(int)i_index {
+- (VLCTreeItem *)childAtIndex:(int)i_index
+{
     return [[self children] objectAtIndex:i_index];
 }
 
-- (int)numberOfChildren {
-    id i_tmp = [self children];
-    return (i_tmp == IsALeafNode) ? (-1) : (int)[i_tmp count];
+- (int)numberOfChildren
+{
+    return [[self children] count];
 }
 
-- (BOOL)hasPrefs:(NSString *)o_module_name
+- (NSString *)name
 {
-    intf_thread_t *p_intf = VLCIntf;
-    module_t *p_parser;
-    vlc_list_t *p_list;
-    char *psz_module_name;
-    int i_index;
+    return [[_name retain] autorelease];
+}
 
-    psz_module_name = (char *)[o_module_name UTF8String];
+- (void)showView:(NSScrollView *)prefsView
+{
+    NSRect          s_vrc;
+    NSView          *view;
 
-    /* look for module */
-    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+    [[VLCPrefs sharedInstance] setTitle: [self name]];
+    s_vrc = [[prefsView contentView] bounds]; s_vrc.size.height -= 4;
+    view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
+    [view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin | NSViewMaxYMargin];
 
-    for( i_index = 0; i_index < p_list->i_count; i_index++ )
+    if(!_subviews)
     {
-        p_parser = (module_t *)p_list->p_values[i_index].p_object ;
+        _subviews = [[NSMutableArray alloc] initWithCapacity:10];
 
-        if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
+        long i;
+        for( i = 0; i < [[self children] count]; i++)
         {
-            BOOL b_has_prefs = p_parser->i_config_items != 0;
-            vlc_list_release( p_list );
-            return( b_has_prefs );
+            VLCTreeItem * item = [[self children] objectAtIndex:i];
+            if(![item isKindOfClass:[VLCTreeLeafItem class]]) continue;
+
+            VLCConfigControl *control;
+            control = [VLCConfigControl newControl:[item configItem] withView:view];
+            if( control )
+            {
+                [control setAutoresizingMask: NSViewMaxYMargin | NSViewWidthSizable];
+                [_subviews addObject: control];
+            }
         }
     }
 
-    vlc_list_release( p_list );
+    assert(view);
+    
+    int i_lastItem = 0;
+    int i_yPos = -2;
+    int i_max_label = 0;
+
+    NSEnumerator *enumerator = [_subviews objectEnumerator];
+    VLCConfigControl *widget;
+    NSRect frame;
+
+    while( ( widget = [enumerator nextObject] ) )
+        if( i_max_label < [widget labelSize] )
+            i_max_label = [widget labelSize];
+
+    enumerator = [_subviews objectEnumerator];
+    while( ( widget = [enumerator nextObject] ) )
+    {
+        int i_widget;
+
+        i_widget = [widget viewType];
+        i_yPos += [VLCConfigControl calcVerticalMargin:i_widget lastItem:i_lastItem];
+        [widget setYPos:i_yPos];
+        frame = [widget frame];
+        frame.size.width = [view frame].size.width - LEFTMARGIN - RIGHTMARGIN;
+        [widget setFrame:frame];
+        [widget alignWithXPosition: i_max_label];
+        i_yPos += [widget frame].size.height;
+        i_lastItem = i_widget;
+        [view addSubview:widget];
+    }
+
+    frame = [view frame];
+    frame.size.height = i_yPos;
+    [view setFrame:frame];
+    [prefsView setDocumentView:view];
+}
+
+- (void)applyChanges
+{
+    unsigned int i;
+    for( i = 0 ; i < [_subviews count] ; i++ )
+        [[_subviews objectAtIndex:i] applyChanges];
 
-    return( NO );
+    for( i = 0 ; i < [_children count] ; i++ )
+        [[_children objectAtIndex:i] applyChanges];
 }
 
-@end
+- (void)resetView
+{
+    [_subviews release];
+    _subviews = nil;
+
+    unsigned int i;
+    for( i = 0 ; i < [_children count] ; i++ )
+        [[_children objectAtIndex:i] resetView];
+}
 
+- (NSMutableArray *)children
+{
+    if(!_children) _children = [[NSMutableArray alloc] init];
+    return _children;
+}
+
+- (module_config_t *)configItem
+{
+    return _configItem;
+}
+@end
 
+#pragma mark -
 @implementation VLCFlippedView
 
 - (BOOL)isFlipped