diff --git a/ChangeLog b/ChangeLog index 02e88b289..eb27dc8e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,14 @@ -2009-01-10 Richard Frith-Macdonald +2009-01-01 Fred Kiefer + + * Headers/Additions/GNUstepGUI/GSToolbar.h, + * Source/GSToolbar.m, + * Source/NSToolbar.m: Remove unused initializer. + * Source/GSToolbarView.m: Remove method _setToolbar:, code is now + in setToolbar:. + * Source/NSWindow+Toolbar.m (-setToolbar:): Adopt to changes in + GSToolbarView. + +2009-01-01 Richard Frith-Macdonald * Headers/Additions/GNUstepGUI/GSTheme.h: * Source/GSTheme.m: diff --git a/Headers/Additions/GNUstepGUI/GSToolbar.h b/Headers/Additions/GNUstepGUI/GSToolbar.h index 93a6ef0df..18db0eafd 100644 --- a/Headers/Additions/GNUstepGUI/GSToolbar.h +++ b/Headers/Additions/GNUstepGUI/GSToolbar.h @@ -85,10 +85,6 @@ APPKIT_EXPORT NSString *NSToolbarWillAddItemNotification; // Instance methods - (id) initWithIdentifier: (NSString*)identifier; -- (id) initWithIdentifier: (NSString *)identifier - displayMode: (NSToolbarDisplayMode)displayMode - sizeMode: (NSToolbarSizeMode)sizeMode; - - (void) insertItemWithItemIdentifier: (NSString*)itemIdentifier atIndex: (int)index; - (void) removeItemAtIndex: (int)index; - (void) runCustomizationPalette: (id)sender; diff --git a/Source/GSToolbar.m b/Source/GSToolbar.m index ca215c7e6..337befaed 100644 --- a/Source/GSToolbar.m +++ b/Source/GSToolbar.m @@ -474,7 +474,6 @@ static GSValidationCenter *vc = nil; // Private class method -+ (NSArray *) _toolbars; + (NSArray *) _toolbarsWithIdentifier: (NSString *)identifier; - (void) _insertItemWithItemIdentifier: (NSString *)itemIdentifier @@ -546,11 +545,6 @@ static GSValidationCenter *vc = nil; // Private class method to access static variable toolbars in subclasses -+ (NSArray *) _toolbars -{ - return toolbars; -} - + (NSArray *) _toolbarsWithIdentifier: (NSString *)identifier { return [toolbars objectsWithValue: identifier @@ -559,18 +553,8 @@ static GSValidationCenter *vc = nil; // Instance methods -- (id) initWithIdentifier: (NSString *)identifier -{ - return [self initWithIdentifier: identifier - displayMode: NSToolbarDisplayModeIconAndLabel - sizeMode: NSToolbarSizeModeRegular]; -} - - // default initialiser -- (id) initWithIdentifier: (NSString *)identifier - displayMode: (NSToolbarDisplayMode)displayMode - sizeMode: (NSToolbarSizeMode)sizeMode +- (id) initWithIdentifier: (NSString *)identifier { GSToolbar *toolbarModel; @@ -589,12 +573,8 @@ static GSValidationCenter *vc = nil; _allowsUserCustomization = [toolbarModel allowsUserCustomization]; _autosavesConfiguration = [toolbarModel autosavesConfiguration]; ASSIGN(_configurationDictionary, [toolbarModel configurationDictionary]); - - if ([toolbarModel displayMode] != displayMode - && [toolbarModel sizeMode] != sizeMode) - { - // Raise an exception. - } + _displayMode = [toolbarModel displayMode]; + _sizeMode = [toolbarModel sizeMode]; // [self _loadConfig]; } @@ -604,14 +584,15 @@ static GSValidationCenter *vc = nil; _allowsUserCustomization = NO; _autosavesConfiguration = NO; _configurationDictionary = nil; + _displayMode = NSToolbarDisplayModeIconAndLabel; + _sizeMode = NSToolbarSizeModeRegular; // [self _loadConfig]; } - _displayMode = displayMode; - _sizeMode = sizeMode; _delegate = nil; + // Store in list of toolbars [toolbars addObject: self]; return self; @@ -638,6 +619,7 @@ static GSValidationCenter *vc = nil; [super dealloc]; } +// FIXME: Hack - (void) release { // We currently only worry about when our toolbar view is deallocated. @@ -651,10 +633,6 @@ static GSValidationCenter *vc = nil; [super release]; } -/* - * FIXME: Replace the deprecated method which follows by this one when -base - * NSObject will implement it. - * - (id) valueForUndefinedKey: (NSString *)key { if ([key isEqualToString: @"window"] || [key isEqualToString: @"_window"]) @@ -662,15 +640,6 @@ static GSValidationCenter *vc = nil; return [super valueForUndefinedKey: key]; } - */ - -- (id) handleQueryWithUnboundKey: (NSString *)key -{ - if ([key isEqualToString: @"window"] || [key isEqualToString: @"_window"]) - return [NSNull null]; - - return [super handleQueryWithUnboundKey: key]; -} - (void) insertItemWithItemIdentifier: (NSString *)itemIdentifier atIndex: (int)index diff --git a/Source/GSToolbarView.m b/Source/GSToolbarView.m index bef2eb6c4..80e9a75c4 100644 --- a/Source/GSToolbarView.m +++ b/Source/GSToolbarView.m @@ -178,7 +178,6 @@ static void initSystemExtensionsColors(void) - (void) _handleBackViewsFrame; - (void) _handleViewsVisibility; - (void) _reload; -- (void) _setToolbar: (GSToolbar *)toolbar; - (void) _takeInAccountFlexibleSpaces; - (int) _insertionIndexAtPoint: (NSPoint)location; @@ -659,13 +658,21 @@ static void initSystemExtensionsColors(void) - (void) setToolbar: (GSToolbar *)toolbar { - if ([toolbar isKindOfClass: NSClassFromString(@"NSToolbar")]) - [NSException raise: NSInvalidArgumentException - format: @"NSToolbar instance can't be attached directly to a \ - toolbar view, setToolbar: from the NSWindow toolbar \ - category must be used."]; - - [self _setToolbar: toolbar]; + if ([toolbar sizeMode] != _sizeMode) + ; // FIXME: Raise exception here + + if (_toolbar == toolbar) + return; + + // We unset the toolbar view from the previous toolbar + [_toolbar _setToolbarView: nil]; + ASSIGN(_toolbar, toolbar); + // We set the toolbar view on the new toolbar + [_toolbar _setToolbarView: self]; + + [_clippedItemsMark setToolbar: _toolbar]; + // Load the toolbar in the toolbar view + [self _reload]; } - (NSColor *) standardBackgroundColor @@ -821,21 +828,6 @@ static void initSystemExtensionsColors(void) [self setNeedsDisplay: YES]; } -- (void) _setToolbar: (GSToolbar *)toolbar -{ - if ([toolbar sizeMode] != _sizeMode) - ; // FIXME: Raise exception here - - [toolbar _setToolbarView: self]; // We set the toolbar view on the new toolbar - [_toolbar _setToolbarView: nil]; // We unset the toolbar view from the previous toolbar - - ASSIGN(_toolbar, toolbar); - - [_clippedItemsMark setToolbar: _toolbar]; - - [self _reload]; // Load the toolbar in the toolbar view -} - - (void) _takeInAccountFlexibleSpaces { NSArray *items = [_toolbar items]; diff --git a/Source/NSToolbar.m b/Source/NSToolbar.m index 78ca53642..b452132db 100644 --- a/Source/NSToolbar.m +++ b/Source/NSToolbar.m @@ -93,14 +93,10 @@ static const int current_version = 1; // Instance methods - (id) initWithIdentifier: (NSString *)identifier - displayMode: (NSToolbarDisplayMode)displayMode - sizeMode: (NSToolbarSizeMode)sizeMode { NSToolbar *toolbarModel = nil; - if ((self = [super initWithIdentifier: identifier - displayMode: displayMode - sizeMode: sizeMode]) == nil) + if ((self = [super initWithIdentifier: identifier]) == nil) { return nil; } @@ -109,14 +105,10 @@ static const int current_version = 1; if (toolbarModel != nil) { - _displayMode = [toolbarModel displayMode]; - _sizeMode = [toolbarModel sizeMode]; _visible = [toolbarModel isVisible]; } else { - _displayMode = displayMode; - _sizeMode = sizeMode; _visible = YES; } diff --git a/Source/NSWindow+Toolbar.m b/Source/NSWindow+Toolbar.m index 946a007a2..8978bbc1c 100644 --- a/Source/NSWindow+Toolbar.m +++ b/Source/NSWindow+Toolbar.m @@ -39,7 +39,6 @@ @end @interface GSToolbarView (GNUstepPrivate) -- (void) _setToolbar: (NSToolbar *)toolbar; - (float) _heightFromLayout; - (void) _reload; @end @@ -135,7 +134,7 @@ { [self _toggleToolbarView]; } - [toolbarView _setToolbar: nil]; + [toolbarView setToolbar: nil]; // Release the toolbarView, this will release the toolbar RELEASE(toolbarView); } @@ -164,7 +163,7 @@ [toolbarView setBorderMask: GSToolbarViewBottomBorder]; // Load the toolbar inside the toolbar view // Will set the _toolbarView variable for the toolbar - [toolbarView _setToolbar: toolbar]; + [toolbarView setToolbar: toolbar]; } // Make the toolbar view visible