Better support for opening files.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2009-11-16 11:47:06 -08:00
parent aa8689a4f0
commit 6829d502d7
2 changed files with 19 additions and 12 deletions
+17 -11
View File
@@ -275,15 +275,15 @@ CPRunContinuesResponse = -1002;
postNotificationName:CPApplicationWillFinishLaunchingNotification
object:self];
var filename = window.cpOpeningFilename && window.cpOpeningFilename(),
needsUntitled = !!_documentController;
var needsUntitled = !!_documentController,
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(),
index = 0,
count = [URLStrings count];
if ([filename length])
{
needsUntitled = ![self _openFile:filename];
}
for (; index < count; ++index)
needsUntitled = ![self _openURL:[CPURL URLWithString:URLStrings[index]]] || needsUntitled;
if (needsUntitled && [_delegate respondsToSelector: @selector(applicationShouldOpenUntitledFile:)])
if (needsUntitled && [_delegate respondsToSelector:@selector(applicationShouldOpenUntitledFile:)])
needsUntitled = [_delegate applicationShouldOpenUntitledFile:self];
if (needsUntitled)
@@ -834,12 +834,18 @@ CPRunContinuesResponse = -1002;
return _namedArgs;
}
- (BOOL)_openFile:(CPString)aFilename
- (BOOL)_openURL:(CPURL)aURL
{
if (_delegate && [_delegate respondsToSelector:@selector(application:openFile:)])
return [_delegate application:self openFile:aFilename];
else
return [_documentController openDocumentWithContentsOfURL:aFilename display:YES error:NULL];
{
CPLog.warn("application:openFile: is deprecated, use application:openURL: instead.");
return [_delegate application:self openFile:[aURL absoluteString]];
}
if (_delegate && [_delegate respondsToSelector:@selector(application:openURL:)])
return [_delegate application:self openURL:aURL];
return [_documentController openDocumentWithContentsOfURL:aURL display:YES error:NULL];
}
- (void)_didResignActive
+2 -1
View File
@@ -146,6 +146,8 @@ var CPSharedDocumentController = nil;
result = [self makeDocumentWithContentsOfURL:anAbsoluteURL ofType:type delegate:self didReadSelector:@selector(document:didRead:contextInfo:) contextInfo:[CPDictionary dictionaryWithObject:shouldDisplay forKey:@"shouldDisplay"]];
[self addDocument:result];
if (result)
[self noteNewRecentDocument:result];
}
@@ -207,7 +209,6 @@ var CPSharedDocumentController = nil;
if (!didRead)
return;
[self addDocument:aDocument];
[aDocument makeWindowControllers];
if ([aContextInfo objectForKey:@"shouldDisplay"])