2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSBundleAdditions</title>
|
1997-01-29 16:07:56 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
<abstract>Implementation of NSBundle Additions</abstract>
|
1997-01-29 16:07:56 +00:00
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
Copyright (C) 1997, 1999 Free Software Foundation, Inc.
|
1997-01-29 16:07:56 +00:00
|
|
|
|
|
|
|
Author: Simon Frankau <sgf@frankau.demon.co.uk>
|
|
|
|
Date: 1997
|
1999-01-15 10:14:28 +00:00
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: 1999
|
1997-01-29 16:07:56 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1999-09-09 02:56:20 +00:00
|
|
|
License along with this library;
|
|
|
|
If not, write to the Free Software Foundation,
|
2005-05-26 02:52:46 +00:00
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1997-01-29 16:07:56 +00:00
|
|
|
*/
|
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
#include "config.h"
|
1999-01-15 10:14:28 +00:00
|
|
|
#include <Foundation/NSArchiver.h>
|
1999-01-17 08:14:03 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
1997-01-29 16:07:56 +00:00
|
|
|
#include <Foundation/NSBundle.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
#include <Foundation/NSCoder.h>
|
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
#include <Foundation/NSDictionary.h>
|
2002-04-11 23:17:42 +00:00
|
|
|
#include <Foundation/NSDebug.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
#include <Foundation/NSEnumerator.h>
|
2002-04-11 23:17:42 +00:00
|
|
|
#include <Foundation/NSException.h>
|
1999-01-17 08:14:03 +00:00
|
|
|
#include <Foundation/NSInvocation.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
#include <Foundation/NSObjCRuntime.h>
|
2002-04-11 23:17:42 +00:00
|
|
|
#include <Foundation/NSPathUtilities.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
#include <Foundation/NSFileManager.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
#include <Foundation/NSString.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
#include <Foundation/NSUserDefaults.h>
|
2002-10-06 23:59:30 +00:00
|
|
|
#include <Foundation/NSKeyValueCoding.h>
|
2003-12-30 05:45:40 +00:00
|
|
|
#include <Foundation/NSNotification.h>
|
2003-06-13 15:01:12 +00:00
|
|
|
#include "AppKit/NSNibConnector.h"
|
|
|
|
#include "AppKit/NSNibLoading.h"
|
2003-07-31 23:52:10 +00:00
|
|
|
#include "GNUstepGUI/GSNibTemplates.h"
|
|
|
|
#include "GNUstepGUI/IMLoading.h"
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
|
|
@implementation NSNibConnector
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_src);
|
|
|
|
RELEASE(_dst);
|
|
|
|
RELEASE(_tag);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) destination
|
|
|
|
{
|
|
|
|
return _dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
{
|
|
|
|
[aCoder encodeObject: _src];
|
|
|
|
[aCoder encodeObject: _dst];
|
|
|
|
[aCoder encodeObject: _tag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) establishConnection
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-02-08 20:33:07 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1999-11-29 11:45:50 +00:00
|
|
|
{
|
2004-02-08 20:33:07 +00:00
|
|
|
if ([aDecoder allowsKeyedCoding])
|
|
|
|
{
|
|
|
|
ASSIGN(_src, [aDecoder decodeObjectForKey: @"NSSource"]);
|
|
|
|
ASSIGN(_dst, [aDecoder decodeObjectForKey: @"NSDestination"]);
|
|
|
|
ASSIGN(_tag, [aDecoder decodeObjectForKey: @"NSLabel"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_src];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_dst];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_tag];
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) label
|
|
|
|
{
|
|
|
|
return _tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) replaceObject: (id)anObject withObject: (id)anotherObject
|
|
|
|
{
|
1999-12-03 14:51:56 +00:00
|
|
|
if (_src == anObject)
|
|
|
|
{
|
|
|
|
ASSIGN(_src, anotherObject);
|
|
|
|
}
|
|
|
|
if (_dst == anObject)
|
|
|
|
{
|
|
|
|
ASSIGN(_dst, anotherObject);
|
|
|
|
}
|
|
|
|
if (_tag == anObject)
|
|
|
|
{
|
|
|
|
ASSIGN(_tag, anotherObject);
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) source
|
|
|
|
{
|
|
|
|
return _src;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDestination: (id)anObject
|
|
|
|
{
|
|
|
|
ASSIGN(_dst, anObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setLabel: (NSString*)label
|
|
|
|
{
|
|
|
|
ASSIGN(_tag, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSource: (id)anObject
|
|
|
|
{
|
|
|
|
ASSIGN(_src, anObject);
|
|
|
|
}
|
|
|
|
|
2005-02-05 20:39:49 +00:00
|
|
|
- (NSString *)description
|
|
|
|
{
|
|
|
|
NSString *desc = [NSString stringWithFormat: @"<%@ src=%@ dst=%@ label=%@>",
|
|
|
|
[super description],
|
|
|
|
[self source],
|
|
|
|
[self destination],
|
|
|
|
[self label]];
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
1999-11-29 11:45:50 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSNibControlConnector
|
|
|
|
- (void) establishConnection
|
|
|
|
{
|
|
|
|
SEL sel = NSSelectorFromString(_tag);
|
|
|
|
|
|
|
|
[_src setTarget: _dst];
|
|
|
|
[_src setAction: sel];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSNibOutletConnector
|
|
|
|
- (void) establishConnection
|
|
|
|
{
|
2000-01-03 18:42:16 +00:00
|
|
|
if (_src != nil)
|
|
|
|
{
|
|
|
|
NSString *selName;
|
|
|
|
SEL sel;
|
1999-11-29 11:45:50 +00:00
|
|
|
|
2002-03-26 16:24:42 +00:00
|
|
|
selName = [NSString stringWithFormat: @"set%@%@:",
|
|
|
|
[[_tag substringToIndex: 1] uppercaseString],
|
|
|
|
[_tag substringFromIndex: 1]];
|
2000-01-03 18:42:16 +00:00
|
|
|
sel = NSSelectorFromString(selName);
|
1999-11-29 11:45:50 +00:00
|
|
|
|
2001-05-08 02:42:45 +00:00
|
|
|
if (sel && [_src respondsToSelector: sel])
|
2000-01-03 18:42:16 +00:00
|
|
|
{
|
|
|
|
[_src performSelector: sel withObject: _dst];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-11-27 21:39:48 +00:00
|
|
|
const char *nam = [_tag cString];
|
|
|
|
const char *type;
|
|
|
|
unsigned int size;
|
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
Various whitespace cleanups, comment type fixes, and changes
to avoid warnings from recent versions of gcc.
* Headers/Additions/GNUstepGUI/GSToolbar.h (-_toolbars): Declare.
* Source/NSWindow+Toolbar.m: Remove conflicting declaration of
[NSToolbar -_toolbars].
* Headers/Additions/GNUstepGUI/GSServicesManager.h,
Source/GSServicesMananger.m (-item2title:, -validateMenuItem:):
Adjust argument types.
* Headers/AppKit/NSMenu.h (-validateMenuItem:): Adjust argument
type.
* Source/NSTextView.m (-sizeToFit): Don't use size uninitialized
if neither resizable flags is set.
(-insertText:): Adjust argument type.
* Headers/AppKit/NSResponder.h, Source/NSResponder.m (-insertText:):
Adjust argument type. Document.
* Headers/AppKit/NSView.h: Change type of ivar _window to NSWindow *.
* Source/GSTitleView.m (-mouseDown:): Always initialize
startWindowOrigin.
* Source/NSApplication.m (-setApplicationIconImage:): Add casts
to avoid warnings.
* Source/NSCell.m (-cellSize): Add default: case.
* Source/NSPasteboard.m
([GSFiltered -pasteboard:provideDataForType:]): Detect and warn if we
can't find a filter that will get us the desired type.
* Source/NSProgressIndicator.m: Comment out unused variable 'images'.
* Source/NSBezierPath.m: Declare GSBezierPath fully before using it.
(-bezierPathByFlatteningPath, -bezierPathByReversingPath): Make sure
variables are always initialized.
* Source/NSMenuView.m,
* Source/NSPrintOperation.m,
* Source/NSSplitView.m,
* Source/NSTableHeaderView.m: Make sure variables are always
initialized.
* Source/NSBox.m,
* Source/NSImageview.m,
* Source/NSText.m,
* Source/NSTextStorage.m: Add missing includes.
* Source/GSKeyBindingTable.m,
* Source/GSLayoutManager.m,
* Source/NSBitmapImageRep+PNM.m,
* Source/NSBundleAdditions.m,
* Source/NSLayoutManager.m,
* Source/nsimage-tiff.h,
* Source/tiff.m,
* Headers/Additions/GNUstepGUI/GSDisplayServer.h,
* Source/GSDisplayServer.m: Change signedness of various variables.
* Source/NSPanel.m (-sendEvent:): Remove.
* Source/NSWindow.m (-becomesKeyOnlyIfNeeded): New method.
(-_sendEvent:becomesKeyOnlyIfNeeded:): Remove. Move code ...
(-sendEvent:): ... here. Use -becomesKeyOnlyIfNeeded instead
of the argument.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20590 72102866-910b-0410-8b05-ffd578937521
2005-01-21 20:39:18 +00:00
|
|
|
int offset;
|
2002-11-27 21:39:48 +00:00
|
|
|
|
2000-01-03 18:42:16 +00:00
|
|
|
/*
|
2002-11-27 21:39:48 +00:00
|
|
|
* Use the GNUstep additional function to set the instance
|
|
|
|
* variable directly.
|
|
|
|
* FIXME - need some way to do this for libFoundation and
|
|
|
|
* Foundation based systems.
|
2000-01-03 18:42:16 +00:00
|
|
|
*/
|
2002-11-29 14:23:46 +00:00
|
|
|
if (GSObjCFindVariable(_src, nam, &type, &size, &offset))
|
2002-11-27 21:39:48 +00:00
|
|
|
{
|
|
|
|
GSObjCSetVariable(_src, offset, size, (void*)&_dst);
|
|
|
|
}
|
2000-01-03 18:42:16 +00:00
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
1997-01-29 16:07:56 +00:00
|
|
|
@implementation NSBundle (NSBundleAdditions)
|
|
|
|
|
2001-07-31 16:57:26 +00:00
|
|
|
static
|
|
|
|
Class gmodel_class(void)
|
|
|
|
{
|
|
|
|
static Class gmclass = Nil;
|
|
|
|
|
|
|
|
if (gmclass == Nil)
|
|
|
|
{
|
2002-02-11 16:29:15 +00:00
|
|
|
NSBundle *theBundle;
|
|
|
|
NSEnumerator *benum;
|
|
|
|
NSString *path;
|
|
|
|
|
|
|
|
/* Find the bundle */
|
|
|
|
benum = [NSStandardLibraryPaths() objectEnumerator];
|
|
|
|
while ((path = [benum nextObject]))
|
|
|
|
{
|
|
|
|
path = [path stringByAppendingPathComponent: @"Bundles"];
|
|
|
|
path = [path stringByAppendingPathComponent: @"libgmodel.bundle"];
|
|
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath: path])
|
|
|
|
break;
|
|
|
|
path = nil;
|
|
|
|
}
|
|
|
|
NSCAssert(path != nil, @"Unable to load gmodel bundle");
|
|
|
|
NSDebugLog(@"Loading gmodel from %@", path);
|
|
|
|
|
|
|
|
theBundle = [NSBundle bundleWithPath: path];
|
|
|
|
NSCAssert(theBundle != nil, @"Can't init gmodel bundle");
|
|
|
|
gmclass = [theBundle classNamed: @"GMModel"];
|
|
|
|
NSCAssert(gmclass, @"Can't load gmodel bundle");
|
2001-07-31 16:57:26 +00:00
|
|
|
}
|
|
|
|
return gmclass;
|
|
|
|
}
|
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
+ (BOOL) loadNibFile: (NSString*)fileName
|
|
|
|
externalNameTable: (NSDictionary*)context
|
|
|
|
withZone: (NSZone*)zone
|
1997-01-29 16:07:56 +00:00
|
|
|
{
|
2004-02-09 01:50:45 +00:00
|
|
|
BOOL loaded = NO;
|
|
|
|
NSUnarchiver *unarchiver = nil;
|
|
|
|
NSString *ext = [fileName pathExtension];
|
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
if ([ext isEqual: @"nib"])
|
2002-01-24 17:02:33 +00:00
|
|
|
{
|
2002-02-11 16:29:15 +00:00
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
NSString *base = [fileName stringByDeletingPathExtension];
|
|
|
|
|
|
|
|
/* We can't read nibs, look for an equivalent gorm or gmodel file */
|
|
|
|
fileName = [base stringByAppendingPathExtension: @"gorm"];
|
|
|
|
if ([mgr isReadableFileAtPath: fileName])
|
|
|
|
{
|
|
|
|
ext = @"gorm";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-12 19:10:31 +00:00
|
|
|
fileName = [base stringByAppendingPathExtension: @"gmodel"];
|
2002-02-11 16:29:15 +00:00
|
|
|
ext = @"gmodel";
|
|
|
|
}
|
2002-01-24 17:02:33 +00:00
|
|
|
}
|
2000-07-30 08:20:51 +00:00
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
/*
|
|
|
|
* If the file to be read is a gmodel, use the GMModel method to
|
|
|
|
* read it in and skip the dearchiving below.
|
|
|
|
*/
|
|
|
|
if ([ext isEqualToString: @"gmodel"])
|
2000-07-30 08:20:51 +00:00
|
|
|
{
|
2001-07-31 16:57:26 +00:00
|
|
|
return [gmodel_class() loadIMFile: fileName
|
2004-02-09 01:50:45 +00:00
|
|
|
owner: [context objectForKey: @"NSOwner"]];
|
2000-07-30 08:20:51 +00:00
|
|
|
}
|
2004-02-08 06:38:37 +00:00
|
|
|
|
2004-02-09 01:50:45 +00:00
|
|
|
NSDebugLog(@"Loading Nib `%@'...\n", fileName);
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
BOOL isDir = NO;
|
2002-10-31 14:59:18 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([mgr fileExistsAtPath: fileName isDirectory: &isDir])
|
1999-01-15 10:14:28 +00:00
|
|
|
{
|
2004-02-09 01:50:45 +00:00
|
|
|
NSData *data = nil;
|
|
|
|
|
|
|
|
// if the data is in a directory, then load from objects.gorm in the directory
|
2005-11-16 11:34:25 +00:00
|
|
|
if (isDir == NO)
|
2004-02-09 01:50:45 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2000-01-17 07:18:42 +00:00
|
|
|
|
2004-02-09 01:50:45 +00:00
|
|
|
if (data != nil)
|
|
|
|
{
|
|
|
|
unarchiver = [[NSUnarchiver alloc] initForReadingWithData: data];
|
|
|
|
if (unarchiver != nil)
|
|
|
|
{
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
NSDebugLog(@"Invoking unarchiver");
|
|
|
|
[unarchiver setObjectZone: zone];
|
|
|
|
obj = [unarchiver decodeObject];
|
|
|
|
if (obj != nil)
|
|
|
|
{
|
|
|
|
if ([obj isKindOfClass: [GSNibContainer class]])
|
|
|
|
{
|
|
|
|
NSDebugLog(@"Calling awakeWithContext");
|
2004-06-29 03:04:28 +00:00
|
|
|
[obj awakeWithContext: context];
|
2004-02-09 01:50:45 +00:00
|
|
|
loaded = YES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"Nib '%@' without container object!", fileName);
|
|
|
|
}
|
|
|
|
}
|
2004-06-29 03:04:28 +00:00
|
|
|
// RELEASE(nibitems);
|
2004-02-09 01:50:45 +00:00
|
|
|
RELEASE(unarchiver);
|
|
|
|
}
|
|
|
|
}
|
1999-01-15 10:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-09 01:50:45 +00:00
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
NSLog(@"Exception occured while loading model: %@",[localException reason]);
|
2004-06-29 03:04:28 +00:00
|
|
|
// TEST_RELEASE(nibitems);
|
2004-02-09 01:50:45 +00:00
|
|
|
TEST_RELEASE(unarchiver);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
2000-09-23 02:05:09 +00:00
|
|
|
|
2004-02-09 01:50:45 +00:00
|
|
|
if (loaded == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"Failed to load Nib\n");
|
|
|
|
}
|
|
|
|
return loaded;
|
1997-01-29 16:07:56 +00:00
|
|
|
}
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
+ (BOOL) loadNibNamed: (NSString *)aNibName
|
|
|
|
owner: (id)owner
|
1997-01-29 16:07:56 +00:00
|
|
|
{
|
1999-01-15 10:14:28 +00:00
|
|
|
NSDictionary *table;
|
|
|
|
NSBundle *bundle;
|
|
|
|
|
|
|
|
if (owner == nil || aNibName == nil)
|
2002-02-11 16:29:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
1999-01-15 10:14:28 +00:00
|
|
|
table = [NSDictionary dictionaryWithObject: owner forKey: @"NSOwner"];
|
1999-11-29 11:45:50 +00:00
|
|
|
bundle = [self bundleForClass: [owner class]];
|
|
|
|
if (bundle == nil)
|
1999-01-15 10:14:28 +00:00
|
|
|
{
|
1999-11-29 11:45:50 +00:00
|
|
|
bundle = [self mainBundle];
|
1999-01-15 10:14:28 +00:00
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
return [bundle loadNibFile: aNibName
|
|
|
|
externalNameTable: table
|
|
|
|
withZone: [owner zone]];
|
1997-01-29 16:07:56 +00:00
|
|
|
}
|
|
|
|
|
2001-11-26 20:28:34 +00:00
|
|
|
- (NSString *) pathForNibResource: (NSString *)fileName
|
1999-11-29 11:45:50 +00:00
|
|
|
{
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 8];
|
|
|
|
NSArray *languages = [NSUserDefaults userLanguages];
|
|
|
|
NSString *rootPath = [self bundlePath];
|
|
|
|
NSString *primary;
|
|
|
|
NSString *language;
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
NSString *ext;
|
|
|
|
|
|
|
|
ext = [fileName pathExtension];
|
|
|
|
fileName = [fileName stringByDeletingPathExtension];
|
2003-12-30 17:52:16 +00:00
|
|
|
if ([ext isEqualToString: @"nib"] == YES)
|
|
|
|
{
|
|
|
|
ext = @"";
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Build an array of resource paths that differs from the normal order -
|
|
|
|
* we want a localized file in preference to a generic one.
|
|
|
|
*/
|
|
|
|
primary = [rootPath stringByAppendingPathComponent: @"Resources"];
|
|
|
|
enumerator = [languages objectEnumerator];
|
|
|
|
while ((language = [enumerator nextObject]))
|
|
|
|
{
|
|
|
|
NSString *langDir;
|
|
|
|
|
|
|
|
langDir = [NSString stringWithFormat: @"%@.lproj", language];
|
|
|
|
[array addObject: [primary stringByAppendingPathComponent: langDir]];
|
|
|
|
}
|
|
|
|
[array addObject: primary];
|
|
|
|
primary = rootPath;
|
|
|
|
enumerator = [languages objectEnumerator];
|
|
|
|
while ((language = [enumerator nextObject]))
|
|
|
|
{
|
|
|
|
NSString *langDir;
|
|
|
|
|
|
|
|
langDir = [NSString stringWithFormat: @"%@.lproj", language];
|
|
|
|
[array addObject: [primary stringByAppendingPathComponent: langDir]];
|
|
|
|
}
|
|
|
|
[array addObject: primary];
|
|
|
|
|
|
|
|
enumerator = [array objectEnumerator];
|
|
|
|
while ((rootPath = [enumerator nextObject]) != nil)
|
|
|
|
{
|
|
|
|
NSString *path;
|
|
|
|
|
2000-07-30 08:20:51 +00:00
|
|
|
rootPath = [rootPath stringByAppendingPathComponent: fileName];
|
|
|
|
// If the file does not have an extension, then we need to
|
|
|
|
// figure out what type of model file to load.
|
|
|
|
if ([ext isEqualToString: @""] == YES)
|
1999-11-29 11:45:50 +00:00
|
|
|
{
|
2000-07-30 08:20:51 +00:00
|
|
|
path = [rootPath stringByAppendingPathExtension: @"gorm"];
|
1999-11-29 11:45:50 +00:00
|
|
|
if ([mgr isReadableFileAtPath: path] == NO)
|
|
|
|
{
|
2003-12-30 17:52:16 +00:00
|
|
|
path = [rootPath stringByAppendingPathExtension: @"gmodel"];
|
1999-11-29 11:45:50 +00:00
|
|
|
if ([mgr isReadableFileAtPath: path] == NO)
|
|
|
|
{
|
2003-12-30 17:52:16 +00:00
|
|
|
continue;
|
1999-11-29 11:45:50 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-26 20:28:34 +00:00
|
|
|
return path;
|
1999-11-29 11:45:50 +00:00
|
|
|
}
|
2000-07-30 08:20:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
path = [rootPath stringByAppendingPathExtension: ext];
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([mgr isReadableFileAtPath: path])
|
2000-07-30 08:20:51 +00:00
|
|
|
{
|
2001-11-26 20:28:34 +00:00
|
|
|
return path;
|
2000-07-30 08:20:51 +00:00
|
|
|
}
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
}
|
2000-07-30 08:20:51 +00:00
|
|
|
|
2001-11-26 20:28:34 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) loadNibFile: (NSString*)fileName
|
|
|
|
externalNameTable: (NSDictionary*)context
|
|
|
|
withZone: (NSZone*)zone
|
|
|
|
{
|
|
|
|
NSString *path = [self pathForNibResource: fileName];
|
2004-02-09 01:50:45 +00:00
|
|
|
|
|
|
|
if (path != nil)
|
2002-02-11 16:29:15 +00:00
|
|
|
{
|
|
|
|
return [NSBundle loadNibFile: path
|
|
|
|
externalNameTable: context
|
|
|
|
withZone: (NSZone*)zone];
|
|
|
|
}
|
2004-02-09 01:50:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
}
|
1997-01-29 16:07:56 +00:00
|
|
|
@end
|
2003-08-23 01:03:40 +00:00
|
|
|
// end of NSBundleAdditions
|