mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
* Source/GSXibLoader.m: Better handling for flattened properties
to set the tool tips of an object. Should fix bug report #34783 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34155 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d0d0df78ee
commit
45d5c38825
2 changed files with 95 additions and 51 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-11-11 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSXibLoader.m: Better handling for flattened properties
|
||||
to set the tool tips of an object.
|
||||
|
||||
2011-11-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSKeyValueBinding.m
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<abstract>Xib (Cocoa XML) model loader</abstract>
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Created: March 2010
|
||||
|
@ -215,7 +215,7 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) label
|
||||
- (NSString*) label
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@
|
|||
return destination;
|
||||
}
|
||||
|
||||
- (NSNibConnector *) nibConnector
|
||||
- (NSNibConnector*) nibConnector
|
||||
{
|
||||
NSString *tag = [self label];
|
||||
NSRange colonRange = [tag rangeOfString: @":"];
|
||||
|
@ -402,7 +402,7 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (IBConnection *) connection
|
||||
- (IBConnection*) connection
|
||||
{
|
||||
return connection;
|
||||
}
|
||||
|
@ -422,6 +422,11 @@
|
|||
|
||||
@implementation IBToolTipAttribute
|
||||
|
||||
- (NSString*) toolTip
|
||||
{
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
|
@ -578,7 +583,7 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *)orderedObjects
|
||||
- (NSArray*)orderedObjects
|
||||
{
|
||||
return orderedObjects;
|
||||
}
|
||||
|
@ -603,7 +608,7 @@
|
|||
|
||||
@implementation IBObjectContainer
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)coder
|
||||
- (id) initWithCoder: (NSCoder*)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
|
@ -647,24 +652,47 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSEnumerator *) connectionRecordEnumerator
|
||||
- (NSEnumerator*) connectionRecordEnumerator
|
||||
{
|
||||
return [connectionRecords objectEnumerator];
|
||||
}
|
||||
|
||||
- (NSEnumerator *) objectRecordEnumerator
|
||||
- (NSEnumerator*) objectRecordEnumerator
|
||||
{
|
||||
return [[objectRecords orderedObjects] objectEnumerator];
|
||||
}
|
||||
|
||||
- (NSDictionary*) propertiesForObjectID: (int)objectID
|
||||
{
|
||||
NSEnumerator *en;
|
||||
NSString *idString;
|
||||
NSString *key;
|
||||
NSMutableDictionary *properties;
|
||||
int idLength;
|
||||
|
||||
idString = [NSString stringWithFormat: @"%d.", objectID];
|
||||
idLength = [idString length];
|
||||
properties = [[NSMutableDictionary alloc] init];
|
||||
en = [flattenedProperties keyEnumerator];
|
||||
while ((key = [en nextObject]) != nil)
|
||||
{
|
||||
if ([key hasPrefix: idString])
|
||||
{
|
||||
id value = [flattenedProperties objectForKey: key];
|
||||
[properties setObject: value forKey: [key substringFromIndex: idLength]];
|
||||
}
|
||||
}
|
||||
|
||||
return AUTORELEASE(properties);
|
||||
}
|
||||
|
||||
- (id) nibInstantiate
|
||||
{
|
||||
NSEnumerator *en;
|
||||
id obj;
|
||||
NSString *key;
|
||||
|
||||
en = [connectionRecords objectEnumerator];
|
||||
// iterate over connections, instantiate, and then establish them.
|
||||
en = [connectionRecords objectEnumerator];
|
||||
while ((obj = [en nextObject]) != nil)
|
||||
{
|
||||
[obj nibInstantiate];
|
||||
|
@ -675,38 +703,49 @@
|
|||
en = [[objectRecords orderedObjects] objectEnumerator];
|
||||
while ((obj = [en nextObject]) != nil)
|
||||
{
|
||||
obj = [obj object];
|
||||
if ([obj respondsToSelector: @selector(awakeFromNib)])
|
||||
{
|
||||
[obj awakeFromNib];
|
||||
}
|
||||
}
|
||||
id realObj;
|
||||
NSDictionary *properties;
|
||||
id value;
|
||||
|
||||
// Activate windows
|
||||
en = [flattenedProperties keyEnumerator];
|
||||
while ((key = [en nextObject]) != nil)
|
||||
{
|
||||
if ([key hasSuffix: @"visibleAtLaunch"])
|
||||
realObj = [obj object];
|
||||
if ([realObj respondsToSelector: @selector(nibInstantiate)])
|
||||
{
|
||||
realObj = [realObj nibInstantiate];
|
||||
}
|
||||
|
||||
properties = [self propertiesForObjectID: [obj objectID]];
|
||||
NSDebugLLog(@"XIB", @"object %d props %@", [obj objectID], properties);
|
||||
|
||||
//value = [properties objectForKey: @"windowTemplate.maxSize"];
|
||||
//value = [properties objectForKey: @"CustomClassName"];
|
||||
|
||||
// Activate windows
|
||||
value = [properties objectForKey: @"NSWindowTemplate.visibleAtLaunch"];
|
||||
if (value != nil)
|
||||
{
|
||||
id value = [flattenedProperties objectForKey: key];
|
||||
|
||||
if ([value boolValue] == YES)
|
||||
{
|
||||
NSInteger objID = [key integerValue];
|
||||
|
||||
obj = [objectRecords objectWithObjectID: objID];
|
||||
if ([obj respondsToSelector: @selector(nibInstantiate)])
|
||||
{
|
||||
obj = [obj nibInstantiate];
|
||||
}
|
||||
|
||||
if ([obj isKindOfClass: [NSWindow class]])
|
||||
if ([realObj isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
// bring visible windows to front...
|
||||
[(NSWindow *)obj orderFront: self];
|
||||
[(NSWindow *)realObj orderFront: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tool tips
|
||||
value = [properties objectForKey: @"IBAttributePlaceholdersKey"];
|
||||
if (value != nil)
|
||||
{
|
||||
IBToolTipAttribute *tta = [(NSDictionary*)value objectForKey: @"ToolTip"];
|
||||
|
||||
[realObj setToolTip: [tta toolTip]];
|
||||
}
|
||||
|
||||
if ([realObj respondsToSelector: @selector(awakeFromNib)])
|
||||
{
|
||||
[realObj awakeFromNib];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -721,7 +760,7 @@
|
|||
|
||||
@implementation GSXibLoader
|
||||
|
||||
+ (NSString *)type
|
||||
+ (NSString*) type
|
||||
{
|
||||
return @"xib";
|
||||
}
|
||||
|
@ -821,7 +860,7 @@
|
|||
return loaded;
|
||||
}
|
||||
|
||||
- (NSData *) dataForFile: (NSString *)fileName
|
||||
- (NSData*) dataForFile: (NSString*)fileName
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
BOOL isDir = NO;
|
||||
|
@ -963,17 +1002,17 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) parser: (NSXMLParser *)parser
|
||||
foundCharacters: (NSString *)string
|
||||
- (void) parser: (NSXMLParser*)parser
|
||||
foundCharacters: (NSString*)string
|
||||
{
|
||||
[currentElement setValue: string];
|
||||
}
|
||||
|
||||
- (void) parser: (NSXMLParser *)parser
|
||||
didStartElement: (NSString *)elementName
|
||||
namespaceURI: (NSString *)namespaceURI
|
||||
qualifiedName: (NSString *)qualifiedName
|
||||
attributes: (NSDictionary *)attributeDict
|
||||
- (void) parser: (NSXMLParser*)parser
|
||||
didStartElement: (NSString*)elementName
|
||||
namespaceURI: (NSString*)namespaceURI
|
||||
qualifiedName: (NSString*)qualifiedName
|
||||
attributes: (NSDictionary*)attributeDict
|
||||
{
|
||||
GSXibElement *element = [[GSXibElement alloc] initWithType: elementName
|
||||
andAttributes: attributeDict];
|
||||
|
@ -1008,10 +1047,10 @@ didStartElement: (NSString *)elementName
|
|||
}
|
||||
}
|
||||
|
||||
- (void) parser: (NSXMLParser *)parser
|
||||
didEndElement: (NSString *)elementName
|
||||
namespaceURI: (NSString *)namespaceURI
|
||||
qualifiedName: (NSString *)qName
|
||||
- (void) parser: (NSXMLParser*)parser
|
||||
didEndElement: (NSString*)elementName
|
||||
namespaceURI: (NSString*)namespaceURI
|
||||
qualifiedName: (NSString*)qName
|
||||
{
|
||||
if (![@"archive" isEqualToString: elementName] &&
|
||||
![@"data" isEqualToString: elementName])
|
||||
|
@ -1022,7 +1061,7 @@ didStartElement: (NSString *)elementName
|
|||
}
|
||||
}
|
||||
|
||||
- (id) allocObjectForClassName: (NSString *)classname
|
||||
- (id) allocObjectForClassName: (NSString*)classname
|
||||
{
|
||||
Class c = [self classForClassName: classname];
|
||||
id delegate = [self delegate];
|
||||
|
@ -1055,8 +1094,8 @@ didStartElement: (NSString *)elementName
|
|||
}
|
||||
|
||||
- (id) decodeObjectForXib: (GSXibElement*)element
|
||||
forClassName: (NSString *)classname
|
||||
withID: (NSString *)objID
|
||||
forClassName: (NSString*)classname
|
||||
withID: (NSString*)objID
|
||||
{
|
||||
GSXibElement *last;
|
||||
id o, r;
|
||||
|
@ -1130,8 +1169,8 @@ didStartElement: (NSString *)elementName
|
|||
missing context switch.
|
||||
*/
|
||||
- (id) decodeDictionaryForXib: (GSXibElement*)element
|
||||
forClassName: (NSString *)classname
|
||||
withID: (NSString *)objID
|
||||
forClassName: (NSString*)classname
|
||||
withID: (NSString*)objID
|
||||
{
|
||||
id o, r;
|
||||
id delegate = [self delegate];
|
||||
|
|
Loading…
Reference in a new issue