* Source/GSNibLoading.m:

* Source/NSToolbar.m:
* Source/GSToolbarCustomizationPalette.m:
* Source/GSToolbarView.m:
* Source/NSToolbarItem.m:
* Source/NSToolbarFrameworkPrivate.h:
* Headers/AppKit/NSToolbar.h: Implement -initWithCoder: for
NSToolbar. This required a bit more work that usual because
toolbars created with -initWithCoder can operate without a delegate.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34189 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2011-11-18 20:15:53 +00:00
parent 3961169a72
commit f0d3f1435a
7 changed files with 239 additions and 106 deletions

View file

@ -92,6 +92,10 @@ APPKIT_EXPORT NSString *NSToolbarWillAddItemNotification;
BOOL _customizationPaletteIsRunning; BOOL _customizationPaletteIsRunning;
BOOL _showsBaselineSeparator; BOOL _showsBaselineSeparator;
BOOL _build; BOOL _build;
NSDictionary *_interfaceBuilderItemsByIdentifier;
NSArray *_interfaceBuilderAllowedItemIdentifiers;
NSArray *_interfaceBuilderDefaultItemIdentifiers;
NSArray *_interfaceBuilderSelectableItemIdentifiers;
} }
// Instance methods // Instance methods

View file

@ -479,6 +479,11 @@ static BOOL _isInInterfaceBuilder = NO;
[_realObject setMaxSize: _maxSize]; [_realObject setMaxSize: _maxSize];
[_realObject setTitle: _title]; [_realObject setTitle: _title];
if ([_viewClass isKindOfClass: [NSToolbar class]])
{
[_realObject setToolbar: _viewClass];
}
[_view _fixSubviews]; [_view _fixSubviews];
// FIXME What is the point of calling -setFrame:display: here? It looks // FIXME What is the point of calling -setFrame:display: here? It looks

View file

@ -278,7 +278,6 @@
NSString *identifier = nil; NSString *identifier = nil;
NSToolbarDisplayMode tag = [toolbar displayMode]; NSToolbarDisplayMode tag = [toolbar displayMode];
NSToolbarSizeMode size = [toolbar sizeMode]; NSToolbarSizeMode size = [toolbar sizeMode];
id delegate = [toolbar delegate];
NSView *toolbarView; NSView *toolbarView;
NSRect toolbarFrame; NSRect toolbarFrame;
NSPoint bottomCenter; NSPoint bottomCenter;
@ -299,38 +298,22 @@
[_sizeCheckBox setState: NSOffState]; [_sizeCheckBox setState: NSOffState];
} }
if (delegate == nil) itemIdentifiers = [toolbar _allowedItemIdentifiers];
{
NSLog(@"The toolbar %@ needs a delegate to allow customization",
toolbar);
return;
}
itemIdentifiers = [delegate toolbarAllowedItemIdentifiers: toolbar];
e = [itemIdentifiers objectEnumerator]; e = [itemIdentifiers objectEnumerator];
while ((identifier = [e nextObject]) != nil) while ((identifier = [e nextObject]) != nil)
{ {
NSToolbarItem *item = [toolbar _toolbarItemForIdentifier: identifier]; NSToolbarItem *item = [toolbar _toolbarItemForIdentifier: identifier
if(item == nil) willBeInsertedIntoToolbar: NO];
{ NSLog(@"item %@ for ident %@", item, identifier);
item = [delegate toolbar: toolbar
itemForItemIdentifier: identifier
willBeInsertedIntoToolbar: NO];
}
[_allowedItems addObject: item]; [_allowedItems addObject: item];
} }
itemIdentifiers = [delegate toolbarDefaultItemIdentifiers: toolbar]; itemIdentifiers = [toolbar _defaultItemIdentifiers];
e = [itemIdentifiers objectEnumerator]; e = [itemIdentifiers objectEnumerator];
while ((identifier = [e nextObject]) != nil) while ((identifier = [e nextObject]) != nil)
{ {
NSToolbarItem *item = [toolbar _toolbarItemForIdentifier: identifier]; NSToolbarItem *item = [toolbar _toolbarItemForIdentifier: identifier
if(item == nil) willBeInsertedIntoToolbar: NO];
{
item = [delegate toolbar: toolbar
itemForItemIdentifier: identifier
willBeInsertedIntoToolbar: NO];
}
[_defaultItems addObject: item]; [_defaultItems addObject: item];
} }

