From f8dc080c34ab45206e763985cf0ce7f13f9fbeb8 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 22 Aug 1999 21:16:21 +0000 Subject: [PATCH] setMainMenu: fixes git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4747 72102866-910b-0410-8b05-ffd578937521 --- Source/NSApplication.m | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Source/NSApplication.m b/Source/NSApplication.m index eb778dcb3..1bd31f2d9 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -1092,12 +1092,20 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); - (void) setMainMenu: (NSMenu*)aMenu { - unsigned i, j; - NSMenuItem *mc; - NSArray *mi; + unsigned i, j; + NSMenuItem *mc; + NSArray *mi; + + if (main_menu != nil && main_menu != aMenu) + { + [main_menu close]; + } ASSIGN(main_menu, aMenu); + [aMenu setTitle: + [[[NSProcessInfo processInfo] processName] lastPathComponent]]; + [aMenu sizeToFit]; /* * Find a menucell with the title Windows this is the default windows menu */ @@ -1113,6 +1121,12 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); break; } } + + if ([self isActive]) + { + [main_menu update]; + [main_menu display]; + } } /* @@ -1214,12 +1228,12 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); break; i++; } - item = [menu insertItemWithTitle: aString action: @selector(makeKeyAndOrderFront:) keyEquivalent: @"" atIndex: i]; [item setTarget: aWindow]; + [menu sizeToFit]; [menu update]; } @@ -1243,6 +1257,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); if ([item target] == aWindow) { [menu removeItem: item]; + [menu sizeToFit]; [menu update]; break; } @@ -1299,6 +1314,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); filename: [win representedFilename] != nil]; [windows removeLastObject]; } + [aMenu sizeToFit]; [aMenu update]; } } @@ -1360,6 +1376,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); if (changed) { [(id)[item controlView] sizeToFit]; + [menu sizeToFit]; [menu update]; } break;