More data link implementation details.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20850 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gcasa 2005-03-05 15:50:32 +00:00
parent 45d5c1ef80
commit b6d9981388
8 changed files with 329 additions and 93 deletions

View file

@ -1,3 +1,15 @@
2005-03-05 10:53 Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/AppKit/NSDataLink.h
* Headers/AppKit/NSDataLinkManager.h: Added some ivars
* Source/Functions.m: Changed the NSLinkFrameThickness() function to
return 1 instead of 1.5.
* Source/NSDataLink.m: Implemented several methods.
* Source/NSDataLinkManager.m: Implemented several methods.
* Source/NSDataLinkPanel.m: Change version from 1 to 0.
* Source/NSSelection.m: Change version from 1 to 0, corrected
but in initWithCoder:.
2005-03-03 Adam Fedor <fedor@gnu.org> 2005-03-03 Adam Fedor <fedor@gnu.org>
* configure.ac: Disable gsnd on darwin * configure.ac: Disable gsnd on darwin

View file

@ -65,19 +65,32 @@ APPKIT_EXPORT NSString *NSDataLinkFileNameExtension;
NSDataLinkNumber linkNumber; NSDataLinkNumber linkNumber;
NSDataLinkDisposition disposition; NSDataLinkDisposition disposition;
NSDataLinkUpdateMode updateMode; NSDataLinkUpdateMode updateMode;
NSDataLinkManager *manager;
// info about the source. // info about the source.
NSDate *lastUpdateTime; NSDate *lastUpdateTime;
NSString *sourceApplicationName; NSString *sourceApplicationName;
NSString *sourceFilename; NSString *sourceFilename;
NSSelection *sourceSelection; NSSelection *sourceSelection;
NSArray *types; id sourceManager;
// info about the destination // info about the destination
NSString *destinationApplicationName; NSString *destinationApplicationName;
NSString *destinationFilename; NSString *destinationFilename;
NSSelection *destinationSelection; NSSelection *destinationSelection;
id destinationManager;
// types.
NSArray *types;
// other flags
struct __linkFlags {
unsigned appVerifies:1;
unsigned broken:1;
unsigned canUpdateContinuously:1;
unsigned isDirty:1;
unsigned willOpenSource:1;
unsigned willUpdate:1;
} _flags;
} }
// //
@ -131,5 +144,8 @@ APPKIT_EXPORT NSString *NSDataLinkFileNameExtension;
- (NSDataLinkUpdateMode)updateMode; - (NSDataLinkUpdateMode)updateMode;
@end @end
APPKIT_EXPORT NSString *NSDataLinkFilenameExtension;
APPKIT_EXPORT NSString *NSDataLinkPboardType;
#endif // _GNUstep_H_NSDataLink #endif // _GNUstep_H_NSDataLink

View file

@ -33,7 +33,7 @@
@class NSString; @class NSString;
@class NSEnumerator; @class NSEnumerator;
@class NSMutableDictionary; @class NSMutableArray;
@class NSDataLink; @class NSDataLink;
@class NSSelection; @class NSSelection;
@class NSPasteboard; @class NSPasteboard;
@ -44,12 +44,16 @@
// Attributes // Attributes
id delegate; id delegate;
NSString *filename; NSString *filename;
BOOL delegateVerifiesLinks; NSMutableArray *sourceLinks;
BOOL interactsWithUser; NSMutableArray *destinationLinks;
BOOL isEdited;
BOOL areLinkOutlinesVisible; struct __dlmFlags {
NSMutableDictionary *sourceLinks; unsigned areLinkOutlinesVisible:1;
NSMutableDictionary *destinationLinks; unsigned delegateVerifiesLinks:1;
unsigned interactsWithUser:1;
unsigned isEdited:1;
} _flags;
} }
// //
@ -108,9 +112,7 @@
// Methods Implemented by the Delegate // Methods Implemented by the Delegate
// //
@interface NSObject (NSDataLinkManagerDelegate) @interface NSObject (NSDataLinkManagerDelegate)
- (BOOL)copyToPasteboard:(NSPasteboard *)pasteboard // data link management methods.
at:(NSSelection *)selection
cheapCopyAllowed:(BOOL)flag;
- (void)dataLinkManager:(NSDataLinkManager *)sender - (void)dataLinkManager:(NSDataLinkManager *)sender
didBreakLink:(NSDataLink *)link; didBreakLink:(NSDataLink *)link;
- (BOOL)dataLinkManager:(NSDataLinkManager *)sender - (BOOL)dataLinkManager:(NSDataLinkManager *)sender
@ -123,6 +125,11 @@
- (void)dataLinkManagerDidEditLinks:(NSDataLinkManager *)sender; - (void)dataLinkManagerDidEditLinks:(NSDataLinkManager *)sender;
- (void)dataLinkManagerRedrawLinkOutlines:(NSDataLinkManager *)sender; - (void)dataLinkManagerRedrawLinkOutlines:(NSDataLinkManager *)sender;
- (BOOL)dataLinkManagerTracksLinksIndividually:(NSDataLinkManager *)sender; - (BOOL)dataLinkManagerTracksLinksIndividually:(NSDataLinkManager *)sender;
// selection management methods.
- (BOOL)copyToPasteboard:(NSPasteboard *)pasteboard
at:(NSSelection *)selection
cheapCopyAllowed:(BOOL)flag;
- (BOOL)importFile:(NSString *)filename - (BOOL)importFile:(NSString *)filename
at:(NSSelection *)selection; at:(NSSelection *)selection;
- (BOOL)pasteFromPasteboard:(NSPasteboard *)pasteboard - (BOOL)pasteFromPasteboard:(NSPasteboard *)pasteboard

View file

@ -779,7 +779,7 @@ NSDrawWindowBackground(NSRect aRect)
float float
NSLinkFrameThickness(void) NSLinkFrameThickness(void)
{ {
return 1.5; return 1;
} }
void void

View file

@ -1,7 +1,9 @@
/** <title>NSDataLink</title> /** <title>NSDataLink</title>
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 2005 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
Date: 2005
Author: Scott Christley <scottc@net-community.com> Author: Scott Christley <scottc@net-community.com>
Date: 1996 Date: 1996
@ -24,29 +26,17 @@
*/ */
#include "config.h" #include "config.h"
#include <Foundation/NSFileManager.h>
#include <Foundation/NSArchiver.h>
#include <Foundation/NSData.h>
#include "AppKit/NSDataLink.h" #include "AppKit/NSDataLink.h"
#include "AppKit/NSDataLinkManager.h" #include "AppKit/NSDataLinkManager.h"
#include "AppKit/NSPasteboard.h"
#include "AppKit/NSSavePanel.h"
#include "AppKit/NSSelection.h"
@interface NSDataLink (Private) // constants
- (void) setLastUpdateTime: (NSDate *)date; NSString *NSDataLinkFilenameExtension = @"dlink";
- (void) setSourceFilename: (NSString *)src;
- (void) setDestinationFilename: (NSString *)src;
@end
@implementation NSDataLink (Private)
- (void) setLastUpdateTime: (NSDate *)date
{
ASSIGN(lastUpdateTime, date);
}
- (void) setSourceFilename: (NSString *)src
{
ASSIGN(sourceFilename,src);
}
- (void) setDestinationFilename: (NSString *)dst
{
ASSIGN(destinationFilename, dst);
}
@end
@implementation NSDataLink @implementation NSDataLink
@ -58,7 +48,7 @@
if (self == [NSDataLink class]) if (self == [NSDataLink class])
{ {
// Initial version // Initial version
[self setVersion: 1]; [self setVersion: 0];
} }
} }
@ -70,6 +60,12 @@
// //
- (id)initLinkedToFile:(NSString *)filename - (id)initLinkedToFile:(NSString *)filename
{ {
if((self = [self init]) != nil)
{
NSData *data = [NSData dataWithBytes: [filename cString] length: [filename cStringLength]];
NSSelection *selection = [NSSelection selectionWithDescriptionData: data];
ASSIGN(sourceSelection, selection);
}
return nil; return nil;
} }
@ -80,7 +76,7 @@
if((self = [self init]) != nil) if((self = [self init]) != nil)
{ {
ASSIGN(sourceSelection,selection); ASSIGN(sourceSelection,selection);
ASSIGN(manager,linkManager); ASSIGN(sourceManager,linkManager);
ASSIGN(types,newTypes); ASSIGN(types,newTypes);
} }
return self; return self;
@ -88,12 +84,18 @@
- (id)initWithContentsOfFile:(NSString *)filename - (id)initWithContentsOfFile:(NSString *)filename
{ {
return nil; NSData *data = AUTORELEASE([[NSData alloc] initWithContentsOfFile: filename]);
id object = [NSUnarchiver unarchiveObjectWithData: data];
RELEASE(self);
return object;
} }
- (id)initWithPasteboard:(NSPasteboard *)pasteboard - (id)initWithPasteboard:(NSPasteboard *)pasteboard
{ {
return nil; NSData *data = [pasteboard dataForType: NSDataLinkPboardType];
id object = [NSUnarchiver unarchiveObjectWithData: data];
RELEASE(self);
return object;
} }
// //
@ -101,16 +103,48 @@
// //
- (BOOL)saveLinkIn:(NSString *)directoryName - (BOOL)saveLinkIn:(NSString *)directoryName
{ {
NSSavePanel *sp;
int result;
sp = [NSSavePanel savePanel];
[sp setRequiredFileType: NSDataLinkFilenameExtension];
result = [sp runModalForDirectory: directoryName file: @""];
if (result == NSOKButton)
{
NSFileManager *mgr = [NSFileManager defaultManager];
NSString *path = [sp filename];
if ([mgr fileExistsAtPath: path] == YES)
{
/* NSSavePanel has already asked if it's ok to replace */
NSString *bPath = [path stringByAppendingString: @"~"];
[mgr removeFileAtPath: bPath handler: nil];
[mgr movePath: path toPath: bPath handler: nil];
}
// save it.
return [self writeToFile: path];
}
return NO; return NO;
} }
- (BOOL)writeToFile:(NSString *)filename - (BOOL)writeToFile:(NSString *)filename
{ {
return NO; NSString *path = filename;
if([[path pathExtension] isEqual: NSDataLinkFilenameExtension] == NO)
{
path = [filename stringByAppendingPathExtension: NSDataLinkFilenameExtension];
}
return [NSArchiver archiveRootObject: self toFile: path];
} }
- (void)writeToPasteboard:(NSPasteboard *)pasteboard - (void)writeToPasteboard:(NSPasteboard *)pasteboard
{ {
NSData *data = [NSArchiver archivedDataWithRootObject: self];
[pasteboard setData: data forType: NSDataLinkPboardType];
} }
// //
@ -128,7 +162,7 @@
- (NSDataLinkManager *)manager - (NSDataLinkManager *)manager
{ {
return manager; return sourceManager;
} }
// //
@ -187,11 +221,34 @@
// //
- (BOOL)break - (BOOL)break
{ {
return NO; id srcDelegate = [sourceManager delegate];
id dstDelegate = [destinationManager delegate];
// The spec is quite vague here. I don't know under what
// circumstances a link cannot be broken, so this method
// always returns YES.
if([srcDelegate respondsToSelector: @selector(dataLinkManager:didBreakLink:)])
{
[srcDelegate dataLinkManager: sourceManager didBreakLink: self];
}
if([dstDelegate respondsToSelector: @selector(dataLinkManager:didBreakLink:)])
{
[dstDelegate dataLinkManager: destinationManager didBreakLink: self];
}
return (_flags.broken = YES);
} }
- (void)noteSourceEdited - (void)noteSourceEdited
{ {
_flags.isDirty = YES;
if(updateMode != NSUpdateNever)
{
[sourceManager noteDocumentEdited];
}
} }
- (void)setUpdateMode:(NSDataLinkUpdateMode)mode - (void)setUpdateMode:(NSDataLinkUpdateMode)mode
@ -214,42 +271,80 @@
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL flag = NO;
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber]; [aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition]; [aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode]; [aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &manager];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime]; [aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; [aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename]; [aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection]; [aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &types]; [aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName]; [aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename]; [aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection]; [aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &types];
// flags...
flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLink"]; int version = [aCoder versionForClassName: @"NSDataLink"];
if(version == 1) if(version == 0)
{ {
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber]; [aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition]; [aCoder decodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode]; [aCoder decodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder decodeValueOfObjCType: @encode(id) at: &manager]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime]; [aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &types]; [aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName]; [aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename]; [aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection]; [aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &types];
// flags...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.appVerifies = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.canUpdateContinuously = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
} }
else else
{ {
NSLog(@"No decoder for NSDataLink version #%d",version); return nil;
} }
return self; return self;

View file

@ -1,7 +1,9 @@
/** <title>NSDataLinkManager</title> /** <title>NSDataLinkManager</title>
Copyright (C) 1996 Free Software Foundation, Inc. Copyright (C) 1996, 2005 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
Date: 2005
Author: Scott Christley <scottc@net-community.com> Author: Scott Christley <scottc@net-community.com>
Date: 1996 Date: 1996
@ -26,9 +28,58 @@
#include "config.h" #include "config.h"
#include <Foundation/NSDictionary.h> #include <Foundation/NSDictionary.h>
#include <Foundation/NSEnumerator.h> #include <Foundation/NSEnumerator.h>
#include <Foundation/NSArray.h>
#include <AppKit/NSDataLinkManager.h> #include <AppKit/NSDataLinkManager.h>
#include <AppKit/NSDataLink.h> #include <AppKit/NSDataLink.h>
@interface NSDataLink (Private)
- (void) setLastUpdateTime: (NSDate *)date;
- (void) setSourceFilename: (NSString *)src;
- (void) setDestinationFilename: (NSString *)dst;
- (void) setSourceManager: (id)src;
- (void) setDestinationManager: (id)dst;
- (void) setSourceSelection: (id)src;
- (void) setDestinationSelection: (id)dst;
@end
@implementation NSDataLink (Private)
- (void) setLastUpdateTime: (NSDate *)date
{
ASSIGN(lastUpdateTime, date);
}
- (void) setSourceFilename: (NSString *)src
{
ASSIGN(sourceFilename,src);
}
- (void) setDestinationFilename: (NSString *)dst
{
ASSIGN(destinationFilename, dst);
}
- (void) setSourceManager: (id)src
{
ASSIGN(sourceManager,src);
}
- (void) setDestinationManager: (id)dst
{
ASSIGN(destinationManager,dst);
}
- (void) setSourceSelection: (id)src
{
ASSIGN(sourceSelection,src);
}
- (void) setDestinationSelection: (id)dst
{
ASSIGN(destinationSelection,dst);
}
@end
@implementation NSDataLinkManager @implementation NSDataLinkManager
// //
@ -39,7 +90,7 @@
if (self == [NSDataLinkManager class]) if (self == [NSDataLinkManager class])
{ {
// Initial version // Initial version
[self setVersion:1]; [self setVersion: 0];
} }
} }
@ -53,12 +104,15 @@
{ {
self = [super init]; self = [super init];
ASSIGN(delegate,anObject); if(self != nil)
filename = nil; {
delegateVerifiesLinks = NO; ASSIGN(delegate,anObject);
interactsWithUser = NO; filename = nil;
isEdited = NO; _flags.delegateVerifiesLinks = NO;
areLinkOutlinesVisible = NO; _flags.interactsWithUser = NO;
_flags.isEdited = NO;
_flags.areLinkOutlinesVisible = NO;
}
return self; return self;
} }
@ -68,12 +122,15 @@
{ {
self = [super init]; self = [super init];
ASSIGN(delegate,anObject); if(self != nil)
ASSIGN(filename,path); {
delegateVerifiesLinks = NO; ASSIGN(delegate,anObject);
interactsWithUser = NO; ASSIGN(filename,path);
isEdited = NO; _flags.delegateVerifiesLinks = NO;
areLinkOutlinesVisible = NO; _flags.interactsWithUser = NO;
_flags.isEdited = NO;
_flags.areLinkOutlinesVisible = NO;
}
return self; return self;
} }
@ -84,7 +141,18 @@
- (BOOL)addLink:(NSDataLink *)link - (BOOL)addLink:(NSDataLink *)link
at:(NSSelection *)selection at:(NSSelection *)selection
{ {
return NO; BOOL result = NO;
[link setDestinationSelection: selection];
[link setDestinationManager: self];
if([destinationLinks containsObject: link] == NO)
{
[destinationLinks addObject: link];
result = YES;
}
return result;
} }
- (BOOL)addLinkAsMarker:(NSDataLink *)link - (BOOL)addLinkAsMarker:(NSDataLink *)link
@ -102,23 +170,26 @@
- (void)breakAllLinks - (void)breakAllLinks
{ {
NSEnumerator *en = [self destinationLinkEnumerator]; NSArray *allLinks = [sourceLinks arrayByAddingObjectsFromArray: destinationLinks];
NSEnumerator *en = [allLinks objectEnumerator];
id obj = nil; id obj = nil;
while((obj = [en nextObject]) != nil) while((obj = [en nextObject]) != nil)
{ {
[obj break]; [obj break];
} }
en = [self sourceLinkEnumerator];
while((obj = [en nextObject]) != nil)
{
[obj break];
}
} }
- (void)writeLinksToPasteboard:(NSPasteboard *)pasteboard - (void)writeLinksToPasteboard:(NSPasteboard *)pasteboard
{ {
NSArray *allLinks = [sourceLinks arrayByAddingObjectsFromArray: destinationLinks];
NSEnumerator *en = [allLinks objectEnumerator];
id obj = nil;
while((obj = [en nextObject]) != nil)
{
[obj writeToPasteboard: pasteboard];
}
} }
// //
@ -158,7 +229,7 @@
- (BOOL)delegateVerifiesLinks - (BOOL)delegateVerifiesLinks
{ {
return delegateVerifiesLinks; return _flags.delegateVerifiesLinks;
} }
- (NSString *)filename - (NSString *)filename
@ -168,22 +239,22 @@
- (BOOL)interactsWithUser - (BOOL)interactsWithUser
{ {
return interactsWithUser; return _flags.interactsWithUser;
} }
- (BOOL)isEdited - (BOOL)isEdited
{ {
return isEdited; return _flags.isEdited;
} }
- (void)setDelegateVerifiesLinks:(BOOL)flag - (void)setDelegateVerifiesLinks:(BOOL)flag
{ {
delegateVerifiesLinks = flag; _flags.delegateVerifiesLinks = flag;
} }
- (void)setInteractsWithUser:(BOOL)flag - (void)setInteractsWithUser:(BOOL)flag
{ {
interactsWithUser = flag; _flags.interactsWithUser = flag;
} }
// //
@ -191,12 +262,12 @@
// //
- (BOOL)areLinkOutlinesVisible - (BOOL)areLinkOutlinesVisible
{ {
return areLinkOutlinesVisible; return _flags.areLinkOutlinesVisible;
} }
- (NSEnumerator *)destinationLinkEnumerator - (NSEnumerator *)destinationLinkEnumerator
{ {
return [destinationLinks keyEnumerator]; return [destinationLinks objectEnumerator];
} }
- (NSDataLink *)destinationLinkWithSelection:(NSSelection *)destSel - (NSDataLink *)destinationLinkWithSelection:(NSSelection *)destSel
@ -217,12 +288,12 @@
- (void)setLinkOutlinesVisible:(BOOL)flag - (void)setLinkOutlinesVisible:(BOOL)flag
{ {
areLinkOutlinesVisible = flag; _flags.areLinkOutlinesVisible = flag;
} }
- (NSEnumerator *)sourceLinkEnumerator - (NSEnumerator *)sourceLinkEnumerator
{ {
return [sourceLinks keyEnumerator]; return [sourceLinks objectEnumerator];
} }
// //
@ -230,10 +301,48 @@
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL flag = NO;
[aCoder encodeValueOfObjCType: @encode(id) at: &filename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks];
flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isEdited;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLinkManager"];
if(version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(id) at: &filename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isEdited = flag;
}
else
{
return nil;
}
return self; return self;
} }

View file

@ -104,7 +104,7 @@ static NSDataLinkPanel *_sharedDataLinkPanel;
if (self == [NSDataLinkPanel class]) if (self == [NSDataLinkPanel class])
{ {
// Initial version // Initial version
[self setVersion:1]; [self setVersion: 0];
} }
} }

View file

@ -96,7 +96,7 @@ typedef enum
if (self == [NSSelection class]) if (self == [NSSelection class])
{ {
// Initial version // Initial version
[self setVersion:1]; [self setVersion: 0];
} }
} }
@ -226,6 +226,8 @@ typedef enum
at: &_isWellKnownSelection]; at: &_isWellKnownSelection];
[aDecoder decodeValueOfObjCType: @encode(int) [aDecoder decodeValueOfObjCType: @encode(int)
at: &_selectionType]; at: &_selectionType];
[aDecoder decodeValueOfObjCType: @encode(id)
at: _descriptionData];
// if it's a well known selection then determine which one it is. // if it's a well known selection then determine which one it is.
if(_isWellKnownSelection) if(_isWellKnownSelection)
@ -249,11 +251,6 @@ typedef enum
break; break;
} }
} }
else
{
[aDecoder decodeValueOfObjCType: @encode(id)
at: _descriptionData];
}
return self; return self;
} }