2009-03-08 01:49:50 +00:00
|
|
|
//
|
|
|
|
// PreferencePluginController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 3/7/09.
|
|
|
|
// Copyright 2009 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "PreferencePluginController.h"
|
|
|
|
#import "PreferencePanePlugin.h"
|
|
|
|
|
|
|
|
@implementation PreferencePluginController
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (id)initWithPlugins:(NSArray *)plugins {
|
2009-03-08 01:49:50 +00:00
|
|
|
self = [super init];
|
2022-02-07 05:49:27 +00:00
|
|
|
if(self) {
|
2016-05-05 20:05:39 +00:00
|
|
|
_plugins = plugins;
|
2009-03-08 01:49:50 +00:00
|
|
|
_preferencePanes = [[NSMutableArray alloc] init];
|
|
|
|
}
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2009-03-08 01:49:50 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)_searchForPlugins {
|
|
|
|
for(NSBundle *plugin in _plugins) {
|
2009-03-08 01:49:50 +00:00
|
|
|
[plugin load];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2009-03-08 01:49:50 +00:00
|
|
|
Class principalClass = [plugin principalClass];
|
2022-02-07 05:49:27 +00:00
|
|
|
if([principalClass conformsToProtocol:@protocol(PreferencePanePlugin)]) {
|
2009-03-08 01:49:50 +00:00
|
|
|
NSArray *panes = [principalClass preferencePanes];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2009-03-08 01:49:50 +00:00
|
|
|
[_preferencePanes addObjectsFromArray:panes];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (NSArray *)preferencePanes {
|
2009-03-08 01:49:50 +00:00
|
|
|
[self _searchForPlugins];
|
|
|
|
|
|
|
|
return _preferencePanes;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|