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>
* 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
@ -434,25 +450,31 @@ static NSMutableArray *toolbars;
if([allowedItems containsObject: itemIdentifier])
{
item = [_delegate toolbar: self
itemForItemIdentifier: itemIdentifier
willBeInsertedIntoToolbar: YES];
item = [self _toolbarItemForIdentifier: itemIdentifier];
if(item == nil)
{
item = [_delegate toolbar: self
itemForItemIdentifier: itemIdentifier
willBeInsertedIntoToolbar: YES];
}
if (item != nil)
{
[nc postNotificationName: NSToolbarWillAddItemNotification object: self];
[item _setToolbar: self];
[_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
[_toolbarView _reload];
if (broadcast)
{
TRANSMIT(_insertItemWithItemIdentifier: itemIdentifier atIndex: index broadcast: NO);
}
}
}
{
[nc postNotificationName: NSToolbarWillAddItemNotification object: self];
[item _setToolbar: self];
[_items insertObject: item atIndex: index];
// We reload the toolbarView each time a new item is
// added except when we build/create the toolbar
if (!_build)
[_toolbarView _reload];
if (broadcast)
{
TRANSMIT(_insertItemWithItemIdentifier: itemIdentifier
atIndex: index broadcast: NO);
}
}
}
}
- (void) _removeItemAtIndex: (int)index broadcast: (BOOL)broadcast