mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Move more behaviour from the IBActionConnection5 and IBOutletConnection5
classes to the original ones.
This commit is contained in:
parent
078d10774c
commit
3db981a95d
4 changed files with 112 additions and 116 deletions
|
@ -1,3 +1,11 @@
|
|||
2020-02-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSXibLoading.h,
|
||||
* Source/GSXib5KeyedUnarchiver.m,
|
||||
* Source/GSXibLoading.m: Move more behaviour from the
|
||||
IBActionConnection5 and IBOutletConnection5 classes
|
||||
to the original ones.
|
||||
|
||||
2020-02-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* .travis.yml
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
|
||||
@interface IBActionConnection: IBConnection
|
||||
{
|
||||
NSString *trigger;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -113,118 +113,6 @@ static NSString *ApplicationClass = nil;
|
|||
|
||||
@end
|
||||
|
||||
@interface IBActionConnection5 : IBActionConnection
|
||||
{
|
||||
NSString *trigger;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation IBActionConnection5
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
trigger = nil;
|
||||
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
// label and source string tags have changed for XIB5...
|
||||
ASSIGN(label, [coder decodeObjectForKey: @"selector"]);
|
||||
ASSIGN(source, [coder decodeObjectForKey: @"target"]);
|
||||
// destination string tag is still the same (so far) and loaded
|
||||
// by base class...
|
||||
//ASSIGN(destination, [coder decodeObjectForKey: @"destination"]);
|
||||
|
||||
// Looks like the 'trigger' attribute should be used to override the
|
||||
// target/action setup method...
|
||||
if ([coder containsValueForKey: @"trigger"])
|
||||
ASSIGN(trigger, [coder decodeObjectForKey: @"trigger"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*) trigger
|
||||
{
|
||||
return trigger;
|
||||
}
|
||||
|
||||
- (void) establishConnection
|
||||
{
|
||||
if (trigger && [trigger length])
|
||||
{
|
||||
SEL sel = NSSelectorFromString(label);
|
||||
NSString *selName = [NSString stringWithFormat: @"set%@%@:",
|
||||
[[trigger substringToIndex: 1] uppercaseString],
|
||||
[trigger substringFromIndex: 1]];
|
||||
SEL trigsel = NSSelectorFromString(selName);
|
||||
|
||||
if (sel && trigsel && [destination respondsToSelector: trigsel])
|
||||
{
|
||||
NSWarnMLog(@"setting trigger %@ to selector %@", selName, label);
|
||||
//[destination setTarget: source]; // Not needed???
|
||||
[destination performSelector: trigsel withObject: (id)sel];
|
||||
}
|
||||
else if (!sel)
|
||||
{
|
||||
NSWarnMLog(@"label %@ does not correspond to any selector", label);
|
||||
}
|
||||
else if (!trigsel)
|
||||
{
|
||||
NSWarnMLog(@"trigger %@ does not correspond to any selector", trigger);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnMLog(@"destination class (%@) does not respond to trigger selector %@",
|
||||
NSStringFromClass([destination class]), selName);
|
||||
}
|
||||
|
||||
// PREMATURE RETURN...
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise invoke the super class' method...
|
||||
[super establishConnection];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface IBOutletConnection5 : IBOutletConnection
|
||||
@end
|
||||
|
||||
@implementation IBOutletConnection5
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
// label string tag has changed for XIB5...
|
||||
ASSIGN(label, [coder decodeObjectForKey: @"property"]);
|
||||
// destination and source string tags are still the same (so far) and loaded
|
||||
// by base class...
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface IBUserDefinedRuntimeAttribute5 : IBUserDefinedRuntimeAttribute
|
||||
@end
|
||||
|
@ -313,8 +201,8 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"NSSegmentItem", @"segment",
|
||||
@"NSCell", @"customCell",
|
||||
@"NSCustomObject5", @"customObject",
|
||||
@"IBOutletConnection5", @"outlet",
|
||||
@"IBActionConnection5", @"action",
|
||||
@"IBOutletConnection", @"outlet",
|
||||
@"IBActionConnection", @"action",
|
||||
@"NSNibBindingConnector", @"binding",
|
||||
@"NSWindowTemplate", @"window",
|
||||
@"NSView", @"tableCellView",
|
||||
|
@ -3122,7 +3010,7 @@ didStartElement: (NSString*)elementName
|
|||
return flag;
|
||||
}
|
||||
|
||||
- (NSPoint) decodePointForKey:(NSString *)key
|
||||
- (NSPoint) decodePointForKey: (NSString *)key
|
||||
{
|
||||
NSPoint point = NSZeroPoint;
|
||||
|
||||
|
|
|
@ -421,18 +421,117 @@
|
|||
|
||||
@implementation IBActionConnection
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
DESTROY(trigger);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
// label and source string tags have changed for XIB5...
|
||||
if ([coder containsValueForKey: @"selector"])
|
||||
{
|
||||
ASSIGN(label, [coder decodeObjectForKey: @"selector"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"target"])
|
||||
{
|
||||
ASSIGN(source, [coder decodeObjectForKey: @"target"]);
|
||||
}
|
||||
|
||||
// Looks like the 'trigger' attribute should be used to override the
|
||||
// action setup method...
|
||||
if ([coder containsValueForKey: @"trigger"])
|
||||
{
|
||||
ASSIGN(trigger, [coder decodeObjectForKey: @"trigger"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.", NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*) trigger
|
||||
{
|
||||
return trigger;
|
||||
}
|
||||
|
||||
- (void) establishConnection
|
||||
{
|
||||
SEL sel = NSSelectorFromString(label);
|
||||
|
||||
[destination setTarget: source];
|
||||
[destination setAction: sel];
|
||||
|
||||
if (trigger && [trigger length])
|
||||
{
|
||||
NSString *selName = [NSString stringWithFormat: @"set%@%@:",
|
||||
[[trigger substringToIndex: 1] uppercaseString],
|
||||
[trigger substringFromIndex: 1]];
|
||||
SEL trigsel = NSSelectorFromString(selName);
|
||||
|
||||
if (sel && trigsel && [destination respondsToSelector: trigsel])
|
||||
{
|
||||
NSWarnMLog(@"setting trigger %@ to selector %@", selName, label);
|
||||
[destination performSelector: trigsel withObject: (id)sel];
|
||||
}
|
||||
else if (!sel)
|
||||
{
|
||||
NSWarnMLog(@"label %@ does not correspond to any selector", label);
|
||||
}
|
||||
else if (!trigsel)
|
||||
{
|
||||
NSWarnMLog(@"trigger %@ does not correspond to any selector", trigger);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWarnMLog(@"destination class (%@) does not respond to trigger selector %@",
|
||||
NSStringFromClass([destination class]), selName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise invoke the normal method...
|
||||
[destination setAction: sel];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation IBOutletConnection
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
// label string tag has changed for XIB5...
|
||||
if ([coder containsValueForKey: @"property"])
|
||||
{
|
||||
ASSIGN(label, [coder decodeObjectForKey: @"property"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Can't decode %@ with %@.", NSStringFromClass([self class]),
|
||||
NSStringFromClass([coder class])];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) establishConnection
|
||||
{
|
||||
NS_DURING
|
||||
|
|
Loading…
Reference in a new issue