Revert the relationship between NSToolbar and GSToolbarView,

now the toolbar retains the view.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27550 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-01-07 08:49:53 +00:00
parent aca8c4b62c
commit ec783dc3b3
4 changed files with 27 additions and 37 deletions

View file

@ -1,3 +1,10 @@
2009-01-07 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSWindow+Toolbar.m,
* Source/NSToolbar.m,
* Source/GSToolbarView.m: Revert the relationship between
NSToolbar and GSToolbarView, now the toolbar retains the view.
2009-01-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTheme.m:

View file

@ -325,7 +325,6 @@ static void initSystemExtensionsColors(void)
[[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(_toolbar);
RELEASE(_clippedItemsMark);
RELEASE(_clipView);
@ -567,11 +566,7 @@ static void initSystemExtensionsColors(void)
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];
_toolbar = toolbar;
[_clippedItemsMark setToolbar: _toolbar];
// Load the toolbar in the toolbar view

View file

@ -546,8 +546,7 @@ static GSValidationCenter *vc = nil;
- (void) dealloc
{
//NSLog(@"Toolbar dealloc %@", self);
[vc removeObserver: self window: nil];
[self _setToolbarView: nil];
// Use DESTROY ?
RELEASE(_identifier);
@ -567,10 +566,8 @@ static GSValidationCenter *vc = nil;
// FIXME: Hack
- (void) release
{
// We currently only worry about when our toolbar view is deallocated.
// Views which belongs to a window which is deallocated, are released.
// In such case, it's necessary to remove the toolbar which belongs to this
// view from the master list when nobody else still retains us, so that it
// When a toolbar has no external references any more, it's necessary
// to remove the toolbar from the master list, so that it
// doesn't cause a memory leak.
if ([self retainCount] == 2)
[toolbars removeObjectIdenticalTo: self];
@ -1206,18 +1203,24 @@ static GSValidationCenter *vc = nil;
- (void) _setToolbarView: (GSToolbarView *)toolbarView
{
if (_toolbarView == toolbarView)
return;
if (_toolbarView != nil)
{
// We unset the toolbar from the previous toolbar view
[_toolbarView setToolbar: nil];
[vc removeObserver: self window: nil];
}
// Don't do an ASSIGN here, the toolbar itself retains us.
_toolbarView = toolbarView;
ASSIGN(_toolbarView, toolbarView);
if (toolbarView != nil)
{
[vc addObserver: self window: [toolbarView window]];
// In the case the window parameter is a nil value, nothing happens.
[vc addObserver: self window: [toolbarView window]];
// We set the toolbar on the new toolbar view
[_toolbarView setToolbar: self];
}
}

View file

@ -60,11 +60,6 @@
[_wv addToolbarView: [toolbar _toolbarView]];
}
// Important to set _visible after the toolbar view has been toggled because
// NSWindow method _contentViewWithoutToolbar uses [NSToolbar visible]
// when we toggle the toolbar
// example : the toolbar needs to be still known visible in order to hide
// it.
[toolbar setVisible: !isVisible];
[self display];
@ -84,16 +79,11 @@
if (_toolbar != nil)
{
GSToolbarView *toolbarView = [_toolbar _toolbarView];
// We throw the last toolbar out
if ([_toolbar isVisible])
{
[_wv removeToolbarView: toolbarView];
[_wv removeToolbarView: [_toolbar _toolbarView]];
}
[toolbarView setToolbar: nil];
// Release the toolbarView, this may release the toolbar
RELEASE(toolbarView);
}
ASSIGN(_toolbar, toolbar);
@ -102,27 +92,22 @@
{
GSToolbarView *toolbarView = [toolbar _toolbarView];
if (toolbarView != nil)
{
NSLog(@"Error: the new toolbar is still owned by a toolbar view");
}
else
if (toolbarView == nil)
{
// Instantiate the toolbar view
// FIXME: Currently this is reatined until the toolbar
// gets removed from the window.
toolbarView = [[GSToolbarView alloc]
initWithFrame:
NSMakeRect(0, 0,
[NSWindow contentRectForFrameRect: [self frame]
styleMask: [self styleMask]].size.width, 100)];
// _toggleToolbarView method will set the toolbar view to the right
// addToolbarView: method will set the toolbar view to the right
// frame
[toolbarView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
[toolbarView setBorderMask: GSToolbarViewBottomBorder];
// Load the toolbar inside the toolbar view
// Will set the _toolbarView variable for the toolbar
[toolbarView setToolbar: toolbar];
// Load the toolbar view inside the toolbar
[toolbar _setToolbarView: toolbarView];
RELEASE(toolbarView);
}
// Make the toolbar view visible