mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:50:48 +00:00
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:
parent
15c24d53a9
commit
6ae4c9b25f
2 changed files with 31 additions and 14 deletions
|
@ -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>
|
2010-10-08 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
* Source/NSWindowController.m (-window): Send
|
* Source/NSWindowController.m (-window): Send
|
||||||
|
|
|
@ -1134,24 +1134,34 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
||||||
}
|
}
|
||||||
else if (!didAutoreopen && ![defs boolForKey: @"autolaunch"])
|
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:
|
if ([_delegate respondsToSelector:
|
||||||
@selector(applicationShouldOpenUntitledFile:)])
|
@selector(applicationShouldOpenUntitledFile:)])
|
||||||
{
|
{
|
||||||
if ([_delegate applicationShouldOpenUntitledFile: self]
|
shouldOpen = [_delegate applicationShouldOpenUntitledFile: self];
|
||||||
&& [_delegate respondsToSelector:
|
}
|
||||||
@selector(applicationOpenUntitledFile:)])
|
if (shouldOpen)
|
||||||
{
|
{
|
||||||
[_delegate applicationOpenUntitledFile: self];
|
if (docBased)
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ([[sdc documentClassNames] count] > 0 && [sdc defaultType] != nil)
|
|
||||||
{
|
|
||||||
NSError *err = nil;
|
|
||||||
|
|
||||||
if ([sdc openUntitledDocumentAndDisplay: YES error: &err] == nil
|
|
||||||
&& [sdc presentError: err] == NO)
|
|
||||||
{
|
{
|
||||||
[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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue