Better unpacking of nib.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3569 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-01-17 08:14:03 +00:00
parent e18717400a
commit a1947434d8
2 changed files with 62 additions and 0 deletions

View file

@ -79,6 +79,15 @@
toName: (NSString*)targetName;
@end
@interface GSNibItem : NSObject
{
NSString *theClass;
NSRect frame;
BOOL hasFrame;
NSMutableArray *settings;
}
@end
#endif /* NO_GNUSTEP */
#endif // _GNUstep_H_NSNibLoading

View file

@ -29,13 +29,16 @@
#include <gnustep/gui/config.h>
#include <Foundation/NSArchiver.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSString.h>
#include <AppKit/NSView.h>
#include <AppKit/NSNibLoading.h>
@implementation NSBundle (NSBundleAdditions)
@ -295,3 +298,53 @@
}
@end
@implementation GSNibItem
- (void) dealloc
{
[theClass release];
[settings release];
[self dealloc];
}
- (id) init
{
self = [super init];
if (self)
{
settings = [[NSMutableArray alloc] initWithCapacity: 0];
}
return self;
}
- (id) initWithCoder: (NSCoder*)aCoder
{
id obj;
Class cls;
unsigned i;
self = [super initWithCoder: aCoder];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &hasFrame];
frame = [aCoder decodeRect];
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
[aCoder decodeValueOfObjCType: @encode(id) at: &settings];
cls = NSClassFromString(theClass);
obj = [cls allocWithZone: [self zone]];
if (hasFrame)
obj = [obj initWithFrame: frame];
else
obj = [obj init];
for (i = 0; i < [settings count]; i++)
{
NSInvocation *inv = [settings objectAtIndex: i];
[inv setTarget: obj];
[inv invoke];
}
[self release];
return obj;
}
@end