Open folders and plain text files dropped dock icon

Closes #103
This commit is contained in:
Kevin Sawicki
2012-12-19 10:58:28 -08:00
parent 35f362df1d
commit d674aa6a39
2 changed files with 29 additions and 0 deletions

View File

@@ -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];

View File

@@ -20,6 +20,16 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>public.folder</string>
<string>public.plain-text</string>
</array>
</dict>
</array>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>