From d674aa6a39b831bc8f1fa3fb9f03dceb9f3a032a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 19 Dec 2012 10:58:28 -0800 Subject: [PATCH] Open folders and plain text files dropped dock icon Closes #103 --- native/atom_application.mm | 19 +++++++++++++++++++ native/mac/info.plist | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/native/atom_application.mm b/native/atom_application.mm index 769dbdbc2..fb7b09150 100644 --- a/native/atom_application.mm +++ b/native/atom_application.mm @@ -81,6 +81,7 @@ if (cleanArgc > 0) { NSString *path = [NSString stringWithUTF8String:cleanArgv[0]]; + path = [self standardizePathToOpen:path withArguments:arguments]; NSString *executedFromPath =[arguments objectForKey:@"executed-from"]; if (![path isAbsolutePath] && executedFromPath) { path = [executedFromPath stringByAppendingPathComponent:path]; @@ -93,6 +94,16 @@ return arguments; } ++ (NSString *)standardizePathToOpen:(NSString *)path withArguments:(NSDictionary *)arguments { + NSString *standardizedPath = path; + NSString *executedFromPath = [arguments objectForKey:@"executed-from"]; + if (![standardizedPath isAbsolutePath] && executedFromPath) { + standardizedPath = [executedFromPath stringByAppendingPathComponent:standardizedPath]; + } + standardizedPath = [standardizedPath stringByStandardizingPath]; + return standardizedPath; +} + + (NSString *)supportDirectory { NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *executableName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"]; @@ -166,6 +177,14 @@ # pragma mark NSApplicationDelegate +- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { + for (int i = 0; i < [filenames count]; i++) { + NSString *path = [filenames objectAtIndex:i]; + path = [[self class] standardizePathToOpen:path withArguments:self.arguments]; + [self open:path]; + } +} + - (void)applicationWillFinishLaunching:(NSNotification *)notification { _backgroundWindowController = [[AtomWindowController alloc] initInBackground]; diff --git a/native/mac/info.plist b/native/mac/info.plist index 9dd8973e8..d168799f2 100644 --- a/native/mac/info.plist +++ b/native/mac/info.plist @@ -20,6 +20,16 @@ ???? CFBundleVersion 1.0 + CFBundleDocumentTypes + + + LSItemContentTypes + + public.folder + public.plain-text + + + NSMainNibFile MainMenu NSPrincipalClass