Corrected issue with inserting system defined toolbar items.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18757 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-03-03 21:41:09 +00:00
parent aafb1832d8
commit 6c860d7497
2 changed files with 46 additions and 18 deletions

View file

@ -1,3 +1,9 @@
2004-02-29 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSToolbar.m: Added code in
-[NSToolbar insertItemWithIdentifier:atIndex:] to properly
handle when a system defined identifier is passed to the toolbar.
2004-03-01 Fred Kiefer <FredKiefer@gmx.de> 2004-03-01 Fred Kiefer <FredKiefer@gmx.de>
* Header/AppKit/NSTableView.h: * Header/AppKit/NSTableView.h:

View file

@ -410,6 +410,22 @@ static NSMutableArray *toolbars;
} }
} }
- (id) _toolbarItemForIdentifier: (NSString *)itemIdent
{
id item = nil;
if([itemIdent isEqual: NSToolbarSeparatorItemIdentifier] ||
[itemIdent isEqual: NSToolbarSpaceItemIdentifier] ||
[itemIdent isEqual: NSToolbarFlexibleSpaceItemIdentifier] ||
[itemIdent isEqual: NSToolbarShowColorsItemIdentifier] ||
[itemIdent isEqual: NSToolbarShowFontsItemIdentifier] ||
[itemIdent isEqual: NSToolbarCustomizeToolbarItemIdentifier] ||
[itemIdent isEqual: NSToolbarPrintItemIdentifier])
{
item = [[NSToolbarItem alloc] initWithItemIdentifier: itemIdent];
}
return item;
}
/* /*
* *
* The methods below handles the toolbar edition and broacasts each associated event * The methods below handles the toolbar edition and broacasts each associated event
@ -434,25 +450,31 @@ static NSMutableArray *toolbars;
if([allowedItems containsObject: itemIdentifier]) if([allowedItems containsObject: itemIdentifier])
{ {
item = [_delegate toolbar: self item = [self _toolbarItemForIdentifier: itemIdentifier];
itemForItemIdentifier: itemIdentifier if(item == nil)
willBeInsertedIntoToolbar: YES]; {
item = [_delegate toolbar: self
itemForItemIdentifier: itemIdentifier
willBeInsertedIntoToolbar: YES];
}
if (item != nil) if (item != nil)
{ {
[nc postNotificationName: NSToolbarWillAddItemNotification object: self]; [nc postNotificationName: NSToolbarWillAddItemNotification object: self];
[item _setToolbar: self]; [item _setToolbar: self];
[_items insertObject: item atIndex: index]; [_items insertObject: item atIndex: index];
if (!_build) // we reload the toolbarView each time a new item is added except when we build/create the toolbar // We reload the toolbarView each time a new item is
[_toolbarView _reload]; // added except when we build/create the toolbar
if (!_build)
if (broadcast) [_toolbarView _reload];
{
TRANSMIT(_insertItemWithItemIdentifier: itemIdentifier atIndex: index broadcast: NO); if (broadcast)
} {
} TRANSMIT(_insertItemWithItemIdentifier: itemIdentifier
} atIndex: index broadcast: NO);
}
}
}
} }
- (void) _removeItemAtIndex: (int)index broadcast: (BOOL)broadcast - (void) _removeItemAtIndex: (int)index broadcast: (BOOL)broadcast