More tidying.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3471 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1998-12-16 17:36:48 +00:00
parent fd3f754cb5
commit 1299ad6aa2
2 changed files with 63 additions and 24 deletions

View file

@ -95,6 +95,10 @@ static id NSApp;
static NSString *NSAbortModalException = @"NSAbortModalException"; static NSString *NSAbortModalException = @"NSAbortModalException";
@interface NSApplication (Private)
- (void) _windowWillClose: (NSNotification*)n;
- (void) _windowWillOpen: (NSWindow*)win;
@end
@implementation NSApplication @implementation NSApplication
@ -1322,8 +1326,15 @@ NSWindow *w;
*/ */
if ([window_list indexOfObjectIdenticalTo: aWindow] == NSNotFound) if ([window_list indexOfObjectIdenticalTo: aWindow] == NSNotFound)
{ {
[window_list addObject: aWindow]; [self _windowWillOpen: aWindow];
[aWindow setWindowNumber: window_count++]; }
/*
* If Menus are implemented as a subclass of window we must make sure
* to exclude them from the windows menu.
*/
if ([aWindow isKindOfClass: [NSMenu class]])
return;
/* /*
* If this was the first window then make it the main and key window. * If this was the first window then make it the main and key window.
@ -1333,14 +1344,6 @@ NSWindow *w;
[aWindow becomeMainWindow]; [aWindow becomeMainWindow];
[aWindow becomeKeyWindow]; [aWindow becomeKeyWindow];
} }
}
/*
* If Menus are implemented as a subclass of window we must make sure
* to exclude them from the windows menu.
*/
if ([aWindow isKindOfClass: [NSMenu class]])
return;
/* /*
* Can't permit an untitled window in the window menu. * Can't permit an untitled window in the window menu.
@ -1379,7 +1382,6 @@ NSWindow *w;
{ {
menu = [[NSMenu alloc] initWithTitle: [windows_menu title]]; menu = [[NSMenu alloc] initWithTitle: [windows_menu title]];
[self setWindowsMenu: menu]; [self setWindowsMenu: menu];
[menu release];
} }
/* /*
@ -1729,3 +1731,43 @@ BOOL result = YES;
@end /* NSApplication */ @end /* NSApplication */
@implementation NSApplication (Private)
- (void) _windowWillClose: (NSNotification*)n
{
NSWindow *win = [n object];
if ([win isReleasedWhenClosed])
{
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc removeObserver: self
name: NSWindowWillCloseNotification
object: win];
[window_list removeObjectIdenticalTo: win];
/*
* Horrible kludge to handle case where an application has no menu - we
* assume that this is the only window in the application and terminate.
* We only do this for windows that release when closed - any other
* window may be intended to re-open.
*/
if (main_menu == nil)
[self terminate: nil];
}
}
- (void) _windowWillOpen: (NSWindow*)win
{
if ([window_list indexOfObjectIdenticalTo: win] == NSNotFound)
{
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[window_list addObject: win];
[win setWindowNumber: window_count++];
[nc addObserver: self
selector: @selector(_windowWillClose:)
name: NSWindowWillCloseNotification
object: win];
}
}
@end

View file

@ -630,24 +630,21 @@ NSView *v;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
/*
* If 'is_released_when_closed' then the window will be removed from the
* applications list of windows (causing it to be released) - so we must
* bracket any work we do in a retain/release sequence.
*/
if (is_released_when_closed)
[self retain];
[nc postNotificationName: NSWindowWillCloseNotification object: self]; [nc postNotificationName: NSWindowWillCloseNotification object: self];
[theApp removeWindowsItem: self]; [theApp removeWindowsItem: self];
[self orderOut: self]; [self orderOut: self];
visible = NO; visible = NO;
if (is_released_when_closed) if (is_released_when_closed)
{ [self release];
[self autorelease];
/*
* Horrible kludge to handle case where an application has no menu - we
* assume that this is the only window in the application and terminate.
* We only do this for windows that release when closed - any other
* window may be intended to re-open.
*/
if ([theApp mainMenu] == nil)
[theApp terminate: nil];
}
} }
- (void)deminiaturize:sender - (void)deminiaturize:sender