mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
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:
parent
2edde21185
commit
7f4faee93a
2 changed files with 43 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue