mirror of
https://github.com/MacPass/MacPass.git
synced 2026-01-31 05:58:24 +00:00
Added simple support for import Plugins via plugin API
This commit is contained in:
@@ -249,8 +249,11 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) {
|
|||||||
for(MPPlugin<MPImportPlugin> * plugin in MPPluginHost.sharedHost.importPlugins) {
|
for(MPPlugin<MPImportPlugin> * plugin in MPPluginHost.sharedHost.importPlugins) {
|
||||||
NSMenuItem *importItem = [[NSMenuItem alloc] init];
|
NSMenuItem *importItem = [[NSMenuItem alloc] init];
|
||||||
[plugin prepareImportMenuItem:importItem];
|
[plugin prepareImportMenuItem:importItem];
|
||||||
|
importItem.submenu = nil; // kill any potential submenu!
|
||||||
|
importItem.representedObject = plugin.identifier;
|
||||||
importItem.target = nil;
|
importItem.target = nil;
|
||||||
importItem.action = @selector(importFromPlugin:);
|
importItem.action = @selector(importFromPlugin:);
|
||||||
|
[menu addItem:importItem];
|
||||||
}
|
}
|
||||||
[menu insertItem:exportXML atIndex:0];
|
[menu insertItem:exportXML atIndex:0];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSMenuItem *menuItem = sender;
|
NSMenuItem *menuItem = sender;
|
||||||
if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) {
|
if(![menuItem.representedObject isKindOfClass:NSString.class]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
if(!sheetWindow) {
|
if(!sheetWindow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MPPlugin<MPImportPlugin> *importPlugin;
|
NSString *bundleIdentifier = menuItem.representedObject;
|
||||||
|
MPPlugin<MPImportPlugin> *importPlugin = (MPPlugin<MPImportPlugin> *)[MPPluginHost.sharedHost pluginWithBundleIdentifier:bundleIdentifier];
|
||||||
NSOpenPanel *openPanel = NSOpenPanel.openPanel;
|
NSOpenPanel *openPanel = NSOpenPanel.openPanel;
|
||||||
[importPlugin prepareOpenPanel:openPanel];
|
[importPlugin prepareOpenPanel:openPanel];
|
||||||
[openPanel beginSheetModalForWindow:sheetWindow completionHandler:^(NSModalResponse result) {
|
[openPanel beginSheetModalForWindow:sheetWindow completionHandler:^(NSModalResponse result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user