Open default path from applicationDidFinishLaunching

This is called after openFiles and so the default path
will open be opened if other explicit files were not
opened such as by dropping onto the dock icon
This commit is contained in:
Kevin Sawicki
2012-12-19 11:22:58 -08:00
parent 17976a19b5
commit ea088db19d
2 changed files with 33 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ class AtomCefClient;
@interface AtomApplication : NSApplication <CefAppProtocol, NSApplicationDelegate> {
NSWindowController *_backgroundWindowController;
NSDictionary *_arguments;
BOOL _filesOpened;
BOOL handlingSendEvent_;
}
@@ -22,4 +23,4 @@ class AtomCefClient;
@property (nonatomic, retain) NSDictionary *arguments;
@end
@end

View File

@@ -174,24 +174,31 @@
# pragma mark NSApplicationDelegate
- (BOOL)shouldOpenFiles {
if ([self.arguments objectForKey:@"benchmark"]) {
return NO;
}
if ([self.arguments objectForKey:@"test"]) {
return NO;
}
return YES;
}
- (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];
if ([self shouldOpenFiles]) {
for (int i = 0; i < [filenames count]; i++) {
NSString *path = [filenames objectAtIndex:i];
path = [[self class] standardizePathToOpen:path withArguments:self.arguments];
[self open:path];
}
if ([filenames count] > 0) {
_filesOpened = YES;
}
}
}
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
_backgroundWindowController = [[AtomWindowController alloc] initInBackground];
if ([self.arguments objectForKey:@"benchmark"]) {
[self runBenchmarksThenExit:true];
}
else if ([self.arguments objectForKey:@"test"]) {
[self runSpecsThenExit:true];
}
else {
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
if (!_filesOpened && [self shouldOpenFiles]) {
NSString *path = [self.arguments objectForKey:@"path"];
// Just a hack to open the Atom src by default when we run from xcode
@@ -203,6 +210,16 @@
}
}
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
_backgroundWindowController = [[AtomWindowController alloc] initInBackground];
if ([self.arguments objectForKey:@"benchmark"]) {
[self runBenchmarksThenExit:true];
}
else if ([self.arguments objectForKey:@"test"]) {
[self runSpecsThenExit:true];
}
}
- (void)applicationWillTerminate:(NSNotification *)notification {
for (NSWindow *window in [self windows]) {
[window performClose:self];