Many updates to fix problems with menus etc

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3500 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1998-12-22 12:34:03 +00:00
parent cb22210be6
commit 25a37ec353
7 changed files with 70 additions and 56 deletions

View file

@ -1,3 +1,20 @@
Tue Dec 22 12:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/GSServicesManager.m: ([-rebuildServicesMenu:]) release submenu
once it's added to main menu.a ([-update]) Don't force a display -
let the autodisplay mechanism do it.
* Source/NSMenu.m: ([-update]) Check to see if autoupdate is enabled
properly and don't force a redisplay unnecessarily.
* Source/NSApplication.m: ([-run]) update main menu items.
* Source/NSMenuItem.m: Fix memory leak when copying an item with a
submenu - the submenu was never released.
* Source/NSWindow.m: Don't add window to windows menu in
([-initWithContentRect:styleMask:backing:defer:screen:]).
([-setMiniwindowTitle:]) Don't change windows menu if excluded.
([-makeKeyAndOrderFront:]) Make main window as well as key window.
([-initWithCoder:]) Don't put in windows menu automatically.
* Source/NSpanel.m: Implemented ([canBecomeMainWindow]) to return NO.
Sat Dec 19 01:26:06 1998 Matthias Klose <doko@cs.tu-berlin.de> Sat Dec 19 01:26:06 1998 Matthias Klose <doko@cs.tu-berlin.de>
* Images/Makefile.postamble: Use macro MKDIRS. * Images/Makefile.postamble: Use macro MKDIRS.

View file

@ -689,6 +689,7 @@ static NSString *disabledName = @".GNUstepDisabled";
menu = [[NSMenu alloc] initWithTitle: parentTitle]; menu = [[NSMenu alloc] initWithTitle: parentTitle];
[servicesMenu setSubmenu: menu [servicesMenu setSubmenu: menu
forItem: item]; forItem: item];
[menu release];
} }
else else
{ {
@ -957,7 +958,7 @@ static NSString *disabledName = @".GNUstepDisabled";
/* /*
* If there is no title mapping, this cell must be a * If there is no title mapping, this cell must be a
* submenu - so we chaeck the submenu cells. * submenu - so we check the submenu cells.
*/ */
if (title == nil && [[cell target] isKindOfClass: [NSMenu class]]) if (title == nil && [[cell target] isKindOfClass: [NSMenu class]])
{ {
@ -984,9 +985,6 @@ static NSString *disabledName = @".GNUstepDisabled";
[subMenuCells cellFrameAtRow: j]]; [subMenuCells cellFrameAtRow: j]];
} }
} }
/* FIXME - only doing this here 'cos auto-display doesn't work */
if ([subMenuCells needsDisplay])
[subMenuCells display];
} }
else else
shouldBeEnabled = [self validateMenuItem: cell]; shouldBeEnabled = [self validateMenuItem: cell];
@ -997,9 +995,6 @@ static NSString *disabledName = @".GNUstepDisabled";
[menuCells setNeedsDisplayInRect: [menuCells cellFrameAtRow: i]]; [menuCells setNeedsDisplayInRect: [menuCells cellFrameAtRow: i]];
} }
} }
/* FIXME - only doing this here 'cos auto-display doesn't work */
if ([menuCells needsDisplay])
[menuCells display];
} }
} }

View file

@ -286,11 +286,13 @@ NSAutoreleasePool* pool;
if (e) if (e)
[self sendEvent: e]; [self sendEvent: e];
[listener updateServicesMenu]; // update (en/disable) the
// services menu's items
[main_menu update];
if (windows_need_update) // send an update message if (windows_need_update) // send an update message
[self updateWindows]; // to all visible windows [self updateWindows]; // to all visible windows
[listener updateServicesMenu]; // update (en/disable) the
// services menu's items
[pool release]; [pool release];
} }
while (!app_should_quit); while (!app_should_quit);

View file

@ -440,13 +440,13 @@ static Class menuCellClass = nil;
- (void)update - (void)update
{ {
// SUBCLASS to redisplay the menu // SUBCLASS to redisplay the menu if necessary
id cells; id cells;
int i, count; int i, count;
id theApp = [NSApplication sharedApplication]; id theApp = [NSApplication sharedApplication];
if (![[theApp mainMenu] autoenablesItems]) if (![self autoenablesItems])
return; return;
cells = [menuCells itemArray]; cells = [menuCells itemArray];
@ -509,15 +509,11 @@ static Class menuCellClass = nil;
} }
} }
/* Reenable displaying of menus */
[self setMenuChangedMessagesEnabled:YES];
if (menuHasChanged) if (menuHasChanged)
[self sizeToFit]; [self sizeToFit];
/* FIXME - only doing this here 'cos auto-display doesn't work */ /* Reenable displaying of menus */
if ([menuCells needsDisplay]) [self setMenuChangedMessagesEnabled:YES];
[menuCells display];
} }
- (void) performActionForItem: (id <NSMenuItem>)cell - (void) performActionForItem: (id <NSMenuItem>)cell
@ -531,11 +527,11 @@ static Class menuCellClass = nil;
nc = [NSNotificationCenter defaultCenter]; nc = [NSNotificationCenter defaultCenter];
d = [NSDictionary dictionaryWithObject: cell forKey: @"MenuItem"]; d = [NSDictionary dictionaryWithObject: cell forKey: @"MenuItem"];
[nc postNotificationName: NSMenuWillSendActionNotification [nc postNotificationName: NSMenuWillSendActionNotification
object: self object: self
userInfo: d]; userInfo: d];
[[NSApplication sharedApplication] sendAction: [cell action] [[NSApplication sharedApplication] sendAction: [cell action]
to: [cell target] to: [cell target]
from: cell]; from: cell];
[nc postNotificationName: NSMenuDidSendActionNotification [nc postNotificationName: NSMenuDidSendActionNotification
object: self object: self
userInfo: d]; userInfo: d];

