diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 3408769ad..7f02b307b 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -182,10 +182,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; SEL _doubleAction; unsigned _columnAutoResizingStyle; - BOOL _verticalMotionCanDrag; +// BOOL _verticalMotionCanDrag; unsigned _destinationDragStyle; BOOL _isSelectingSession; - CPIndexSet _draggedRowIndexes; +// CPIndexSet _draggedRowIndexes; _dropOperationDrawingView _dropOperationFeedbackView; CPDragOperation _dragOperationDefaultMask; int _retargetedDropRow; @@ -241,9 +241,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; _selectedColumnIndexes = [CPIndexSet indexSet]; _selectedRowIndexes = [CPIndexSet indexSet]; - - _draggedRowIndexes = [CPIndexSet indexSet]; - _verticalMotionCanDrag = YES; +window.setTimeout(function(){ + self._draggedRowIndexes = [CPIndexSet indexSet]; + self._verticalMotionCanDrag = YES;}, 0); _destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular; _dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()]; [self addSubview:_dropOperationFeedbackView]; diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 04024632e..0917ce948 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -220,7 +220,7 @@ var CPToolbarConfigurationsByIdentifier = nil; */ - (void)setDelegate:(id)aDelegate { - if (_delegate == aDelegate) + if (_delegate === aDelegate) return; _delegate = aDelegate; @@ -252,16 +252,22 @@ var CPToolbarConfigurationsByIdentifier = nil; /* @ignore */ - (void)_reloadToolbarItems { - if (!_delegate) - return; + // As of OS X 10.5 (Leopard), toolbar items can be set in IB and a + // toolbar delegate is optional. Toolbar items can be combined from + // both IB and a delegate (see Apple's NSToolbar guide for IB, for more details). + + // _defaultItems may have been loaded from Cib + _itemIdentifiers = [_defaultItems valueForKey:@"itemIdentifier"] || []; + + if (_delegate) + { + var itemIdentifiersFromDelegate = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy]; + + if (itemIdentifiersFromDelegate) + _itemIdentifiers = [_itemIdentifiers arrayByAddingObjectsFromArray:itemIdentifiersFromDelegate]; + } var count = [_itemIdentifiers count]; - - if (!count) - { - _itemIdentifiers = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy]; - count = [_itemIdentifiers count]; - } _items = []; @@ -272,14 +278,20 @@ var CPToolbarConfigurationsByIdentifier = nil; var identifier = _itemIdentifiers[index], item = [CPToolbarItem _standardItemWithItemIdentifier:identifier]; + // May come from a Cib. if (!item) + item = [_identifiedItems objectForKey:identifier]; + + if (!item && _delegate) item = [_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES]; - + item = [item copy]; - - if (item == nil) + + if (item === nil) [CPException raise:CPInvalidArgumentException - reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)]; + reason:@"Toolbar delegate " + _delegate + " returned nil toolbar item for identifier \"" + identifier + "\""]; + + item._toolbar = self; [_items addObject:item]; } @@ -288,9 +300,9 @@ var CPToolbarConfigurationsByIdentifier = nil; // Store items sorted by priority. We want items to be removed first at the end of the array, // items to be removed last at the front. - + _itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL]; - + [_toolbarView reloadToolbarItems]; } @@ -359,28 +371,62 @@ var CPToolbarConfigurationsByIdentifier = nil; } /* @ignore */ --(id)_defaultToolbarItems +- (id)_defaultToolbarItems { - if (!_defaultItems) - if ([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)]) - _defaultItems = [self _itemsWithIdentifiers:[_delegate toolbarDefaultItemIdentifiers:self]]; - + if (!_defaultItems && [_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)]) + { + _defaultItems = []; + + var identifiers = [_delegate toolbarDefaultItemIdentifiers:self], + index = 0, + count = [identifiers count]; + + for (; index < count; ++index) + [_defaultItems addObject:[self _itemForItemIdentifier:identifiers[index] willBeInsertedIntoToolbar:NO]]; + } + return _defaultItems; } +/*! + Notifies the toolbar that an item has been changed. This will cause the toolbar to reload its items. + @param anItem the item that has been changed +*/ +- (void)toolbarItemDidChange:(CPToolbarItem)anItem +{ + if ([_identifiedItems objectForKey:[anItem itemIdentifier]]) + [_identifiedItems setObject:anItem forKey:[anItem itemIdentifier]]; + + var index = 0, + count = [_items count]; + + for (; index <= count; ++index) + { + var item = _items[index]; + + if ([item itemIdentifier] === [anItem itemIdentifier]) + { + _items[index] = anItem; + _itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL]; + + [_toolbarView reloadToolbarItems]; + } + } +} + @end -var CPToolbarIdentifierKey = "CPToolbarIdentifierKey", - CPToolbarDisplayModeKey = "CPToolbarDisplayModeKey", - CPToolbarShowsBaselineSeparatorKey = "CPToolbarShowsBaselineSeparatorKey", - CPToolbarAllowsUserCustomizationKey = "CPToolbarAllowsUserCustomizationKey", - CPToolbarIsVisibleKey = "CPToolbarIsVisibleKey", - CPToolbarDelegateKey = "CPToolbarDelegateKey", - CPToolbarIdentifiedItemsKey = "CPToolbarIdentifiedItemsKey", - CPToolbarDefaultItemsKey = "CPToolbarDefaultItemsKey", - CPToolbarAllowedItemsKey = "CPToolbarAllowedItemsKey", - CPToolbarSelectableItemsKey = "CPToolbarSelectableItemsKey"; +var CPToolbarIdentifierKey = @"CPToolbarIdentifierKey", + CPToolbarDisplayModeKey = @"CPToolbarDisplayModeKey", + CPToolbarShowsBaselineSeparatorKey = @"CPToolbarShowsBaselineSeparatorKey", + CPToolbarAllowsUserCustomizationKey = @"CPToolbarAllowsUserCustomizationKey", + CPToolbarIsVisibleKey = @"CPToolbarIsVisibleKey", + CPToolbarDelegateKey = @"CPToolbarDelegateKey", + CPToolbarIdentifiedItemsKey = @"CPToolbarIdentifiedItemsKey", + CPToolbarDefaultItemsKey = @"CPToolbarDefaultItemsKey", + CPToolbarAllowedItemsKey = @"CPToolbarAllowedItemsKey", + CPToolbarSelectableItemsKey = @"CPToolbarSelectableItemsKey"; @implementation CPToolbar (CPCoding) @@ -394,23 +440,36 @@ var CPToolbarIdentifierKey = "CPToolbarIdentifierKey", if (self) { - _identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey]; - _displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey]; - _showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey]; - _allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey]; - _isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey]; - - _identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey]; - _defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey]; - _allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey]; - _selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey]; - + _identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey]; + _displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey]; + _showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey]; + _allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey]; + _isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey]; + + _identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey]; + _defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey]; + _allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey]; + _selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey]; + + [[_identifiedItems allValues] makeObjectsPerformSelector:@selector(_setToolbar:) withObject:self]; + _items = []; + [CPToolbar _addToolbar:self forIdentifier:_identifier]; - + + // This won't come from a Cib, but can come from manual encoding. [self setDelegate:[aCoder decodeObjectForKey:CPToolbarDelegateKey]]; + + // Because we don't know if a delegate will be set later (it is optional + // as of OS X 10.5), we need to call -_reloadToolbarItems here. + // In order to load any toolbar items that may have been configured in the + // Cib. Unfortunatelly this means that if there is a delegate + // specified, it will be read later and the resulting call to -setDelegate: + // will cause -_reloadToolbarItems] to run again :-( + // FIXME: Can we make this better? + [self _reloadToolbarItems]; } - + return self; } @@ -420,18 +479,18 @@ var CPToolbarIdentifierKey = "CPToolbarIdentifierKey", */ - (void)encodeWithCoder:(CPCoder)aCoder { - [aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey]; - [aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey]; - [aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey]; + [aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey]; + [aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey]; + [aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey]; [aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey]; - [aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey]; - - [aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey]; - [aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey]; - [aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey]; - [aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey]; - - [aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey]; + [aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey]; + + [aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey]; + [aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey]; + [aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey]; + [aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey]; + + [aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey]; } @end @@ -475,7 +534,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) + (void)initialize { - if (self != [_CPToolbarView class]) + if (self !== [_CPToolbarView class]) return; var bundle = [CPBundle bundleForClass:self]; @@ -774,7 +833,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) _minWidth += [view minSize].width + TOOLBAR_ITEM_MARGIN; } - + [self tile]; } @@ -837,7 +896,16 @@ var TOP_MARGIN = 5.0, _toolbar = aToolbar; - [_toolbarItem addObserver:self forKeyPath:"enabled" options:0 context:NULL]; + var keyPaths = [@"label", @"image", @"alternateImage", @"minSize", @"maxSize", @"enabled"], + index = 0, + count = [keyPaths count]; + + for (; index < count; ++index) + [_toolbarItem + addObserver:self + forKeyPath:keyPaths[index] + options:0 + context:NULL]; } return self; @@ -1032,9 +1100,10 @@ var TOP_MARGIN = 5.0, change:(CPDictionary)aChange context:(id)aContext { - // FIXME: Not clear if -synchronizeWindowTitleWithDocumentName is the best way to go. if (aKeyPath === "enabled") [self setEnabled:[anObject isEnabled]]; + else + [self updateFromItem]; } @end diff --git a/AppKit/CPToolbarItem.j b/AppKit/CPToolbarItem.j index 2cdd5528c..54e93c6b0 100644 --- a/AppKit/CPToolbarItem.j +++ b/AppKit/CPToolbarItem.j @@ -48,13 +48,13 @@ CPToolbarItemVisibilityPriorityHigh = 1000; */ CPToolbarItemVisibilityPriorityUser = 2000; -CPToolbarSeparatorItemIdentifier = @"CPToolbarSeparatorItemIdentifier"; -CPToolbarSpaceItemIdentifier = @"CPToolbarSpaceItemIdentifier"; -CPToolbarFlexibleSpaceItemIdentifier = @"CPToolbarFlexibleSpaceItemIdentifier"; -CPToolbarShowColorsItemIdentifier = @"CPToolbarShowColorsItemIdentifier"; -CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItemIdentifier"; -CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItemIdentifier"; -CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; +CPToolbarSeparatorItemIdentifier = @"CPToolbarSeparatorItem"; +CPToolbarSpaceItemIdentifier = @"CPToolbarSpaceItem"; +CPToolbarFlexibleSpaceItemIdentifier = @"CPToolbarFlexibleSpaceItem"; +CPToolbarShowColorsItemIdentifier = @"CPToolbarShowColorsItem"; +CPToolbarShowFontsItemIdentifier = @"CPToolbarShowFontsItem"; +CPToolbarCustomizeToolbarItemIdentifier = @"CPToolbarCustomizeToolbarItem"; +CPToolbarPrintItemIdentifier = @"CPToolbarPrintItem"; /*! @ingroup appkit @@ -65,9 +65,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; @implementation CPToolbarItem : CPObject { CPString _itemIdentifier; - + CPToolbar _toolbar; - + CPString _label; CPString _paletteLabel; CPString _toolTip; @@ -77,12 +77,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; BOOL _isEnabled; CPImage _image; CPImage _alternateImage; - + CPView _view; - + CGSize _minSize; CGSize _maxSize; - + int _visibilityPriority; BOOL _autovalidates; @@ -114,6 +114,7 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; _maxSize = CGSizeMakeZero(); _visibilityPriority = CPToolbarItemVisibilityPriorityStandard; + _autovalidates = YES; } return self; @@ -136,6 +137,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; return _toolbar; } +/* @ignore */ +- (void)_setToolbar:(CPToolbar)aToolbar +{ + _toolbar = aToolbar; +} + /*! Returns the item's label */ @@ -313,7 +320,12 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; _image = anImage; if (!_image) + { + if(_toolbar) + [_toolbar toolbarItemDidChange:self]; + return; + } if (_minSize.width == 0 && _minSize.height == 0 && _maxSize.width == 0 && _maxSize.height == 0) @@ -395,6 +407,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; */ - (void)setMinSize:(CGSize)aMinSize { + if(!aMinSize.height || !aMinSize.width) + return; + _minSize = CGSizeMakeCopy(aMinSize); // Try to provide some sanity: Make maxSize >= minSize @@ -415,6 +430,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; */ - (void)setMaxSize:(CGSize)aMaxSize { + if(!aMaxSize.height || !aMaxSize.width) + return; + _maxSize = CGSizeMakeCopy(aMaxSize); // Try to provide some sanity: Make minSize <= maxSize @@ -495,7 +513,7 @@ CPToolbarItemVisibilityPriorityUser @end -var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", +var CPToolbarItemItemIdentifierKey = @"CPToolbarItemItemIdentifierKey", CPToolbarItemLabelKey = @"CPToolbarItemLabelKey", CPToolbarItemPaletteLabelKey = @"CPToolbarItemPaletteLabelKey", CPToolbarItemToolTipKey = @"CPToolbarItemToolTipKey", @@ -508,7 +526,8 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", CPToolbarItemViewKey = @"CPToolbarItemViewKey", CPToolbarItemMinSizeKey = @"CPToolbarItemMinSizeKey", CPToolbarItemMaxSizeKey = @"CPToolbarItemMaxSizeKey", - CPToolbarItemVisibilityPriorityKey = @"CPToolbarItemVisibilityPriorityKey"; + CPToolbarItemVisibilityPriorityKey = @"CPToolbarItemVisibilityPriorityKey", + CPToolbarItemAutovalidatesKey = @"CPToolbarItemAutovalidatesKey"; @implementation CPToolbarItem (CPCoding) @@ -518,7 +537,10 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", if (self) { - _itemIdentifier = [aCoder decodeObjectForKey:CPToolbarItemIdentifierKey]; + _itemIdentifier = [aCoder decodeObjectForKey:CPToolbarItemItemIdentifierKey]; + + _minSize = [aCoder decodeSizeForKey:CPToolbarItemMinSizeKey]; + _maxSize = [aCoder decodeSizeForKey:CPToolbarItemMaxSizeKey]; [self setLabel:[aCoder decodeObjectForKey:CPToolbarItemLabelKey]]; [self setPaletteLabel:[aCoder decodeObjectForKey:CPToolbarItemPaletteLabelKey]]; @@ -535,10 +557,8 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", [self setView:[aCoder decodeObjectForKey:CPToolbarItemViewKey]]; - [self setMinSize:[aCoder decodeSizeForKey:CPToolbarItemMinSizeKey]]; - [self setMaxSize:[aCoder decodeSizeForKey:CPToolbarItemMaxSizeKey]]; - [self setVisibilityPriority:[aCoder decodeIntForKey:CPToolbarItemVisibilityPriorityKey]]; + [self setAutovalidates:[aCoder decodeBoolForKey:CPToolbarItemAutovalidatesKey]]; } return self; @@ -568,6 +588,7 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", [aCoder encodeSize:[self maxSize] forKey:CPToolbarItemMaxSizeKey]; [aCoder encodeObject:[self visibilityPriority] forKey:CPToolbarItemVisibilityPriorityKey]; + [aCoder encodeBool:[self autovalidates] forKey:CPToolbarItemAutovalidatesKey]; } @end @@ -577,10 +598,12 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", - (id)copy { var copy = [[[self class] alloc] initWithItemIdentifier:_itemIdentifier]; - + if (_view) [copy setView:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:_view]]]; - + + [copy _setToolbar:_toolbar]; + [copy setLabel:_label]; [copy setPaletteLabel:_paletteLabel]; [copy setToolTip:[self toolTip]]; @@ -588,7 +611,7 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", [copy setTag:[self tag]]; [copy setTarget:[self target]]; [copy setAction:[self action]]; - + [copy setEnabled:[self isEnabled]]; [copy setImage:[self image]]; @@ -596,9 +619,10 @@ var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", [copy setMinSize:_minSize]; [copy setMaxSize:_maxSize]; - - [copy setVisibilityPriority:_visibilityPriority]; - + + [copy setVisibilityPriority:[self visibilityPriority]]; + [copy setAutovalidates:[self autovalidates]]; + return copy; } diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index b6c4cda04..e6258e6e2 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -1,4 +1,4 @@ -/* + /* * NSAppKit.j * nib2cib * @@ -44,6 +44,7 @@ @import "NSResponder.j" @import "NSScrollView.j" @import "NSScroller.j" +@import "NSSearchField.j" @import "NSSet.j" @import "NSSecureTextField.j" @import "NSSegmentedControl.j" diff --git a/Tools/nib2cib/NSSearchField.j b/Tools/nib2cib/NSSearchField.j new file mode 100644 index 000000000..7ac04ac46 --- /dev/null +++ b/Tools/nib2cib/NSSearchField.j @@ -0,0 +1,61 @@ +/* + * NSSearchField.j + * nib2cib + * + * Created by Francisco Tolmasky. + * Copyright 2010, 280 North, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import +@import "NSTextField.j" + + +@implementation CPSearchField (NSCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + self = [super NS_initWithCoder:aCoder]; + + if (self) + { + } + + return self; +} + +@end + +@implementation NSSearchField : CPSearchField +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPSearchField class]; +} + +@end + +@implementation NSSearchFieldCell : NSTextFieldCell +{ +} +@end diff --git a/Tools/nib2cib/NSToolbarItem.j b/Tools/nib2cib/NSToolbarItem.j index 1fc82af08..76ab09665 100644 --- a/Tools/nib2cib/NSToolbarItem.j +++ b/Tools/nib2cib/NSToolbarItem.j @@ -2,8 +2,9 @@ * NSToolbarItem.j * nib2cib * - * Created by Francisco Tolmasky. + * Created by Francisco Tolmasky and Dimitris Tsitses. * Copyright 2010, 280 North, Inc. + * Copyright 2010, Blueberry Associates LLC. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,6 +24,17 @@ @import +NS_CPToolbarItemIdentifierMap = +{ + @"NSToolbarSeparatorItem" : CPToolbarSeparatorItemIdentifier, + @"NSToolbarSpaceItem" : CPToolbarSpaceItemIdentifier, + @"NSToolbarFlexibleSpaceItem" : CPToolbarFlexibleSpaceItemIdentifier, + @"NSToolbarShowColorsItem" : CPToolbarShowColorsItemIdentifier, + @"NSToolbarShowFontsItem" : CPToolbarShowFontsItemIdentifier, + @"NSToolbarCustomizeToolbarItem" : CPToolbarCustomizeToolbarItemIdentifier, + @"NSToolbarPrintItem" : CPToolbarPrintItemIdentifier +}; + @implementation CPToolbarItem (NSCoding) - (id)NS_initWithCoder:(CPCoder)aCoder @@ -31,7 +43,12 @@ if (self) { - _itemIdentifier = [aCoder decodeObjectForKey:@"NSToolbarItemIdentifier"]; + var NS_itemIdentifier = [aCoder decodeObjectForKey:@"NSToolbarItemIdentifier"]; + + _itemIdentifier = NS_CPToolbarItemIdentifierMap[NS_itemIdentifier] || NS_itemIdentifier; + + _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"] || CGSizeMakeZero(); + _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"] || CGSizeMakeZero(); [self setLabel:[aCoder decodeObjectForKey:@"NSToolbarItemLabel"]]; [self setPaletteLabel:[aCoder decodeObjectForKey:@"NSToolbarItemPaletteLabel"]]; @@ -47,10 +64,8 @@ [self setView:[aCoder decodeObjectForKey:@"NSToolbarItemView"]]; - _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"]; - _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"]; - [self setVisibilityPriority:[aCoder decodeIntForKey:@"NSToolbarItemVisibilityPriority"]]; + [self setAutovalidates:[aCoder decodeBoolForKey:"NSToolbarItemAutovalidates"]]; } return self; diff --git a/bootstrap.sh b/bootstrap.sh index 7a19b51a2..df2c06bb9 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -106,7 +106,7 @@ if [ "$install_narwhal" ]; then echo "To use the default location, \"$install_directory\", just hit enter/return, or enter another path:" read input if [ "$input" ]; then - install_directory="$input" + install_directory="`cd \`dirname $input\`; pwd`/`basename $input`" fi if [ "$git_clone" ]; then