mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:00:46 +00:00
Temporary removal of NSNib pending bugfix. :)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18568 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b827f3792f
commit
4ab36d5d73
4 changed files with 150 additions and 49 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-02-08 20:56 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/GSNibTemplates.m: Backout of NSNib modification.
|
||||||
|
* Source/NSBundleAdditions.m: ditto.
|
||||||
|
* Source/NSNib.m: Commented out some code and private class.
|
||||||
|
|
||||||
2004-02-09 Fred Kiefer <FredKiefer@gmx.de>
|
2004-02-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSLayoutManager.m (-drawGlyphsForGlyphRange:atPoint:)
|
* Source/NSLayoutManager.m (-drawGlyphsForGlyphRange:atPoint:)
|
||||||
|
|
|
@ -161,13 +161,13 @@ static const int currentVersion = 1; // GSNibItem version number...
|
||||||
while ((key = [enumerator nextObject]) != nil)
|
while ((key = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
if ([context objectForKey: key] == nil ||
|
if ([context objectForKey: key] == nil ||
|
||||||
[key isEqualToString: @"NSNibOwner"]) // we want to send the message to the owner
|
[key isEqualToString: @"NSOwner"]) // we want to send the message to the owner
|
||||||
{
|
{
|
||||||
if([key isEqualToString: @"NSWindowsMenu"] == NO && // we don't want to send a message to these menus twice,
|
if([key isEqualToString: @"NSWindowsMenu"] == NO && // we don't want to send a message to these menus twice,
|
||||||
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes.
|
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes.
|
||||||
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable.
|
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable.
|
||||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
[key isEqualToString: @"NSDeferred"] == NO &&
|
||||||
[key isEqualToString: @"NSNibTopLevelObjects"] == NO &&
|
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
|
||||||
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
||||||
{
|
{
|
||||||
id o = [nameTable objectForKey: key];
|
id o = [nameTable objectForKey: key];
|
||||||
|
@ -180,12 +180,12 @@ static const int currentVersion = 1; // GSNibItem version number...
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if the user has passed in the NSNibTopLevelObjects key.
|
* See if the user has passed in the NSTopLevelObjects key.
|
||||||
* This is an implementation of an undocumented, but commonly used feature
|
* This is an implementation of an undocumented, but commonly used feature
|
||||||
* of nib files to allow the release of the top level objects in the nib
|
* of nib files to allow the release of the top level objects in the nib
|
||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
obj = [context objectForKey: @"NSNibTopLevelObjects"];
|
obj = [context objectForKey: @"NSTopLevelObjects"];
|
||||||
if([obj isKindOfClass: [NSMutableArray class]])
|
if([obj isKindOfClass: [NSMutableArray class]])
|
||||||
{
|
{
|
||||||
topLevelObjects = obj;
|
topLevelObjects = obj;
|
||||||
|
@ -208,7 +208,7 @@ static const int currentVersion = 1; // GSNibItem version number...
|
||||||
[key isEqualToString: @"NSServicesMenu"] == NO &&
|
[key isEqualToString: @"NSServicesMenu"] == NO &&
|
||||||
[key isEqualToString: @"NSVisible"] == NO &&
|
[key isEqualToString: @"NSVisible"] == NO &&
|
||||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
[key isEqualToString: @"NSDeferred"] == NO &&
|
||||||
[key isEqualToString: @"NSNibTopLevelObjects"] == NO &&
|
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
|
||||||
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
||||||
{
|
{
|
||||||
id o = [nameTable objectForKey: key];
|
id o = [nameTable objectForKey: key];
|
||||||
|
@ -220,7 +220,7 @@ static const int currentVersion = 1; // GSNibItem version number...
|
||||||
{
|
{
|
||||||
if(topLevelObjects == nil)
|
if(topLevelObjects == nil)
|
||||||
{
|
{
|
||||||
// It is expected, if the NSNibTopLevelObjects key is not passed in,
|
// It is expected, if the NSTopLevelObjects key is not passed in,
|
||||||
// that the user has opted to either allow these objects to leak or
|
// that the user has opted to either allow these objects to leak or
|
||||||
// to release them explicitly.
|
// to release them explicitly.
|
||||||
RETAIN(o);
|
RETAIN(o);
|
||||||
|
|
|
@ -45,10 +45,8 @@
|
||||||
#include <Foundation/NSUserDefaults.h>
|
#include <Foundation/NSUserDefaults.h>
|
||||||
#include <Foundation/NSKeyValueCoding.h>
|
#include <Foundation/NSKeyValueCoding.h>
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
#include <Foundation/NSURL.h>
|
|
||||||
#include "AppKit/NSNibConnector.h"
|
#include "AppKit/NSNibConnector.h"
|
||||||
#include "AppKit/NSNibLoading.h"
|
#include "AppKit/NSNibLoading.h"
|
||||||
#include "AppKit/NSNib.h"
|
|
||||||
#include "GNUstepGUI/GSNibTemplates.h"
|
#include "GNUstepGUI/GSNibTemplates.h"
|
||||||
#include "GNUstepGUI/IMLoading.h"
|
#include "GNUstepGUI/IMLoading.h"
|
||||||
|
|
||||||
|
@ -187,11 +185,66 @@
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// declare this here to avoid a compiler warning...
|
/*
|
||||||
@interface NSNib (GNUstepPrivate)
|
* This private class is used to collect the nib items while the
|
||||||
+ (NSString *) _nibFilename: (NSString *)fileName;
|
* .gorm file is being unarchived. This is done to allow only
|
||||||
|
* the top level items to be retained in a clean way. The reason it's
|
||||||
|
* being done this way is because old .gorm files don't have any
|
||||||
|
* array within the nameTable which indicates the objects which are
|
||||||
|
* considered top level, so there is no clean and generic way to determine
|
||||||
|
* this. Basically the top level items are any instances of or instances
|
||||||
|
* of subclasses of NSMenu, NSWindow, or any controller class.
|
||||||
|
* It's the last one that's hairy. Controller classes are
|
||||||
|
* represented in .gorm files by the GSNibItem class, but once they transform
|
||||||
|
* into the actual class instance it's not easy to tell if it should be
|
||||||
|
* retained or not since there are a lot of other things stored in the nameTable
|
||||||
|
* as well. GJC
|
||||||
|
*/
|
||||||
|
@interface _GSNibItemCollector : NSObject
|
||||||
|
{
|
||||||
|
NSMutableArray *items;
|
||||||
|
}
|
||||||
|
- (void) handleNotification: (NSNotification *)notification;
|
||||||
|
- (NSMutableArray *)items;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation _GSNibItemCollector
|
||||||
|
- (void) handleNotification: (NSNotification *)notification;
|
||||||
|
{
|
||||||
|
id obj = [notification object];
|
||||||
|
[items addObject: obj];
|
||||||
|
}
|
||||||
|
|
||||||
|
- init
|
||||||
|
{
|
||||||
|
if((self = [super init]) != nil)
|
||||||
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
|
// add myself as an observer and initialize the items array.
|
||||||
|
[nc addObserver: self
|
||||||
|
selector: @selector(handleNotification:)
|
||||||
|
name: @"__GSInternalNibItemAddedNotification"
|
||||||
|
object: nil];
|
||||||
|
items = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
RELEASE(items);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray *)items
|
||||||
|
{
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation NSBundle (NSBundleAdditions)
|
@implementation NSBundle (NSBundleAdditions)
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -230,15 +283,11 @@ Class gmodel_class(void)
|
||||||
externalNameTable: (NSDictionary*)context
|
externalNameTable: (NSDictionary*)context
|
||||||
withZone: (NSZone*)zone
|
withZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
NSString *ext = [fileName pathExtension];
|
BOOL loaded = NO;
|
||||||
NSNib *nib = nil;
|
NSUnarchiver *unarchiver = nil;
|
||||||
BOOL result = NO;
|
NSString *ext = [fileName pathExtension];
|
||||||
NSMutableDictionary *ctx = nil;
|
id nibitems = nil;
|
||||||
|
|
||||||
/*
|
|
||||||
* Determine if we're loading a .gorm or a .gmodel
|
|
||||||
* if the extension is .nib.
|
|
||||||
*/
|
|
||||||
if ([ext isEqual: @"nib"])
|
if ([ext isEqual: @"nib"])
|
||||||
{
|
{
|
||||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
|
@ -264,42 +313,78 @@ Class gmodel_class(void)
|
||||||
if ([ext isEqualToString: @"gmodel"])
|
if ([ext isEqualToString: @"gmodel"])
|
||||||
{
|
{
|
||||||
return [gmodel_class() loadIMFile: fileName
|
return [gmodel_class() loadIMFile: fileName
|
||||||
owner: [context objectForKey: @"NSOwner"]];
|
owner: [context objectForKey: @"NSOwner"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a temporary context dictionary, containing all of the entries of the
|
NSDebugLog(@"Loading Nib `%@'...\n", fileName);
|
||||||
// one passed in, but replacing the NSOwner and NSTopLevelObjects entries with
|
NS_DURING
|
||||||
// the ones used by the NSNib class. We want *all* nib handling to happen in
|
|
||||||
// one unified place within NSNib. GJC
|
|
||||||
if(context != nil)
|
|
||||||
{
|
{
|
||||||
id obj = nil;
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
|
BOOL isDir = NO;
|
||||||
|
|
||||||
ctx = [NSMutableDictionary dictionaryWithDictionary: context];
|
if([mgr fileExistsAtPath: fileName isDirectory: &isDir])
|
||||||
|
|
||||||
// remove and set the owner...
|
|
||||||
obj = [ctx objectForKey: @"NSOwner"];
|
|
||||||
if(obj != nil)
|
|
||||||
{
|
{
|
||||||
[ctx removeObjectForKey: @"NSOwner"];
|
NSData *data = nil;
|
||||||
[ctx setObject: obj forKey: @"NSNibOwner"];
|
|
||||||
}
|
// if the data is in a directory, then load from objects.gorm in the directory
|
||||||
|
if(isDir == NO)
|
||||||
|
{
|
||||||
|
data = [NSData dataWithContentsOfFile: fileName];
|
||||||
|
NSDebugLog(@"Loaded data from file...");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSString *newFileName = [fileName stringByAppendingPathComponent: @"objects.gorm"];
|
||||||
|
data = [NSData dataWithContentsOfFile: newFileName];
|
||||||
|
NSDebugLog(@"Loaded data from %@...",newFileName);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove and set the top level objects...
|
if (data != nil)
|
||||||
obj = [ctx objectForKey: @"NSTopLevelObjects"];
|
{
|
||||||
if(obj != nil)
|
unarchiver = [[NSUnarchiver alloc] initForReadingWithData: data];
|
||||||
{
|
if (unarchiver != nil)
|
||||||
[ctx removeObjectForKey: @"NSTopLevelObjects"];
|
{
|
||||||
[ctx setObject: obj forKey: @"NSNibTopLevelObjects"];
|
id obj;
|
||||||
|
|
||||||
|
nibitems = [[_GSNibItemCollector alloc] init];
|
||||||
|
NSDebugLog(@"Invoking unarchiver");
|
||||||
|
[unarchiver setObjectZone: zone];
|
||||||
|
obj = [unarchiver decodeObject];
|
||||||
|
if (obj != nil)
|
||||||
|
{
|
||||||
|
NSArray *items = [nibitems items];
|
||||||
|
if ([obj isKindOfClass: [GSNibContainer class]])
|
||||||
|
{
|
||||||
|
NSDebugLog(@"Calling awakeWithContext");
|
||||||
|
|
||||||
|
[obj awakeWithContext: context
|
||||||
|
topLevelItems: items];
|
||||||
|
loaded = YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Nib '%@' without container object!", fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RELEASE(nibitems);
|
||||||
|
RELEASE(unarchiver);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSLog(@"Exception occured while loading model: %@",[localException reason]);
|
||||||
|
TEST_RELEASE(nibitems);
|
||||||
|
TEST_RELEASE(unarchiver);
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
// Load and instantiate the nib... release the NSNib object.
|
if (loaded == NO)
|
||||||
nib = [[NSNib alloc] initWithContentsOfURL: [NSURL fileURLWithPath: [NSNib _nibFilename: fileName]]];
|
{
|
||||||
result = [nib instantiateNibWithExternalNameTable: ctx withZone: zone];
|
NSLog(@"Failed to load Nib\n");
|
||||||
RELEASE(nib);
|
}
|
||||||
|
return loaded;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL) loadNibNamed: (NSString *)aNibName
|
+ (BOOL) loadNibNamed: (NSString *)aNibName
|
||||||
|
@ -405,13 +490,17 @@ Class gmodel_class(void)
|
||||||
withZone: (NSZone*)zone
|
withZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
NSString *path = [self pathForNibResource: fileName];
|
NSString *path = [self pathForNibResource: fileName];
|
||||||
if (fileName != nil)
|
|
||||||
|
if (path != nil)
|
||||||
{
|
{
|
||||||
return [NSBundle loadNibFile: path
|
return [NSBundle loadNibFile: path
|
||||||
externalNameTable: context
|
externalNameTable: context
|
||||||
withZone: (NSZone*)zone];
|
withZone: (NSZone*)zone];
|
||||||
}
|
}
|
||||||
return NO;
|
else
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
// end of NSBundleAdditions
|
// end of NSBundleAdditions
|
||||||
|
|
|
@ -69,6 +69,8 @@
|
||||||
* retained or not since there are a lot of other things stored in the nameTable
|
* retained or not since there are a lot of other things stored in the nameTable
|
||||||
* as well. GJC
|
* as well. GJC
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
@interface _GSNibItemCollector : NSObject
|
@interface _GSNibItemCollector : NSObject
|
||||||
{
|
{
|
||||||
NSMutableArray *items;
|
NSMutableArray *items;
|
||||||
|
@ -105,6 +107,7 @@
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
*/
|
||||||
|
|
||||||
@implementation NSNib
|
@implementation NSNib
|
||||||
|
|
||||||
|
@ -213,6 +216,7 @@
|
||||||
- (BOOL)instantiateNibWithExternalNameTable: (NSDictionary *)externalNameTable
|
- (BOOL)instantiateNibWithExternalNameTable: (NSDictionary *)externalNameTable
|
||||||
withZone: (NSZone *)zone
|
withZone: (NSZone *)zone
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
BOOL loaded = NO;
|
BOOL loaded = NO;
|
||||||
id nibitems = nil;
|
id nibitems = nil;
|
||||||
NSUnarchiver *unarchiver = nil;
|
NSUnarchiver *unarchiver = nil;
|
||||||
|
@ -264,6 +268,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return loaded;
|
return loaded;
|
||||||
|
*/
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue