mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 16:10:48 +00:00
NSNibOutletConnector and NSNibControlConnector classes added
This commit is contained in:
parent
f23058b172
commit
c31ec536a2
4 changed files with 8 additions and 62 deletions
|
@ -173,6 +173,8 @@
|
|||
#import <AppKit/NSMovieView.h>
|
||||
#import <AppKit/NSPanGestureRecognizer.h>
|
||||
#import <AppKit/NSNib.h>
|
||||
#import <AppKit/NSNibControlConnector.h>
|
||||
#import <AppKit/NSNibOutletConnector.h>
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSObjectController.h>
|
||||
#import <AppKit/NSOpenGL.h>
|
||||
|
|
|
@ -50,13 +50,8 @@
|
|||
- (void) setSource: (id)anObject;
|
||||
@end
|
||||
|
||||
@interface NSNibControlConnector : NSNibConnector
|
||||
- (void) establishConnection;
|
||||
@end
|
||||
|
||||
@interface NSNibOutletConnector : NSNibConnector
|
||||
- (void) establishConnection;
|
||||
@end
|
||||
#import <AppKit/NSNibControlConnector.h>
|
||||
#import <AppKit/NSNibOutletConnector.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -158,6 +158,8 @@ NSMovie.m \
|
|||
NSMovieView.m \
|
||||
NSNib.m \
|
||||
NSNibConnector.m \
|
||||
NSNibControlConnector.m \
|
||||
NSNibOutletConnector.m \
|
||||
NSNibBindingConnector.m \
|
||||
NSNibAXAttributeConnector.m \
|
||||
NSNibAXRelationshipConnector.m \
|
||||
|
@ -520,6 +522,8 @@ NSColorPicking.h \
|
|||
NSDragging.h \
|
||||
NSGraphics.h \
|
||||
NSNibConnector.h \
|
||||
NSNibControlConnector.h \
|
||||
NSNibOutletConnector.h \
|
||||
NSNibDeclarations.h \
|
||||
NSNibLoading.h \
|
||||
NSNib.h \
|
||||
|
|
|
@ -180,58 +180,3 @@
|
|||
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
|
||||
{
|
||||
/*
|
||||
* We cannot use the KVC mechanism here, as this would always retain _dst
|
||||
* and it could also affect _setXXX methods and _XXX ivars that aren't
|
||||
* affected by the Cocoa code.
|
||||
*/
|
||||
const char *name = [_tag cString];
|
||||
Class class = object_getClass(_src);
|
||||
Ivar ivar = class_getInstanceVariable(class, name);
|
||||
|
||||
if (ivar != 0)
|
||||
{
|
||||
object_setIvar(_src, ivar, _dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSLog(@"Error while establishing connection %@: %@", self, [localException reason]);
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue