Commit 29e178eb authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

macosx prefs: Repair the preferences view for Mac OS X.

Seperate config options from the configtree. VLCTreeItem and VLCTreeLeafItem
are now used for CONFIG_ITEM in an options collection. It now works, but
probably should be cleanup up a bit more, with better seperation between the
disjunct elements of Tree and ConfigItems.

This was broken since [09e31e1436ef3e670bd7497688272dd073c8d3a6]
(cherry picked from commit 1e7e2ae9)
parent bef9bb0b
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
{ {
NSString *_name; NSString *_name;
NSMutableArray *_children; NSMutableArray *_children;
NSMutableArray *_options;
NSMutableArray *_subviews; NSMutableArray *_subviews;
module_config_t * _configItem; module_config_t * _configItem;
} }
...@@ -78,21 +79,32 @@ ...@@ -78,21 +79,32 @@
- (NSString *)name; - (NSString *)name;
- (NSMutableArray *)children; - (NSMutableArray *)children;
- (NSMutableArray *)options;
- (void)showView:(NSScrollView *)o_prefs_view; - (void)showView:(NSScrollView *)o_prefs_view;
- (void)applyChanges; - (void)applyChanges;
- (void)resetView; - (void)resetView;
@end @end
/* CONFIG_SUBCAT */
@interface VLCTreeSubCategoryItem : VLCTreeItem @interface VLCTreeSubCategoryItem : VLCTreeItem
{ {
int _subCategory; int _subCategory;
} }
+ (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)category; + (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)subCategory;
- (id)initWithSubCategory:(int)subCategory; - (id)initWithSubCategory:(int)subCategory;
- (int)subCategory; - (int)subCategory;
@end @end
/* Plugin daughters */
@interface VLCTreePluginItem : VLCTreeItem
{
}
+ (VLCTreePluginItem *)pluginTreeItemWithPlugin:(module_t *)plugin;
- (id)initWithPlugin:(module_t *)plugin;
@end
/* CONFIG_CAT */
@interface VLCTreeCategoryItem : VLCTreeItem @interface VLCTreeCategoryItem : VLCTreeItem
{ {
int _category; int _category;
...@@ -103,7 +115,7 @@ ...@@ -103,7 +115,7 @@
- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)category; - (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)category;
@end @end
/* individual options. */
@interface VLCTreeLeafItem : VLCTreeItem @interface VLCTreeLeafItem : VLCTreeItem
{ } { }
@end @end
...@@ -256,7 +268,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -256,7 +268,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{ {
return ![item isKindOfClass:[VLCTreeSubCategoryItem class]]; return (item == nil) ? [_rootTreeItem numberOfChildren] : [item numberOfChildren];
} }
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
...@@ -292,6 +304,21 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -292,6 +304,21 @@ static VLCPrefs *_o_sharedMainInstance = nil;
[super dealloc]; [super dealloc];
} }
- (bool)isSubCategoryGeneral:(int)category
{
if(category == SUBCAT_VIDEO_GENERAL ||
category == SUBCAT_ADVANCED_MISC ||
category == SUBCAT_INPUT_GENERAL ||
category == SUBCAT_INTERFACE_GENERAL ||
category == SUBCAT_SOUT_GENERAL||
category == SUBCAT_PLAYLIST_GENERAL||
category == SUBCAT_AUDIO_GENERAL )
{
return true;
}
return false;
}
/* Creates and returns the array of children /* Creates and returns the array of children
* Loads children incrementally */ * Loads children incrementally */
- (NSMutableArray *)children - (NSMutableArray *)children
...@@ -319,6 +346,8 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -319,6 +346,8 @@ static VLCPrefs *_o_sharedMainInstance = nil;
VLCTreeCategoryItem * categoryItem = nil; VLCTreeCategoryItem * categoryItem = nil;
VLCTreeSubCategoryItem * subCategoryItem = nil; VLCTreeSubCategoryItem * subCategoryItem = nil;
VLCTreePluginItem * pluginItem = nil;
int lastsubcat = 0;
unsigned int j; unsigned int j;
for( j = 0; j < confsize; j++ ) for( j = 0; j < confsize; j++ )
...@@ -333,20 +362,41 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -333,20 +362,41 @@ static VLCPrefs *_o_sharedMainInstance = nil;
if(categoryItem) [[self children] addObject:categoryItem]; if(categoryItem) [[self children] addObject:categoryItem];
} }
} }
else if( configType == CONFIG_SUBCATEGORY && categoryItem ) else if( configType == CONFIG_SUBCATEGORY )
{ {
subCategoryItem = [categoryItem itemRepresentingSubCategory:_configItems[j].value.i]; lastsubcat = _configItems[j].value.i;
if(!subCategoryItem) if( categoryItem && ![self isSubCategoryGeneral:lastsubcat] )
{ {
subCategoryItem = [VLCTreeSubCategoryItem subCategoryTreeItemWithSubCategory:_configItems[j].value.i]; subCategoryItem = [categoryItem itemRepresentingSubCategory:lastsubcat];
if(subCategoryItem) [[categoryItem children] addObject:subCategoryItem]; if(!subCategoryItem)
{
subCategoryItem = [VLCTreeSubCategoryItem subCategoryTreeItemWithSubCategory:lastsubcat];
if(subCategoryItem) [[categoryItem children] addObject:subCategoryItem];
}
} }
} }
else if( (configType & CONFIG_ITEM) && subCategoryItem )
if( module_is_main( p_module) && (configType & CONFIG_ITEM) )
{ {
[[subCategoryItem children] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]]; if( categoryItem && [self isSubCategoryGeneral:lastsubcat] )
{
[[categoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
}
else if( subCategoryItem )
{
[[subCategoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
}
}
else if( !module_is_main( p_module) && (configType & CONFIG_ITEM))
{
if( !pluginItem )
{
pluginItem = [VLCTreePluginItem pluginTreeItemWithPlugin: p_module];
if(pluginItem) [[subCategoryItem children] addObject:pluginItem];
}
if( pluginItem )
[[pluginItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
} }
} }
} }
module_list_free( modules ); module_list_free( modules );
...@@ -416,6 +466,26 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -416,6 +466,26 @@ static VLCPrefs *_o_sharedMainInstance = nil;
@end @end
#pragma mark -
@implementation VLCTreePluginItem
- (id)initWithPlugin:(module_t *)plugin
{
NSString * name = [[VLCMain sharedInstance] localizedString: module_get_name( plugin, false )];
if(self = [super initWithName:name andConfigItem:NULL])
{
//_plugin = plugin;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
}
return self;
}
+ (VLCTreePluginItem *)pluginTreeItemWithPlugin:(module_t *)plugin
{
return [[[[self class] alloc] initWithPlugin:plugin] autorelease];
}
@end
#pragma mark - #pragma mark -
@implementation VLCTreeLeafItem @implementation VLCTreeLeafItem
@end @end
...@@ -444,6 +514,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -444,6 +514,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (void)dealloc - (void)dealloc
{ {
[_children release]; [_children release];
[_options release];
[_name release]; [_name release];
[_subviews release]; [_subviews release];
[super dealloc]; [super dealloc];
...@@ -479,10 +550,9 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -479,10 +550,9 @@ static VLCPrefs *_o_sharedMainInstance = nil;
_subviews = [[NSMutableArray alloc] initWithCapacity:10]; _subviews = [[NSMutableArray alloc] initWithCapacity:10];
long i; long i;
for( i = 0; i < [[self children] count]; i++) for( i = 0; i < [[self options] count]; i++)
{ {
VLCTreeItem * item = [[self children] objectAtIndex:i]; VLCTreeItem * item = [[self options] objectAtIndex:i];
if(![item isKindOfClass:[VLCTreeLeafItem class]]) continue;
VLCConfigControl *control; VLCConfigControl *control;
control = [VLCConfigControl newControl:[item configItem] withView:view]; control = [VLCConfigControl newControl:[item configItem] withView:view];
...@@ -557,6 +627,12 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -557,6 +627,12 @@ static VLCPrefs *_o_sharedMainInstance = nil;
return _children; return _children;
} }
- (NSMutableArray *)options
{
if(!_options) _options = [[NSMutableArray alloc] init];
return _options;
}
- (module_config_t *)configItem - (module_config_t *)configItem
{ {
return _configItem; return _configItem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment