Author: fredkiefer
Date: Thu Jun  2 23:37:03 2016
New Revision: 39836

URL: http://svn.gna.org/viewcvs/gnustep?rev=39836&view=rev
Log:
Add class NSIBUserDefinedRuntimeAttributesConnector to handle
newer NIB files.

Modified:
    libs/gui/trunk/ChangeLog
    libs/gui/trunk/Headers/Additions/GNUstepGUI/GSNibLoading.h
    libs/gui/trunk/Source/GSNibLoading.m
    libs/gui/trunk/Source/NSBitmapImageRep+PNG.m

Modified: libs/gui/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=39836&r1=39835&r2=39836&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog    (original)
+++ libs/gui/trunk/ChangeLog    Thu Jun  2 23:37:03 2016
@@ -1,3 +1,12 @@
+2016-06-02 Fred Kiefer <[email protected]>
+
+        * Source/NSBitmapImageRep+PNG.m:
+       Convert image before storing it.
+        * Headers/Additions/GNUstepGUI/GSNibLoading.h,
+        * Source/GSNibLoading.m:
+       Add class NSIBUserDefinedRuntimeAttributesConnector to handle
+       newer NIB files.
+
 2016-05-31  Richard Frith-Macdonald <[email protected]>
 
         * Headers/Additions/GNUstepGUI/GSTheme.h:
@@ -64,7 +73,7 @@
        * Source/NSWorkspace.m
        * Images/GNUMakefile
        Add Application folder (patch by Bertrand Dekoninck)
-       
+
 2016-03-22 Riccardo Mottola <[email protected]>
 
        * Headers/AppKit/NSWorkspace.h

Modified: libs/gui/trunk/Headers/Additions/GNUstepGUI/GSNibLoading.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Headers/Additions/GNUstepGUI/GSNibLoading.h?rev=39836&r1=39835&r2=39836&view=diff
==============================================================================
--- libs/gui/trunk/Headers/Additions/GNUstepGUI/GSNibLoading.h  (original)
+++ libs/gui/trunk/Headers/Additions/GNUstepGUI/GSNibLoading.h  Thu Jun  2 
23:37:03 2016
@@ -341,4 +341,31 @@
 - (void) setKeyPath: (NSString *)keyPath;
 - (void) setOptions: (NSDictionary *)options;
 @end
+
+@interface NSIBUserDefinedRuntimeAttributesConnector : NSObject <NSCoding>
+{
+  id _object;
+  NSArray *_keyPaths;
+  NSArray *_values;
+}
+
+- (void) instantiateWithObjectInstantiator: (id)instantiator;
+- (void) establishConnection;
+/*
+- (void) replaceObject: (id)anObject withObject: (id)anotherObject;
+- (void) setLabel: (id)label;
+- (id) label;
+- (void) setDestination: (id)destination;
+- (id) destination;
+- (void) setSource: (id)source;
+- (id) source;
+*/
+- (void) setObject: (id)object;
+- (id) object;
+- (void) setValues: (id)values;
+- (id) values;
+- (void) setKeyPaths: (id)keyPaths;
+- (id) keyPaths;
+@end
+
 #endif /* _GNUstep_H_GSNibCompatibility */

Modified: libs/gui/trunk/Source/GSNibLoading.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/GSNibLoading.m?rev=39836&r1=39835&r2=39836&view=diff
==============================================================================
--- libs/gui/trunk/Source/GSNibLoading.m        (original)
+++ libs/gui/trunk/Source/GSNibLoading.m        Thu Jun  2 23:37:03 2016
@@ -45,6 +45,7 @@
 #import <Foundation/NSEnumerator.h>
 #import <Foundation/NSException.h>
 #import <Foundation/NSKeyedArchiver.h>
+#import <Foundation/NSKeyValueCoding.h>
 #import <Foundation/NSObjCRuntime.h>
 #import <Foundation/NSSet.h>
 #import <Foundation/NSString.h>
@@ -1955,6 +1956,14 @@
           [obj instantiateWithInstantiator: self];          
           [obj establishConnection];
         }
+      else
+        {
+          if ([obj respondsToSelector: 
@selector(instantiateWithObjectInstantiator:)])
+            {
+              [obj instantiateWithObjectInstantiator: self];          
+              [obj establishConnection];
+            }
+        }
     }
 
   // awaken all objects except proxy objects.
@@ -2256,7 +2265,7 @@
         }
       if (_marker != nil)
         {
-          [coder encodeObject: _file forKey: @"NSMarker"];
+          [coder encodeObject: _marker forKey: @"NSMarker"];
         }      
     }
   else
@@ -2368,3 +2377,117 @@
   return self;
 }
 @end
+
+@implementation NSIBUserDefinedRuntimeAttributesConnector
+- (void) setObject: (id)object
+{
+  ASSIGN(_object, object);
+}
+
+- (id) object
+{
+  return _object;
+}
+
+- (void) setValues: (id)values
+{
+  ASSIGN(_values, values);
+}
+
+- (id) values
+{
+  return _values;
+}
+
+- (void) setKeyPaths: (id)keyPaths
+{
+  ASSIGN(_keyPaths, keyPaths);
+}
+
+- (id) keyPaths
+{
+  return _keyPaths;
+}
+
+- (void) dealloc
+{
+  RELEASE(_object);
+  RELEASE(_keyPaths);
+  RELEASE(_values);
+  [super dealloc];
+}
+
+- (void) encodeWithCoder: (NSCoder *)coder
+{
+  if ([coder allowsKeyedCoding])
+    {
+      if (_object != nil)
+        {
+          [coder encodeObject: _object forKey: @"NSObject"];
+        }
+      if (_keyPaths != nil)
+        {
+          [coder encodeObject: _keyPaths forKey: @"NSKeyPaths"];
+        }      
+      if (_values != nil)
+        {
+          [coder encodeObject: _values forKey: @"NSValues"];
+        }      
+    }
+  else
+    {
+      [coder encodeObject: _object];
+      [coder encodeObject: _keyPaths];
+      [coder encodeObject: _values];
+    }
+}
+
+- (id) initWithCoder: (NSCoder *)coder
+{
+  if ([coder allowsKeyedCoding])
+    {
+      if ([coder containsValueForKey: @"NSObject"])
+        {
+          ASSIGN(_object, [coder decodeObjectForKey: @"NSObject"]);
+        }
+      if ([coder containsValueForKey: @"NSKeyPaths"])
+        {
+          ASSIGN(_keyPaths, [coder decodeObjectForKey: @"NSKeyPaths"]);
+        }
+      if ([coder containsValueForKey: @"NSValues"])
+        {
+          ASSIGN(_values, [coder decodeObjectForKey: @"NSValues"]);
+        }
+    }
+  else
+    {
+      ASSIGN(_object, [coder decodeObject]);
+      ASSIGN(_keyPaths, [coder decodeObject]);
+      ASSIGN(_values, [coder decodeObject]);
+    }
+  
+  return self;
+}
+
+- (void) establishConnection
+{
+  // Loop over key paths and values and use KVC on object
+  NSEnumerator *keyEn = [_keyPaths objectEnumerator];
+  NSEnumerator *valEn = [_values objectEnumerator];
+  id key;
+
+  while ((key = [keyEn nextObject]) != nil)
+    {
+      id val = [valEn nextObject];
+
+      [_object setValue: val forKeyPath: key];
+    }
+}
+
+- (void) instantiateWithObjectInstantiator: (id)instantiator
+{
+  [self setObject: [(id<GSInstantiator>)instantiator instantiateObject: 
_object]];
+  // FIXME Should handle values too
+}
+
+@end

Modified: libs/gui/trunk/Source/NSBitmapImageRep+PNG.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSBitmapImageRep%2BPNG.m?rev=39836&r1=39835&r2=39836&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSBitmapImageRep+PNG.m        (original)
+++ libs/gui/trunk/Source/NSBitmapImageRep+PNG.m        Thu Jun  2 23:37:03 2016
@@ -320,10 +320,19 @@
   NSNumber * gammaNumber = nil;
   double gamma = 0.0;
   
-  // FIXME: Need to convert to non-pre-multiplied format
-  if ([self isPlanar]) // don't handle planar yet
-  {
-    return nil;
+  // Need to convert to non-pre-multiplied format
+  if ([self isPlanar] || !(_format & NSAlphaNonpremultipliedBitmapFormat))
+  {
+    NSBitmapImageRep *converted = [self _convertToFormatBitsPerSample: 
_bitsPerSample
+                                                      samplesPerPixel: 
_numColors
+                                                             hasAlpha: 
_hasAlpha
+                                                             isPlanar: NO
+                                                       colorSpaceName: 
_colorSpace
+                                                         bitmapFormat: _format 
| NSAlphaNonpremultipliedBitmapFormat 
+                                                          bytesPerRow: 
_bytesPerRow
+                                                         bitsPerPixel: 
_bitsPerPixel];
+
+    return [converted _PNGRepresentationWithProperties: properties];
   } 
   // get the image parameters
   width = [self pixelsWide];


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

Reply via email to