Handle openFile and openURL - also don't start with a window open.

This commit is contained in:
Marco Cawthorne 2022-09-17 14:43:53 -07:00
parent c7a7f46b34
commit 4b4bf6efc3
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 45 additions and 1 deletions

View File

@ -132,7 +132,7 @@ static NSMenuItem *menuItemForItem(id item) {
object: nil];
[self bookmarksUpdated: nil];
[self historyUpdated: nil];
[self didTapNewWindow: nil];
//[self didTapNewWindow: nil];
}
-(void)didTapNewWindow: (id)sender {
@ -298,6 +298,50 @@ static NSMenuItem *menuItemForItem(id item) {
}
}
- (BOOL) application: (NSApplication *)application
openFile: (NSString *)fileName
{
NSArray *args;
NSString *path;
NSTask *task;
[self openDeveloperFileAtPath: fileName];
return YES;
}
- (void) openURL: (NSPasteboard*)pb
userData: (NSString*)ud
error: (NSString**)err
{
NSString *url;
NSArray *types;
NSArray *args;
NSString *path;
NSTask *task;
NSString *pboardString;
*err = nil;
types = [pb types];
if (![types containsObject:NSStringPboardType] || !(pboardString = [pb stringForType:NSStringPboardType]))
{
*err = NSLocalizedString(@"Error: Pasteboard doesn't contain a string.",
@"Pasteboard couldn't give string.");
return;
}
url = [pb stringForType: NSStringPboardType];
if (url == nil)
{
*err = @"No string value supplied on pasteboard";
return;
}
[self openDeveloperFileAtPath: url];
return;
}
@end
int main(int argc, char **argv) {