View file

@ -151,7 +151,6 @@ static int draggedItemIndex = NSNotFound;
{ {
return [self overflowMenu]; return [self overflowMenu];
} }
return nil; return nil;
} }
@ -327,7 +326,7 @@ static int draggedItemIndex = NSNotFound;
NSToolbarItem *item = [[info draggingSource] toolbarItem]; NSToolbarItem *item = [[info draggingSource] toolbarItem];
NSString *identifier = [item itemIdentifier]; NSString *identifier = [item itemIdentifier];
NSToolbar *toolbar = [self toolbar]; NSToolbar *toolbar = [self toolbar];
NSArray *allowedItemIdentifiers = [[toolbar delegate] toolbarAllowedItemIdentifiers: toolbar]; NSArray *allowedItemIdentifiers = [toolbar _allowedItemIdentifiers];
int newIndex; int newIndex;
// don't accept any dragging if the customization palette isn't running for this toolbar // don't accept any dragging if the customization palette isn't running for this toolbar
@ -889,4 +888,14 @@ static int draggedItemIndex = NSNotFound;
NSLog(@"Use of deprecated method %@", NSStringFromSelector(_cmd)); NSLog(@"Use of deprecated method %@", NSStringFromSelector(_cmd));
} }
- (NSMenu *) menuForEvent: (NSEvent *)event
{
NSMenu *menu = [[[NSMenu alloc] initWithTitle: @""] autorelease];
NSMenuItem *customize = [menu insertItemWithTitle: _(@"Customize Toolbar") action:@selector(runCustomizationPalette:) keyEquivalent:@"" atIndex:0];
[customize setTarget: _toolbar];
return menu;
}
@end @end

View file

@ -510,7 +510,13 @@ static GSValidationCenter *vc = nil;
ASSIGN(_identifier, identifier); ASSIGN(_identifier, identifier);
_items = [[NSMutableArray alloc] init]; _items = [[NSMutableArray alloc] init];
// Only set when loaded from a nib
_interfaceBuilderItemsByIdentifier = nil;
_interfaceBuilderAllowedItemIdentifiers = nil;
_interfaceBuilderDefaultItemIdentifiers = nil;
_interfaceBuilderSelectableItemIdentifiers = nil;
toolbarModel = [self _toolbarModel]; toolbarModel = [self _toolbarModel];
if (toolbarModel != nil) if (toolbarModel != nil)
@ -542,6 +548,53 @@ static GSValidationCenter *vc = nil;
return self; return self;
} }
- (NSArray *) _identifiersForItems: (NSArray*)items
{
NSMutableArray *result = [NSMutableArray arrayWithCapacity: [items count]];
NSEnumerator *e = [items objectEnumerator];
NSToolbarItem *item;
if (items == nil)
return nil;
while ((item = [e nextObject]) != nil)
{
[result addObject: [item itemIdentifier]];
}
return result;
}
- (id) initWithCoder: (NSCoder *)aCoder
{
self = [super initWithCoder: aCoder];
_identifier = [[aCoder decodeObjectForKey:@"NSToolbarIdentifier"] retain];
_items = [[NSMutableArray alloc] init];
_configurationDictionary = nil;
_customizationPaletteIsRunning = NO;
ASSIGN(_interfaceBuilderItemsByIdentifier, [aCoder decodeObjectForKey: @"NSToolbarIBIdentifiedItems"]);
ASSIGN(_interfaceBuilderAllowedItemIdentifiers, [self _identifiersForItems: [aCoder decodeObjectForKey: @"NSToolbarIBAllowedItems"]]);
ASSIGN(_interfaceBuilderDefaultItemIdentifiers, [self _identifiersForItems: [aCoder decodeObjectForKey: @"NSToolbarIBDefaultItems"]]);
ASSIGN(_interfaceBuilderSelectableItemIdentifiers, [self _identifiersForItems: [aCoder decodeObjectForKey: @"NSToolbarIBSelectableItems"]]);
// Store in list of toolbars
[toolbars addObject: self];
[self setAllowsUserCustomization: [aCoder decodeBoolForKey: @"NSToolbarAllowsUserCustomization"]];
[self setAutosavesConfiguration: [aCoder decodeBoolForKey: @"NSToolbarAutosavesConfiguration"]];
[self setDisplayMode: [aCoder decodeIntForKey: @"NSToolbarDisplayMode"]];
[self setShowsBaselineSeparator: [aCoder decodeBoolForKey: @"NSToolbarShowsBaselineSeparator"]];
[self setSizeMode: [aCoder decodeIntForKey: @"NSToolbarSizeMode"]];
[self setVisible: [aCoder decodeBoolForKey: @"NSToolbarPrefersToBeShown"]];
[self setDelegate: [aCoder decodeObjectForKey: @"NSToolbarDelegate"]];
return self;
}
//FIXME: encodeWithCoder
- (void) dealloc - (void) dealloc
{ {
//NSLog(@"Toolbar dealloc %@", self); //NSLog(@"Toolbar dealloc %@", self);
@ -553,6 +606,11 @@ static GSValidationCenter *vc = nil;
RELEASE(_configurationDictionary); RELEASE(_configurationDictionary);
RELEASE(_items); RELEASE(_items);
DESTROY(_interfaceBuilderItemsByIdentifier);
DESTROY(_interfaceBuilderAllowedItemIdentifiers);
DESTROY(_interfaceBuilderDefaultItemIdentifiers);
DESTROY(_interfaceBuilderSelectableItemIdentifiers);
if (_delegate != nil) if (_delegate != nil)
{ {
[nc removeObserver: _delegate name: nil object: self]; [nc removeObserver: _delegate name: nil object: self];
@ -563,7 +621,7 @@ static GSValidationCenter *vc = nil;
} }
// FIXME: Hack // FIXME: Hack
- (void) release - (oneway void) release
{ {
// When a toolbar has no external references any more, it's necessary // When a toolbar has no external references any more, it's necessary
// to remove the toolbar from the master list, so that it // to remove the toolbar from the master list, so that it
@ -759,13 +817,22 @@ static GSValidationCenter *vc = nil;
{ {
#define CHECK_REQUIRED_METHOD(selector_name) \ #define CHECK_REQUIRED_METHOD(selector_name) \
if (![_delegate respondsToSelector: @selector(selector_name)]) \ if (![_delegate respondsToSelector: @selector(selector_name)]) \
[NSException raise: NSInternalInconsistencyException \ [NSException raise: NSInternalInconsistencyException \
format: @"delegate does not respond to %@",@#selector_name] format: @"delegate does not respond to %@",@#selector_name]
CHECK_REQUIRED_METHOD(toolbar:itemForItemIdentifier: if (_interfaceBuilderItemsByIdentifier == nil)
willBeInsertedIntoToolbar:); {
CHECK_REQUIRED_METHOD(toolbarAllowedItemIdentifiers:); CHECK_REQUIRED_METHOD(toolbar:itemForItemIdentifier:
CHECK_REQUIRED_METHOD(toolbarDefaultItemIdentifiers:); willBeInsertedIntoToolbar:);
}
if (_interfaceBuilderAllowedItemIdentifiers == nil)
{
CHECK_REQUIRED_METHOD(toolbarAllowedItemIdentifiers:);
}
if (_interfaceBuilderDefaultItemIdentifiers == nil)
{
CHECK_REQUIRED_METHOD(toolbarDefaultItemIdentifiers:);
}
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([_delegate respondsToSelector: @selector(toolbar##notif_name:)]) \ if ([_delegate respondsToSelector: @selector(toolbar##notif_name:)]) \
@ -780,18 +847,37 @@ static GSValidationCenter *vc = nil;
[self _build]; [self _build];
} }
- (NSArray *) _selectableItemIdentifiers
{
NSArray *selectableIdentifiers = nil;
if (_delegate != nil &&
[_delegate respondsToSelector: @selector(toolbarSelectableItemIdentifiers:)])
{
selectableIdentifiers = [_delegate toolbarSelectableItemIdentifiers: self];
if (selectableIdentifiers == nil)
{
NSLog(@"Toolbar delegate returns no such selectable item identifiers");
}
}
if (selectableIdentifiers == nil)
{
selectableIdentifiers = _interfaceBuilderSelectableItemIdentifiers;
}
return selectableIdentifiers;
}
- (void) setSelectedItemIdentifier: (NSString *)identifier - (void) setSelectedItemIdentifier: (NSString *)identifier
{ {
NSArray *selectedItems; NSArray *selectedItems;
NSArray *itemsToSelect; NSArray *itemsToSelect;
NSEnumerator *e; NSEnumerator *e;
NSToolbarItem *item; NSToolbarItem *item;
NSArray *selectableIdentifiers = nil; NSArray *selectableIdentifiers;
BOOL updated = NO; BOOL updated = NO;
if (_delegate == nil)
return;
// First, we have to deselect the previous selected toolbar items // First, we have to deselect the previous selected toolbar items
selectedItems = [[self items] objectsWithValue: [self selectedItemIdentifier] selectedItems = [[self items] objectsWithValue: [self selectedItemIdentifier]
forKey: @"_itemIdentifier"]; forKey: @"_itemIdentifier"];
@ -801,25 +887,11 @@ static GSValidationCenter *vc = nil;
[item _setSelected: NO]; [item _setSelected: NO];
} }
if ([_delegate respondsToSelector: selectableIdentifiers = [self _selectableItemIdentifiers];
@selector(toolbarSelectableItemIdentifiers:)])
{ if (selectableIdentifiers == nil)
selectableIdentifiers = return;
[_delegate toolbarSelectableItemIdentifiers: self];
}
else
{
NSLog(@"Toolbar delegate does not respond to %@",
@selector(toolbarSelectableItemIdentifiers:));
return;
}
if (selectableIdentifiers == nil)
{
NSLog(@"Toolbar delegate returns no such selectable item identifiers");
return;
}
itemsToSelect = [_items objectsWithValue: identifier itemsToSelect = [_items objectsWithValue: identifier
forKey: @"_itemIdentifier"]; forKey: @"_itemIdentifier"];
e = [itemsToSelect objectEnumerator]; e = [itemsToSelect objectEnumerator];
@ -888,6 +960,18 @@ static GSValidationCenter *vc = nil;
// Private methods // Private methods
- (NSArray *) _defaultItemIdentifiers
{
if (_delegate != nil)
{
return [_delegate toolbarDefaultItemIdentifiers:self];
}
else
{
return _interfaceBuilderDefaultItemIdentifiers;
}
}
/* /*
* Toolbar build : * Toolbar build :
* will use the delegate when there is no toolbar model * will use the delegate when there is no toolbar model
@ -920,13 +1004,7 @@ static GSValidationCenter *vc = nil;
RELEASE(_items); RELEASE(_items);
_items = [[NSMutableArray alloc] init]; _items = [[NSMutableArray alloc] init];
if (_delegate == nil)
{
_build = NO;
return;
}
toolbarModel = [self _toolbarModel]; toolbarModel = [self _toolbarModel];
wantedItemIdentifiers = [self _itemsFromConfig]; wantedItemIdentifiers = [self _itemsFromConfig];
@ -938,10 +1016,15 @@ static GSValidationCenter *vc = nil;
[[toolbarModel items] valueForKey: @"_itemIdentifier"]; [[toolbarModel items] valueForKey: @"_itemIdentifier"];
} }
else else
{ {
wantedItemIdentifiers = [_delegate toolbarDefaultItemIdentifiers:self]; wantedItemIdentifiers = [self _defaultItemIdentifiers];
} }
} }
if (wantedItemIdentifiers == nil)
{
_build = NO;
return;
}
e = [wantedItemIdentifiers objectEnumerator]; e = [wantedItemIdentifiers objectEnumerator];
while ((itemIdentifier = [e nextObject]) != nil) while ((itemIdentifier = [e nextObject]) != nil)
@ -1104,7 +1187,7 @@ static GSValidationCenter *vc = nil;
return nil; return nil;
} }
- (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent - (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent willBeInsertedIntoToolbar: (BOOL)insert
{ {
NSToolbarItem *item = nil; NSToolbarItem *item = nil;
@ -1116,10 +1199,21 @@ static GSValidationCenter *vc = nil;
[itemIdent isEqual: NSToolbarCustomizeToolbarItemIdentifier] || [itemIdent isEqual: NSToolbarCustomizeToolbarItemIdentifier] ||
[itemIdent isEqual: NSToolbarPrintItemIdentifier]) [itemIdent isEqual: NSToolbarPrintItemIdentifier])
{ {
item = [[NSToolbarItem alloc] initWithItemIdentifier: itemIdent]; item = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
} }
return AUTORELEASE(item); if (item == nil && _delegate != nil)
{
item = [_delegate toolbar: self itemForItemIdentifier: itemIdent
willBeInsertedIntoToolbar: insert];
}
if (item == nil && _interfaceBuilderItemsByIdentifier)
{
item = [_interfaceBuilderItemsByIdentifier objectForKey: itemIdent];
}
return item;
} }
@ -1141,40 +1235,35 @@ static GSValidationCenter *vc = nil;
[toolbar signature]; \ [toolbar signature]; \
} \ } \
- (NSArray *) _allowedItemIdentifiers
{
if (_delegate)
{
return [_delegate toolbarAllowedItemIdentifiers: self];
}
else
{
return _interfaceBuilderAllowedItemIdentifiers;
}
}
- (void) _insertItemWithItemIdentifier: (NSString *)itemIdentifier - (void) _insertItemWithItemIdentifier: (NSString *)itemIdentifier
atIndex: (int)index atIndex: (int)index
broadcast: (BOOL)broadcast broadcast: (BOOL)broadcast
{ {
NSToolbarItem *item = nil; NSToolbarItem *item = nil;
NSArray *allowedItems; NSArray *allowedItems = [self _allowedItemIdentifiers];
if (_delegate == nil)
return;
allowedItems = [_delegate toolbarAllowedItemIdentifiers: self];
if ([allowedItems containsObject: itemIdentifier]) if ([allowedItems containsObject: itemIdentifier])
{ {
item = [self _toolbarItemForIdentifier: itemIdentifier]; item = [self _toolbarItemForIdentifier: itemIdentifier willBeInsertedIntoToolbar: YES];
if (item == nil)
{
item =
[_delegate toolbar: self itemForItemIdentifier: itemIdentifier
willBeInsertedIntoToolbar: YES];
}
if (item != nil) if (item != nil)
{ {
NSArray *selectableItems; NSArray *selectableItems = [self _selectableItemIdentifiers];
if ([_delegate respondsToSelector: if ([selectableItems containsObject: itemIdentifier])
@selector(toolbarSelectableItemIdentifiers:)]) [item _setSelectable: YES];
{
selectableItems =
[_delegate toolbarSelectableItemIdentifiers: self];
if ([selectableItems containsObject: itemIdentifier])
[item _setSelectable: YES];
}
[nc postNotificationName: NSToolbarWillAddItemNotification [nc postNotificationName: NSToolbarWillAddItemNotification
object: self object: self
@ -1451,4 +1540,6 @@ static GSValidationCenter *vc = nil;
[self validateVisibleItems]; [self validateVisibleItems];
} }
@end @end

View file

@ -94,7 +94,6 @@
toIndex: (int)newIndex toIndex: (int)newIndex
broadcast: (BOOL)broacast; broadcast: (BOOL)broacast;
- (void) _performRemoveItem: (NSToolbarItem *)item; // Used by drag setup - (void) _performRemoveItem: (NSToolbarItem *)item; // Used by drag setup
- (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent;
- (NSToolbar *) _toolbarModel; - (NSToolbar *) _toolbarModel;
- (void) _validate: (NSWindow *)observedWindow; - (void) _validate: (NSWindow *)observedWindow;
- (void) _toolbarViewWillMoveToSuperview: (NSView *)newSuperview; - (void) _toolbarViewWillMoveToSuperview: (NSView *)newSuperview;
@ -111,6 +110,13 @@
// Deprecated // Deprecated
- (void) setUsesStandardBackgroundColor: (BOOL)standard; - (void) setUsesStandardBackgroundColor: (BOOL)standard;
- (BOOL) usesStandardBackgroundColor; - (BOOL) usesStandardBackgroundColor;
// Delegate wrappers
- (NSArray *) _allowedItemIdentifiers;
- (NSArray *) _defaultItemIdentifiers;
- (NSArray *) _selectableItemIdentifiers;
- (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent willBeInsertedIntoToolbar: (BOOL)insert;
@end @end
@interface GSWindowDecorationView (ToolbarPrivate) @interface GSWindowDecorationView (ToolbarPrivate)

View file

@ -929,12 +929,12 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
*/ */
// ---- NSToolbarSeparatorItemIdentifier // ---- NSToolbarSeparatorItemIdentifier
@interface GSToolbarSeparatorItem : NSToolbarItem @interface NSToolbarSeparatorItem : NSToolbarItem
{ {
} }
@end @end
@implementation GSToolbarSeparatorItem @implementation NSToolbarSeparatorItem
- (id) initWithItemIdentifier: (NSString *)itemIdentifier - (id) initWithItemIdentifier: (NSString *)itemIdentifier
{ {
self = [super initWithItemIdentifier: itemIdentifier]; self = [super initWithItemIdentifier: itemIdentifier];
@ -977,12 +977,12 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
@end @end
// ---- NSToolbarSpaceItemIdentifier // ---- NSToolbarSpaceItemIdentifier
@interface GSToolbarSpaceItem : NSToolbarItem @interface NSToolbarSpaceItem : NSToolbarItem
{ {
} }
@end @end
@implementation GSToolbarSpaceItem @implementation NSToolbarSpaceItem
- (id) initWithItemIdentifier: (NSString *)itemIdentifier - (id) initWithItemIdentifier: (NSString *)itemIdentifier
{ {
self = [super initWithItemIdentifier: itemIdentifier]; self = [super initWithItemIdentifier: itemIdentifier];
@ -1007,12 +1007,12 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
@end @end
// ---- NSToolbarFlexibleSpaceItemIdentifier // ---- NSToolbarFlexibleSpaceItemIdentifier
@interface GSToolbarFlexibleSpaceItem : NSToolbarItem @interface NSToolbarFlexibleSpaceItem : NSToolbarItem
{ {
} }
@end @end
@implementation GSToolbarFlexibleSpaceItem @implementation NSToolbarFlexibleSpaceItem
- (id) initWithItemIdentifier: (NSString *)itemIdentifier - (id) initWithItemIdentifier: (NSString *)itemIdentifier
{ {
self = [super initWithItemIdentifier: itemIdentifier]; self = [super initWithItemIdentifier: itemIdentifier];
@ -1167,25 +1167,25 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
{ {
// GNUstep predefined toolbar items // GNUstep predefined toolbar items
if ([itemIdentifier isEqualToString: NSToolbarSeparatorItemIdentifier] if ([itemIdentifier isEqualToString: NSToolbarSeparatorItemIdentifier]
&& [self isKindOfClass: [GSToolbarSeparatorItem class]] == NO) && [self isKindOfClass: [NSToolbarSeparatorItem class]] == NO)
{ {
RELEASE(self); RELEASE(self);
return [[GSToolbarSeparatorItem alloc] return [[NSToolbarSeparatorItem alloc]
initWithItemIdentifier: itemIdentifier]; initWithItemIdentifier: itemIdentifier];
} }
else if ([itemIdentifier isEqualToString: NSToolbarSpaceItemIdentifier] else if ([itemIdentifier isEqualToString: NSToolbarSpaceItemIdentifier]
&& [self isKindOfClass: [GSToolbarSpaceItem class]] == NO) && [self isKindOfClass: [NSToolbarSpaceItem class]] == NO)
{ {
RELEASE(self); RELEASE(self);
return [[GSToolbarSpaceItem alloc] return [[NSToolbarSpaceItem alloc]
initWithItemIdentifier: itemIdentifier]; initWithItemIdentifier: itemIdentifier];
} }
else if ([itemIdentifier else if ([itemIdentifier
isEqualToString: NSToolbarFlexibleSpaceItemIdentifier] isEqualToString: NSToolbarFlexibleSpaceItemIdentifier]
&& [self isKindOfClass: [GSToolbarFlexibleSpaceItem class]] == NO) && [self isKindOfClass: [NSToolbarFlexibleSpaceItem class]] == NO)
{ {
RELEASE(self); RELEASE(self);
return [[GSToolbarFlexibleSpaceItem alloc] return [[NSToolbarFlexibleSpaceItem alloc]
initWithItemIdentifier: itemIdentifier]; initWithItemIdentifier: itemIdentifier];
} }
else if ([itemIdentifier else if ([itemIdentifier
@ -1645,4 +1645,39 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
{ {
return [NSString stringWithFormat: @"<%@ - <%@>>",[super description],[self itemIdentifier]]; return [NSString stringWithFormat: @"<%@ - <%@>>",[super description],[self itemIdentifier]];
} }
- (id) initWithCoder: (NSCoder *)aCoder
{
self = [self initWithItemIdentifier: [aCoder decodeObjectForKey:@"NSToolbarItemIdentifier"]];
if ([aCoder containsValueForKey: @"NSToolbarItemTarget"])
[self setTarget: [aCoder decodeObjectForKey:@"NSToolbarItemTarget"]];
if ([aCoder containsValueForKey: @"NSToolbarItemAction"])
[self setAction: NSSelectorFromString([aCoder decodeObjectForKey:@"NSToolbarItemAction"])];
if ([aCoder containsValueForKey: @"NSToolbarItemToolTip"])
[self setToolTip: [aCoder decodeObjectForKey:@"NSToolbarItemToolTip"]];
if ([aCoder containsValueForKey: @"NSToolbarItemTag"])
[self setTag: [aCoder decodeIntForKey:@"NSToolbarItemTag"]];
if ([aCoder containsValueForKey: @"NSToolbarItemImage"])
[self setImage: [aCoder decodeObjectForKey:@"NSToolbarItemImage"]];
if ([aCoder containsValueForKey: @"NSToolbarItemEnabled"])
[self setEnabled: [aCoder decodeBoolForKey:@"NSToolbarItemEnabled"]];
if ([aCoder containsValueForKey: @"NSToolbarItemPaletteLabel"])
[self setPaletteLabel: [aCoder decodeObjectForKey:@"NSToolbarItemPaletteLabel"]];
if ([aCoder containsValueForKey: @"NSToolbarItemLabel"])
[self setLabel: [aCoder decodeObjectForKey:@"NSToolbarItemLabel"]];
if ([aCoder containsValueForKey: @"NSToolbarItemMinSize"])
[self setMinSize: NSSizeFromString([aCoder decodeObjectForKey:@"NSToolbarItemMinSize"])];
if ([aCoder containsValueForKey: @"NSToolbarItemMaxSize"])
[self setMaxSize: NSSizeFromString([aCoder decodeObjectForKey:@"NSToolbarItemMaxSize"])];
if ([aCoder containsValueForKey: @"NSToolbarItemAutovalidates"])
[self setAutovalidates: [aCoder decodeBoolForKey:@"NSToolbarItemAutovalidates"]];
if ([aCoder containsValueForKey: @"NSToolbarItemVisibilityPriority"])
[self setVisibilityPriority: [aCoder decodeIntForKey:@"NSToolbarItemVisibilityPriority"]];
if ([aCoder containsValueForKey: @"NSToolbarItemView"])
[self setView: [aCoder decodeObjectForKey: @"NSToolbarItemView"]];
return self;
}
@end @end