Open a new document when a document based application is launched if

the delegate responds YES to applicationShouldOpenUntitledFile: but
does not implement applicationOpenUntitledFile:.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31506 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-10-13 13:36:44 +00:00
parent e51e064411
commit 4e19857788
2 changed files with 31 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2010-10-13 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSApplication.m (-finishLaunching): Open a new document
in a document based application when the delegate responds YES to
applicationShouldOpenUntitledFile: but does not implement
applicationOpenUntitledFile:.
2010-10-08 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSWindowController.m (-window): Send

View file

@ -1134,24 +1134,34 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
}
else if (!didAutoreopen && ![defs boolForKey: @"autolaunch"])
{
// For document based applications we automatically open a fresh document
// unless denied by the delegate. For non-document based applications we
// open a fresh document only when requested by the delegate.
// Note: We consider an application document based if the shared document
// controller reports at least one editable type.
BOOL docBased =
[[sdc documentClassNames] count] > 0 && [sdc defaultType] != nil;
BOOL shouldOpen = docBased ? YES : NO;
if ([_delegate respondsToSelector:
@selector(applicationShouldOpenUntitledFile:)])
{
if ([_delegate applicationShouldOpenUntitledFile: self]
&& [_delegate respondsToSelector:
@selector(applicationOpenUntitledFile:)])
{
[_delegate applicationOpenUntitledFile: self];
}
}
else if ([[sdc documentClassNames] count] > 0 && [sdc defaultType] != nil)
{
NSError *err = nil;
if ([sdc openUntitledDocumentAndDisplay: YES error: &err] == nil
&& [sdc presentError: err] == NO)
shouldOpen = [_delegate applicationShouldOpenUntitledFile: self];
}
if (shouldOpen)
{
if (docBased)
{
[self terminate: self];
NSError *err = nil;
if ([sdc openUntitledDocumentAndDisplay: YES error: &err] == nil)
{
[sdc presentError: err];
}
}
else if ([_delegate respondsToSelector:
@selector(applicationOpenUntitledFile:)])
{
[_delegate applicationOpenUntitledFile: self];
}
}
}