From 6462d48f4ab7645937953d0f7239b896be48e919 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Wed, 19 Jul 2006 03:16:49 +0000 Subject: [PATCH] Added better error message to initWithCoder in GSNibContainer and also added code in GSNibCompatibility to fix superview and window settings after a window is loaded in the nib file. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23180 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 ++++++++++ Source/GSNibCompatibility.m | 40 +++++++++++++++++++++++++++++++++++++ Source/GSNibTemplates.m | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d49cfd443..44596e4fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-07-18 23:11-EDT Gregory John Casamento + + * Source/GSNibCompatibility.m: Added category on NSView and + _fixSubviews method to correct window and superview after + loading the nib file. The _fixSubviews method is called in + nibInstantiate. + * Source/GSNibTemplates.m: More helpful error message for when + decoding fails due to the user attempting to load a version of + GSNibContainer that the container doesn't know about in initWithCoder: + 2006-07-17 Enrico Sersale * Headers/AppKit/NSHelpManager.h: @@ -13,6 +23,7 @@ added a button to close the panel and changed the style mask of the window to NSTitledWindowMask | NSResizableWindowMask. +>>>>>>> .r23179 2006-07-15 Enrico Sersale * Headers/AppKit/AppKit.h: added NSHelpManager.h. diff --git a/Source/GSNibCompatibility.m b/Source/GSNibCompatibility.m index e50e6f130..de4d6f705 100644 --- a/Source/GSNibCompatibility.m +++ b/Source/GSNibCompatibility.m @@ -56,6 +56,38 @@ static BOOL _isInInterfaceBuilder = NO; +@interface NSView (NibCompatibility) +- (void) _fixSubviews; +@end + +@implementation NSView (NibCompatibility) +- (void) _setSuperview: (id) sv +{ + ASSIGN(_super_view,sv); +} + +- (void) _setWindow: (id) w +{ + ASSIGN(_window,w); +} + +- (void) _fixSubviews +{ + NSEnumerator *en = [[self subviews] objectEnumerator]; + id v = nil; + while((v = [en nextObject]) != nil) + { + if([v window] != [self window] || + [v superview] != self) + { + [v _setWindow: [self window]]; + [v _setSuperview: self]; + } + [v _fixSubviews]; + } +} +@end + @implementation NSWindowTemplate + (void) initialize { @@ -201,6 +233,12 @@ static BOOL _isInInterfaceBuilder = NO; } } +- (void) _fixSubviews +{ + id view = [_realObject contentView]; + [view _fixSubviews]; +} + - (id) nibInstantiate { if(_realObject == nil) @@ -250,6 +288,8 @@ static BOOL _isInInterfaceBuilder = NO; [_realObject setMaxSize: _maxSize]; [_realObject setTitle: _title]; + [self _fixSubviews]; + // resize the window... [_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect] styleMask: [self windowStyle]] diff --git a/Source/GSNibTemplates.m b/Source/GSNibTemplates.m index 855146c66..7334e244c 100644 --- a/Source/GSNibTemplates.m +++ b/Source/GSNibTemplates.m @@ -471,7 +471,7 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN else { [NSException raise: NSInternalInconsistencyException - format: @"Unable to read GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d.", version, GNUSTEP_NIB_VERSION]; + format: @"Unable to read GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d. Please upgrade to a more recent version of the gui library.", version, GNUSTEP_NIB_VERSION]; } return self;