View file

@ -72,17 +72,19 @@ static BOOL usesUserKeyEquivalents = YES;
[super dealloc]; [super dealloc];
} }
- (id)copyWithZone:(NSZone*)zone - (id) copyWithZone: (NSZone*)zone
{ {
NSMenuItem* copy = [super copyWithZone:zone]; NSMenuItem* copy = [super copyWithZone:zone];
NSDebugLog (@"menu item '%@' copy", [self title]); NSDebugLog (@"menu item '%@' copy", [self title]);
copy->representedObject = [representedObject retain]; copy->representedObject = [representedObject retain];
copy->hasSubmenu = hasSubmenu; copy->hasSubmenu = hasSubmenu;
if (hasSubmenu) { // recursive call if (hasSubmenu)
id submenu = [target copyWithZone:zone]; // to create our {
copy->target = [submenu retain]; // submenus // recursive call
} id submenu = [target copyWithZone: zone];
copy->target = submenu;
}
return copy; return copy;
} }

View file

@ -98,6 +98,11 @@
return self; return self;
} }
- (BOOL) canBecomeKeyWindow
{
return NO;
}
// //
// If we receive an escape, close. // If we receive an escape, close.
// //

View file

@ -193,9 +193,6 @@ NSRect cframe;
cframe.size = frame.size; cframe.size = frame.size;
[self setContentView:[[[NSView alloc] initWithFrame:cframe] autorelease]]; [self setContentView:[[[NSView alloc] initWithFrame:cframe] autorelease]];
[theApp addWindowsItem: self title: nil filename: NO];
_flushRectangles = [[NSMutableArray alloc] initWithCapacity:10]; _flushRectangles = [[NSMutableArray alloc] initWithCapacity:10];
NSDebugLog(@"NSWindow end of init\n"); NSDebugLog(@"NSWindow end of init\n");
@ -304,9 +301,10 @@ NSView *wv;
title = window_title; title = window_title;
if ([title isEqual: represented_filename]) if ([title isEqual: represented_filename])
isDoc = YES; isDoc = YES;
[[NSApplication sharedApplication] changeWindowsItem: self if (menu_exclude == NO)
title: title [[NSApplication sharedApplication] changeWindowsItem: self
filename: isDoc]; title: title
filename: isDoc];
} }
// //
@ -365,20 +363,25 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- (void)makeKeyAndOrderFront:sender - (void)makeKeyAndOrderFront:sender
{ {
[self makeKeyWindow]; // Make self the key window [self makeKeyWindow]; // Make self the key window
[self orderFront:sender]; // order self to the front /*
* OPENSTEP makes a window the main window when it makes it the key window.
* So we do the same (though the documentation doesn't mention it).
*/
[self makeMainWindow];
[self orderFront: sender]; // order self to the front
} }
- (void)makeKeyWindow - (void) makeKeyWindow
{ {
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
// Can we become the key // Can we become the key
if (![self canBecomeKeyWindow]) // window? if (![self canBecomeKeyWindow]) // window?
return; return;
// ask the current key // ask the current key
[[theApp keyWindow] resignKeyWindow]; // window to resign status [[theApp keyWindow] resignKeyWindow]; // window to resign status
[self becomeKeyWindow]; // become the key window [self becomeKeyWindow]; // become the key window
} }
- (void)makeMainWindow - (void)makeMainWindow
@ -524,17 +527,16 @@ NSPoint basePoint;
} }
} }
- (void)update - (void) update
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if (is_autodisplay && needs_display) // if autodisplay is if (is_autodisplay && needs_display) // if autodisplay is
{ // enabled and window { // enabled and window
[self displayIfNeeded]; // display [self displayIfNeeded]; // display
[self flushWindowIfNeeded]; [self flushWindowIfNeeded];
} }
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
} }
- (void)flushWindowIfNeeded - (void)flushWindowIfNeeded
@ -1314,11 +1316,6 @@ id result = nil;
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate]; [aDecoder decodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved]; [aDecoder decodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved];
// Register ourselves with the Application object
// +++ we shouldn't do this because coding may not be done?
// better to do it in the awakeFromCoder method
theApp = [NSApplication sharedApplication];
[theApp addWindowsItem: self title: nil filename: NO];
NSDebugLog(@"NSWindow: finish decoding\n"); NSDebugLog(@"NSWindow: finish decoding\n");
return self; return self;