mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 18:50:48 +00:00
Add keyed coding. This is still rather useless until we get a proper
implementation for -serializedRepresentation. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33294 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
61b0a0ae7b
commit
f29c54e66f
2 changed files with 65 additions and 46 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2011-06-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSFileWrapper.m: Add keyed coding.
|
||||||
|
|
||||||
2011-06-13 Eric Wasylishen <ewasylishen@gmail.com>
|
2011-06-13 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/NSBitmapImageRep.m: Reduce floating-point error in the
|
* Source/NSBitmapImageRep.m: Reduce floating-point error in the
|
||||||
|
|
|
@ -579,59 +579,74 @@
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_wrapperType];
|
if ([aCoder allowsKeyedCoding])
|
||||||
// Dont store the file name
|
{
|
||||||
[aCoder encodeObject: _preferredFilename];
|
[aCoder encodeObject: [self serializedRepresentation] forKey: @"NSFileWrapperData"];
|
||||||
[aCoder encodeObject: _fileAttributes];
|
}
|
||||||
[aCoder encodeObject: _wrapperData];
|
else
|
||||||
[aCoder encodeObject: _iconImage];
|
{
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(int) at: &_wrapperType];
|
||||||
|
// Dont store the file name
|
||||||
|
[aCoder encodeObject: _preferredFilename];
|
||||||
|
[aCoder encodeObject: _fileAttributes];
|
||||||
|
[aCoder encodeObject: _wrapperData];
|
||||||
|
[aCoder encodeObject: _iconImage];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
int wrapperType;
|
if ([aDecoder allowsKeyedCoding])
|
||||||
NSString *preferredFilename;
|
|
||||||
NSDictionary *fileAttributes;
|
|
||||||
id wrapperData;
|
|
||||||
NSImage *iconImage;
|
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &wrapperType];
|
|
||||||
// Dont restore the file name
|
|
||||||
preferredFilename = [aDecoder decodeObject];
|
|
||||||
fileAttributes = [aDecoder decodeObject];
|
|
||||||
wrapperData = [aDecoder decodeObject];
|
|
||||||
iconImage = [aDecoder decodeObject];
|
|
||||||
|
|
||||||
switch (wrapperType)
|
|
||||||
{
|
{
|
||||||
case GSFileWrapperRegularFileType:
|
NSData *data = [aDecoder decodeObjectForKey: @"NSFileWrapperData"];
|
||||||
{
|
return [self initWithSerializedRepresentation: data];
|
||||||
self = [self initRegularFileWithContents: wrapperData];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GSFileWrapperSymbolicLinkType:
|
|
||||||
{
|
|
||||||
self = [self initSymbolicLinkWithDestination: wrapperData];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GSFileWrapperDirectoryType:
|
|
||||||
{
|
|
||||||
self = [self initDirectoryWithFileWrappers: wrapperData];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (preferredFilename != nil)
|
|
||||||
{
|
{
|
||||||
[self setPreferredFilename: preferredFilename];
|
int wrapperType;
|
||||||
}
|
NSString *preferredFilename;
|
||||||
if (fileAttributes != nil)
|
NSDictionary *fileAttributes;
|
||||||
{
|
id wrapperData;
|
||||||
[self setFileAttributes: fileAttributes];
|
NSImage *iconImage;
|
||||||
}
|
|
||||||
if (iconImage != nil)
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &wrapperType];
|
||||||
{
|
// Dont restore the file name
|
||||||
[self setIcon: iconImage];
|
preferredFilename = [aDecoder decodeObject];
|
||||||
|
fileAttributes = [aDecoder decodeObject];
|
||||||
|
wrapperData = [aDecoder decodeObject];
|
||||||
|
iconImage = [aDecoder decodeObject];
|
||||||
|
|
||||||
|
switch (wrapperType)
|
||||||
|
{
|
||||||
|
case GSFileWrapperRegularFileType:
|
||||||
|
{
|
||||||
|
self = [self initRegularFileWithContents: wrapperData];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GSFileWrapperSymbolicLinkType:
|
||||||
|
{
|
||||||
|
self = [self initSymbolicLinkWithDestination: wrapperData];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GSFileWrapperDirectoryType:
|
||||||
|
{
|
||||||
|
self = [self initDirectoryWithFileWrappers: wrapperData];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preferredFilename != nil)
|
||||||
|
{
|
||||||
|
[self setPreferredFilename: preferredFilename];
|
||||||
|
}
|
||||||
|
if (fileAttributes != nil)
|
||||||
|
{
|
||||||
|
[self setFileAttributes: fileAttributes];
|
||||||
|
}
|
||||||
|
if (iconImage != nil)
|
||||||
|
{
|
||||||
|
[self setIcon: iconImage];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue