Author: mlytwyn
Date: Thu Aug 13 18:33:48 2015
New Revision: 38878

URL: http://svn.gna.org/viewcvs/gnustep?rev=38878&view=rev
Log:
Add IB defined runtime attribute processing for XIB

Modified:
    
libs/gui/branches/gnustep_testplant_branch/Headers/Additions/GNUstepGUI/GSXibLoading.h
    libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoader.m
    libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoading.m

Modified: 
libs/gui/branches/gnustep_testplant_branch/Headers/Additions/GNUstepGUI/GSXibLoading.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/Additions/GNUstepGUI/GSXibLoading.h?rev=38878&r1=38877&r2=38878&view=diff
==============================================================================
--- 
libs/gui/branches/gnustep_testplant_branch/Headers/Additions/GNUstepGUI/GSXibLoading.h
      (original)
+++ 
libs/gui/branches/gnustep_testplant_branch/Headers/Additions/GNUstepGUI/GSXibLoading.h
      Thu Aug 13 18:33:48 2015
@@ -37,6 +37,7 @@
 @class NSString, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray;
 @class NSNibBindingConnector;
 @class GSXibElement;
+@class NSNibConnector;
 
 // Hack: This allows the class name FirstResponder in NSCustomObject and
 // correctly returns nil as the corresponding object.
@@ -158,6 +159,38 @@
 - (NSEnumerator *) objectRecordEnumerator;
 @end
 
+@interface IBUserDefinedRuntimeAttributesPlaceholder : NSObject <NSCoding>
+{
+  NSArray  *runtimeAttributes;
+  NSString *name;
+}
+
+- (void) setName: (NSString *)name;
+- (NSString *) name;
+
+- (void) setRuntimeAttributes: (NSString *)attributes;
+- (NSString *) runtimeAttributes;
+
+@end
+
+@interface IBUserDefinedRuntimeAttribute : NSObject <NSCoding>
+{
+  NSString *typeIdentifier;
+  NSString *keyPath;
+  id value;
+}
+
+- (void) setTypeIdentifier: (NSString *)type;
+- (NSString *) typeIdentifier;
+
+- (void) setKeyPath: (NSString *)keyPath;
+- (NSString *) keyPath;
+
+- (void) setValue: (id)value;
+- (id) value;
+
+@end
+
 @interface GSXibKeyedUnarchiver: NSKeyedUnarchiver
 {
   NSMutableDictionary *objects;

Modified: libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoader.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoader.m?rev=38878&r1=38877&r2=38878&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoader.m     
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoader.m     Thu Aug 
13 18:33:48 2015
@@ -856,12 +856,30 @@
       value = [properties objectForKey: @"IBAttributePlaceholdersKey"];
       if (value != nil)
         {
-          IBToolTipAttribute *tta = [(NSDictionary*)value objectForKey: 
@"ToolTip"];
-
-          if ([realObj respondsToSelector: @selector(setToolTip:)])
+          NSDictionary *infodict = (NSDictionary*)value;
+          
+          // Process tooltips...
+          IBToolTipAttribute *tooltip = [infodict objectForKey: @"ToolTip"];
+
+          if (tooltip && [realObj respondsToSelector: @selector(setToolTip:)])
             {
-              [realObj setToolTip: [tta toolTip]];
+              [realObj setToolTip: [tooltip toolTip]];
             }
+          
+          // Process XIB runtime attributes...
+          if ([infodict 
objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"])
+            {
+              IBUserDefinedRuntimeAttributesPlaceholder *placeholder =
+                                                        [infodict 
objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"];
+              NSArray                                   *attributes  = 
[placeholder runtimeAttributes];
+              NSEnumerator                              *objectiter  = 
[attributes objectEnumerator];
+              IBUserDefinedRuntimeAttribute             *attribute   = nil;
+              
+              while (attribute = [objectiter nextObject])
+                {
+                  [realObj setValue:[attribute value] forKeyPath:[attribute 
keyPath]];
+                }
+              }
         }
 
       if ([realObj respondsToSelector: @selector(awakeFromNib)])

Modified: libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoading.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoading.m?rev=38878&r1=38877&r2=38878&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoading.m    
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSXibLoading.m    Thu Aug 
13 18:33:48 2015
@@ -1,24 +1,8 @@
 #import <Foundation/NSObject.h>
+#import <AppKit/NSNibConnector.h>
 #import <Foundation/NSKeyedArchiver.h>
 #import "GNUstepGUI/GSXibElement.h"
-
-@interface IBUserDefinedRuntimeAttributesPlaceholder : NSObject <NSCoding>
-{
-  NSString *typeIdentifier;
-  NSString *keyPath;
-  id value;
-}
-
-- (void) setTypeIdentifier: (NSString *)type;
-- (NSString *) typeIdentifier;
-
-- (void) setKeyPath: (NSString *)keyPath;
-- (NSString *) keyPath;
-
-- (void) setValue: (id)value;
-- (id) value;
-
-@end
+#import "GNUstepGUI/GSXibLoading.h"
 
 @interface IBAccessibilityAttribute : NSObject <NSCoding>
 @end
@@ -29,18 +13,15 @@
 @interface IBLayoutConstant : NSObject <NSCoding>
 @end
 
-@implementation IBUserDefinedRuntimeAttributesPlaceholder
+@implementation IBUserDefinedRuntimeAttribute
 
 - (void) encodeWithCoder: (NSCoder *)coder
 {
   if([coder allowsKeyedCoding])
     {
-      [coder encodeObject: typeIdentifier
-                  forKey: @"typeIdentifier"];
-      [coder encodeObject: keyPath
-                  forKey: @"keyPath"];
-      [coder encodeObject: value 
-                  forKey: @"value"];
+      [coder encodeObject: typeIdentifier forKey: @"typeIdentifier"];
+      [coder encodeObject: keyPath forKey: @"keyPath"];
+      [coder encodeObject: value forKey: @"value"];
     }
 }
 
@@ -87,6 +68,49 @@
 
 @end
 
+@implementation IBUserDefinedRuntimeAttributesPlaceholder
+
+- (void) encodeWithCoder: (NSCoder *)coder
+{
+  if([coder allowsKeyedCoding])
+  {
+    [coder encodeObject: name forKey: 
@"IBUserDefinedRuntimeAttributesPlaceholderName"];
+    [coder encodeObject: runtimeAttributes forKey: 
@"userDefinedRuntimeAttributes"];
+  }
+}
+
+- (id) initWithCoder: (NSCoder *)coder
+{
+  if([coder allowsKeyedCoding])
+  {
+    [self setName: [coder decodeObjectForKey: 
@"IBUserDefinedRuntimeAttributesPlaceholderName"]];
+    [self setRuntimeAttributes: [coder decodeObjectForKey: 
@"userDefinedRuntimeAttributes"]];
+  }
+  return self;
+}
+
+- (void) setName: (NSString *)value
+{
+  ASSIGN(name, value);
+}
+
+- (NSString *) name
+{
+  return name;
+}
+
+- (void) setRuntimeAttributes: (NSString *)attrbutes
+{
+  ASSIGN(runtimeAttributes, attrbutes);
+}
+
+- (NSString *) runtimeAttributes
+{
+  return runtimeAttributes;
+}
+
+@end
+
 @implementation IBAccessibilityAttribute
 
 - (void) encodeWithCoder: (NSCoder *)coder


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to