Miscellaneous improvements.
1.1 --- a/DateUtils.h Wed Apr 02 14:45:33 2008 -0700
1.2 +++ b/DateUtils.h Sun Apr 06 19:13:27 2008 -0700
1.3 @@ -8,5 +8,14 @@
1.4
1.5 #import <Cocoa/Cocoa.h>
1.6
1.7 +#ifdef __cplusplus
1.8 +extern "C" {
1.9 +#endif
1.10
1.11 +
1.12 NSTimeInterval TimeIntervalSinceBoot(void);
1.13 +
1.14 +
1.15 +#ifdef __cplusplus
1.16 +}
1.17 +#endif
2.1 --- a/GraphicsUtils.h Wed Apr 02 14:45:33 2008 -0700
2.2 +++ b/GraphicsUtils.h Sun Apr 06 19:13:27 2008 -0700
2.3 @@ -26,3 +26,6 @@
2.4
2.5 /** Moves/resizes r to fit inside container */
2.6 NSRect PinRect( NSRect r, NSRect container );
2.7 +
2.8 +OSStatus LoadFontsFromBundle( NSBundle *bundle );
2.9 +OSStatus LoadFontsFromPath( NSString* path );
3.1 --- a/GraphicsUtils.m Wed Apr 02 14:45:33 2008 -0700
3.2 +++ b/GraphicsUtils.m Sun Apr 06 19:13:27 2008 -0700
3.3 @@ -6,6 +6,8 @@
3.4 //
3.5
3.6 #import "GraphicsUtils.h"
3.7 +#import "FileUtils.h"
3.8 +#import <ApplicationServices/ApplicationServices.h>
3.9
3.10
3.11 @implementation NSImage (MYUtilities)
3.12 @@ -241,3 +243,32 @@
3.13 return r;
3.14
3.15 }
3.16 +
3.17 +
3.18 +OSStatus LoadFontsFromBundle( NSBundle *bundle )
3.19 +{
3.20 + NSString *fontsPath = [[bundle resourcePath] stringByAppendingPathComponent:@"Fonts"];
3.21 + if( fontsPath )
3.22 + return LoadFontsFromPath(fontsPath);
3.23 + else
3.24 + return fnfErr;
3.25 +}
3.26 +
3.27 +
3.28 +OSStatus LoadFontsFromPath( NSString* path )
3.29 +{
3.30 + // Tip of the hat to Buddy Kurz!
3.31 + FSRef fsRef;
3.32 + OSStatus err = PathToFSRef(path,&fsRef);
3.33 + if (err==noErr)
3.34 + err = ATSFontActivateFromFileReference(&fsRef,
3.35 + kATSFontContextLocal,
3.36 + kATSFontFormatUnspecified,
3.37 + NULL,
3.38 + kATSOptionFlagsDefault,
3.39 + NULL
3.40 + );
3.41 + if( err ) Warn(@"LoadFontsFromPath: Error %i for %@",err,path);
3.42 + return err;
3.43 +}
3.44 +
4.1 --- a/KVUtils.h Wed Apr 02 14:45:33 2008 -0700
4.2 +++ b/KVUtils.h Sun Apr 06 19:13:27 2008 -0700
4.3 @@ -59,8 +59,9 @@
4.4 keyPath: (NSString*)keyPath
4.5 action: (SEL)action;
4.6
4.7 +/** observed or keyPath may be nil, meaning wildcard */
4.8 - (void) stopObserving: (id)observedOrNil keyPath: (NSString*)keyPathOrNil;
4.9 -
4.10 +- (void) stopObserving: (id)observed;
4.11 - (void) stopObserving;
4.12
4.13 @end
5.1 --- a/KVUtils.m Wed Apr 02 14:45:33 2008 -0700
5.2 +++ b/KVUtils.m Sun Apr 06 19:13:27 2008 -0700
5.3 @@ -59,6 +59,7 @@
5.4 }@catch( NSException *x ) {
5.5 Warn(@"Uncaught exception in -[%@<%p> %s] while observing change of key-path %@ in %@<%p>: %@",
5.6 _target,_target, _action, _keyPath, _observed,_observed, x);
5.7 + [NSApp reportException: x];
5.8 }
5.9 }
5.10
5.11 @@ -148,6 +149,12 @@
5.12 }
5.13
5.14
5.15 +- (void) stopObserving: (id)observed
5.16 +{
5.17 + [self stopObserving: observed keyPath: nil];
5.18 +}
5.19 +
5.20 +
5.21 - (void) stopObserving: (id)observed keyPath: (NSString*)keyPath
5.22 {
5.23 // observed or keyPath may be nil
6.1 --- a/UniqueWindowController.h Wed Apr 02 14:45:33 2008 -0700
6.2 +++ b/UniqueWindowController.h Sun Apr 06 19:13:27 2008 -0700
6.3 @@ -14,6 +14,8 @@
6.4 + (UniqueWindowController*) instanceWith: (id)model;
6.5 + (UniqueWindowController*) openWith: (id)model;
6.6
6.7 ++ (BOOL) isModel: (id)model1 equalToModel: (id)model2;
6.8 +
6.9 @end
6.10
6.11
7.1 --- a/UniqueWindowController.m Wed Apr 02 14:45:33 2008 -0700
7.2 +++ b/UniqueWindowController.m Sun Apr 06 19:13:27 2008 -0700
7.3 @@ -13,11 +13,17 @@
7.4 @implementation UniqueWindowController
7.5
7.6
7.7 ++ (BOOL) isModel: (id)model1 equalToModel: (id)model2
7.8 +{
7.9 + return model1==model2;
7.10 +}
7.11 +
7.12 +
7.13 + (UniqueWindowController*) instanceWith: (id)model
7.14 {
7.15 for( NSWindow *window in OpenWindowsWithDelegateClass(self) ) {
7.16 UniqueWindowController *c = window.delegate;
7.17 - if( c.model == model )
7.18 + if( [self isModel: c.model equalToModel: model] )
7.19 return c;
7.20 }
7.21 return nil;