mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:00:46 +00:00
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:
parent
e01cdd4cd1
commit
88160ba733
4 changed files with 27 additions and 37 deletions
|
@ -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>
|
2009-01-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSTheme.m:
|
* Source/GSTheme.m:
|
||||||
|
|
|
@ -325,7 +325,6 @@ static void initSystemExtensionsColors(void)
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
RELEASE(_toolbar);
|
|
||||||
RELEASE(_clippedItemsMark);
|
RELEASE(_clippedItemsMark);
|
||||||
RELEASE(_clipView);
|
RELEASE(_clipView);
|
||||||
|
|
||||||
|
@ -567,11 +566,7 @@ static void initSystemExtensionsColors(void)
|
||||||
if (_toolbar == toolbar)
|
if (_toolbar == toolbar)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// We unset the toolbar view from the previous toolbar
|
_toolbar = toolbar;
|
||||||
[_toolbar _setToolbarView: nil];
|
|
||||||
ASSIGN(_toolbar, toolbar);
|
|
||||||
// We set the toolbar view on the new toolbar
|
|
||||||
[_toolbar _setToolbarView: self];
|
|
||||||
|
|
||||||
[_clippedItemsMark setToolbar: _toolbar];
|
[_clippedItemsMark setToolbar: _toolbar];
|
||||||
// Load the toolbar in the toolbar view
|
// Load the toolbar in the toolbar view
|
||||||
|
|
|
@ -546,8 +546,7 @@ static GSValidationCenter *vc = nil;
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
//NSLog(@"Toolbar dealloc %@", self);
|
//NSLog(@"Toolbar dealloc %@", self);
|
||||||
|
[self _setToolbarView: nil];
|
||||||
[vc removeObserver: self window: nil];
|
|
||||||
|
|
||||||
// Use DESTROY ?
|
// Use DESTROY ?
|
||||||
RELEASE(_identifier);
|
RELEASE(_identifier);
|
||||||
|
@ -567,10 +566,8 @@ static GSValidationCenter *vc = nil;
|
||||||
// FIXME: Hack
|
// FIXME: Hack
|
||||||
- (void) release
|
- (void) release
|
||||||
{
|
{
|
||||||
// We currently only worry about when our toolbar view is deallocated.
|
// When a toolbar has no external references any more, it's necessary
|
||||||
// Views which belongs to a window which is deallocated, are released.
|
// to remove the toolbar from the master list, so that it
|
||||||
// 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
|
|
||||||
// doesn't cause a memory leak.
|
// doesn't cause a memory leak.
|
||||||
if ([self retainCount] == 2)
|
if ([self retainCount] == 2)
|
||||||
[toolbars removeObjectIdenticalTo: self];
|
[toolbars removeObjectIdenticalTo: self];
|
||||||
|
@ -1206,18 +1203,24 @@ static GSValidationCenter *vc = nil;
|
||||||
|
|
||||||
- (void) _setToolbarView: (GSToolbarView *)toolbarView
|
- (void) _setToolbarView: (GSToolbarView *)toolbarView
|
||||||
{
|
{
|
||||||
|
if (_toolbarView == toolbarView)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_toolbarView != nil)
|
if (_toolbarView != nil)
|
||||||
{
|
{
|
||||||
|
// We unset the toolbar from the previous toolbar view
|
||||||
|
[_toolbarView setToolbar: nil];
|
||||||
[vc removeObserver: self window: nil];
|
[vc removeObserver: self window: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't do an ASSIGN here, the toolbar itself retains us.
|
ASSIGN(_toolbarView, toolbarView);
|
||||||
_toolbarView = toolbarView;
|
|
||||||
|
|
||||||
if (toolbarView != nil)
|
if (toolbarView != nil)
|
||||||
{
|
{
|
||||||
[vc addObserver: self window: [toolbarView window]];
|
|
||||||
// In the case the window parameter is a nil value, nothing happens.
|
// 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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,11 +60,6 @@
|
||||||
[_wv addToolbarView: [toolbar _toolbarView]];
|
[_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];
|
[toolbar setVisible: !isVisible];
|
||||||
|
|
||||||
[self display];
|
[self display];
|
||||||
|
@ -84,16 +79,11 @@
|
||||||
|
|
||||||
if (_toolbar != nil)
|
if (_toolbar != nil)
|
||||||
{
|
{
|
||||||
GSToolbarView *toolbarView = [_toolbar _toolbarView];
|
|
||||||
|
|
||||||
// We throw the last toolbar out
|
// We throw the last toolbar out
|
||||||
if ([_toolbar isVisible])
|
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);
|
ASSIGN(_toolbar, toolbar);
|
||||||
|
@ -102,27 +92,22 @@
|
||||||
{
|
{
|
||||||
GSToolbarView *toolbarView = [toolbar _toolbarView];
|
GSToolbarView *toolbarView = [toolbar _toolbarView];
|
||||||
|
|
||||||
if (toolbarView != nil)
|
if (toolbarView == nil)
|
||||||
{
|
|
||||||
NSLog(@"Error: the new toolbar is still owned by a toolbar view");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Instantiate the toolbar view
|
// Instantiate the toolbar view
|
||||||
// FIXME: Currently this is reatined until the toolbar
|
|
||||||
// gets removed from the window.
|
|
||||||
toolbarView = [[GSToolbarView alloc]
|
toolbarView = [[GSToolbarView alloc]
|
||||||
initWithFrame:
|
initWithFrame:
|
||||||
NSMakeRect(0, 0,
|
NSMakeRect(0, 0,
|
||||||
[NSWindow contentRectForFrameRect: [self frame]
|
[NSWindow contentRectForFrameRect: [self frame]
|
||||||
styleMask: [self styleMask]].size.width, 100)];
|
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
|
// frame
|
||||||
[toolbarView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
[toolbarView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||||
[toolbarView setBorderMask: GSToolbarViewBottomBorder];
|
[toolbarView setBorderMask: GSToolbarViewBottomBorder];
|
||||||
// Load the toolbar inside the toolbar view
|
|
||||||
// Will set the _toolbarView variable for the toolbar
|
// Load the toolbar view inside the toolbar
|
||||||
[toolbarView setToolbar: toolbar];
|
[toolbar _setToolbarView: toolbarView];
|
||||||
|
RELEASE(toolbarView);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the toolbar view visible
|
// Make the toolbar view visible
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue