Added last window/application close patch.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4680 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
michael 1999-07-31 07:06:06 +00:00
parent a812673ed4
commit edd8804a04
2 changed files with 43 additions and 0 deletions

View file

@ -1,3 +1,9 @@
1999-07-31 Michael Hanni <mhanni@sprintmail.com>
* Source/NSApplication.m: added patch by Pedro Ivo Andrade Tavares
<ptavares@iname.com> to handle last window/application exit. This
implementation mimics OpenStep 4.1.
1999-07-30 Michael Hanni <mhanni@sprintmail.com>
* Source/NSMenu.m: rewrote sections to handle new popupbutton

View file

@ -197,6 +197,12 @@ NSApplication *NSApp = nil;
/* Register our listener to incoming services requests etc. */
[listener registerAsServiceProvider];
#ifndef STRICT_OPENSTEP
/* Register self as observer to every window closing. */
[nc addObserver: self selector: @selector(_windowWillClose:)
name: NSWindowWillCloseNotification object: nil];
#endif
/* finish the launching post notification that launching has finished */
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
object: self];
@ -1500,5 +1506,36 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
return self;
}
#ifndef STRICT_OPENSTEP
- (void) _windowWillClose: (NSNotification*) notification
{
int count, wincount, realcount;
id win = [self windows];
wincount = [win count];
realcount = 0;
for(count = 0; count < wincount; count++)
{
if([[win objectAtIndex: count] canBecomeMainWindow])
{
realcount ++;
}
}
/* If there's only one window left, and that's the one being closed,
then we ask the delegate if the app is to be terminated. */
if (realcount <= 1)
{
NSLog(@"asking delegate whether to terminate app...");
if ([delegate respondsToSelector: @selector(applicationShouldTerminateAfterLastWindowClosed:)])
{
if([delegate applicationShouldTerminateAfterLastWindowClosed: self])
{
[self terminate: self];
}
}
}
}
#endif
@end /* NSApplication */