mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 18:10:38 +00:00
Added suport for model loading.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2665 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e46ccd1acf
commit
07252e51bb
33 changed files with 2684 additions and 43 deletions
89
Model/IMCustomObject.m
Normal file
89
Model/IMCustomObject.m
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
IMCustomObject.m
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Date: November 1997
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObjCRuntime.h>
|
||||
#include <extensions/GMArchiver.h>
|
||||
#include "IMCustomObject.h"
|
||||
|
||||
@implementation NSObject(ModelUnarchiving)
|
||||
|
||||
- (id)nibInstantiate
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation IMCustomObject
|
||||
|
||||
extern id _nibOwner;
|
||||
extern BOOL _fileOwnerDecoded;
|
||||
|
||||
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
|
||||
{
|
||||
IMCustomObject* customObject = [[self new] autorelease];
|
||||
Class class;
|
||||
|
||||
customObject->className = [unarchiver decodeStringWithName:@"className"];
|
||||
customObject->extension = [unarchiver decodeObjectWithName:@"extension"];
|
||||
customObject->realObject = [unarchiver decodeObjectWithName:@"realObject"];
|
||||
|
||||
if (!_fileOwnerDecoded) {
|
||||
_fileOwnerDecoded = YES;
|
||||
customObject->realObject = _nibOwner;
|
||||
return customObject;
|
||||
}
|
||||
|
||||
class = NSClassFromString (customObject->className);
|
||||
if (class)
|
||||
customObject->realObject = [[class alloc] init];
|
||||
else {
|
||||
NSLog (@"Class %@ not linked into application!", customObject->className);
|
||||
}
|
||||
|
||||
return customObject;
|
||||
}
|
||||
|
||||
- (id)nibInstantiate
|
||||
{
|
||||
return realObject;
|
||||
}
|
||||
|
||||
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
|
||||
{
|
||||
[archiver encodeString:className withName:@"className"];
|
||||
if (realObject)
|
||||
[archiver encodeObject:realObject withName:@"realObject"];
|
||||
if (extension)
|
||||
[archiver encodeObject:extension withName:@"extension"];
|
||||
}
|
||||
|
||||
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue