mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 17:50:38 +00:00
* Source/NSBundleAdditions.m,
* Source/NSNibConnector.m: Move NSNibConnector and subclasses in separate file. Add isEqual: method from Gorm. Switch to new libobjc runtime ivar access for NSNibOutletConnector. * Source/GNUmakefile: Add new file NSNibConnector.m * Source/GSXibLoader.m: Similar change to IBOutletConnection. Replace GSMime base64 decode method with standard one. * Source/GSImageMagickImageRep.m, * Source/GSTheme.m: Remove unused #import. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38919 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
49a39c958f
commit
144ebe2179
7 changed files with 267 additions and 205 deletions
|
@ -33,200 +33,16 @@
|
|||
#import "config.h"
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSCoder.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import "AppKit/NSControl.h"
|
||||
#import "AppKit/NSNib.h"
|
||||
#import "AppKit/NSNibConnector.h"
|
||||
#import "AppKit/NSNibLoading.h"
|
||||
#import "GNUstepGUI/GSModelLoaderFactory.h"
|
||||
|
||||
@implementation NSNibConnector
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_src);
|
||||
RELEASE(_dst);
|
||||
RELEASE(_tag);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) destination
|
||||
{
|
||||
return _dst;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
if (_src != nil)
|
||||
{
|
||||
[aCoder encodeObject: _src forKey: @"NSSource"];
|
||||
}
|
||||
if (_dst != nil)
|
||||
{
|
||||
[aCoder encodeObject: _dst forKey: @"NSDestination"];
|
||||
}
|
||||
if (_tag != nil)
|
||||
{
|
||||
[aCoder encodeObject: _tag forKey: @"NSLabel"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: _src];
|
||||
[aCoder encodeObject: _dst];
|
||||
[aCoder encodeObject: _tag];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) establishConnection
|
||||
{
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
if ([aDecoder containsValueForKey: @"NSDestination"])
|
||||
{
|
||||
ASSIGN(_dst, [aDecoder decodeObjectForKey: @"NSDestination"]);
|
||||
}
|
||||
if ([aDecoder containsValueForKey: @"NSSource"])
|
||||
{
|
||||
ASSIGN(_src, [aDecoder decodeObjectForKey: @"NSSource"]);
|
||||
}
|
||||
if ([aDecoder containsValueForKey: @"NSLabel"])
|
||||
{
|
||||
ASSIGN(_tag, [aDecoder decodeObjectForKey: @"NSLabel"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_src];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_dst];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_tag];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*) label
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
- (void) replaceObject: (id)anObject withObject: (id)anotherObject
|
||||
{
|
||||
if (_src == anObject)
|
||||
{
|
||||
ASSIGN(_src, anotherObject);
|
||||
}
|
||||
if (_dst == anObject)
|
||||
{
|
||||
ASSIGN(_dst, anotherObject);
|
||||
}
|
||||
if (_tag == anObject)
|
||||
{
|
||||
ASSIGN(_tag, anotherObject);
|
||||
}
|
||||
}
|
||||
|
||||
- (id) source
|
||||
{
|
||||
return _src;
|
||||
}
|
||||
|
||||
- (void) setDestination: (id)anObject
|
||||
{
|
||||
ASSIGN(_dst, anObject);
|
||||
}
|
||||
|
||||
- (void) setLabel: (NSString*)label
|
||||
{
|
||||
ASSIGN(_tag, label);
|
||||
}
|
||||
|
||||
- (void) setSource: (id)anObject
|
||||
{
|
||||
ASSIGN(_src, anObject);
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
NSString *desc = [NSString stringWithFormat: @"<%@ src=%@ dst=%@ label=%@>",
|
||||
[super description],
|
||||
[self source],
|
||||
[self destination],
|
||||
[self label]];
|
||||
return desc;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSNibControlConnector
|
||||
- (void) establishConnection
|
||||
{
|
||||
SEL sel = NSSelectorFromString(_tag);
|
||||
|
||||
[_src setTarget: _dst];
|
||||
[_src setAction: sel];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSNibOutletConnector
|
||||
- (void) establishConnection
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
if (_src != nil)
|
||||
{
|
||||
NSString *selName;
|
||||
SEL sel;
|
||||
|
||||
selName = [NSString stringWithFormat: @"set%@%@:",
|
||||
[[_tag substringToIndex: 1] uppercaseString],
|
||||
[_tag substringFromIndex: 1]];
|
||||
sel = NSSelectorFromString(selName);
|
||||
|
||||
if (sel && [_src respondsToSelector: sel])
|
||||
{
|
||||
[_src performSelector: sel withObject: _dst];
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *nam = [_tag cString];
|
||||
const char *type;
|
||||
unsigned int size;
|
||||
int offset;
|
||||
|
||||
/*
|
||||
* Use the GNUstep additional function to set the instance
|
||||
* variable directly.
|
||||
* FIXME - need some way to do this for libFoundation and
|
||||
* Foundation based systems.
|
||||
*/
|
||||
if (GSObjCFindVariable(_src, nam, &type, &size, &offset))
|
||||
{
|
||||
GSObjCSetVariable(_src, offset, size, (void*)&_dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Error while establishing connection %@: %@",self,[localException reason]);
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSBundle (NSBundleAdditions)
|
||||
+ (BOOL) loadNibFile: (NSString*)fileName
|
||||
externalNameTable: (NSDictionary*)context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue