Fix deprecated API compiler warning

This commit is contained in:
Bjorn Winckler
2009-01-06 22:05:50 +01:00
parent 2153ab22d7
commit c50143db47
3 changed files with 45 additions and 39 deletions
+45 -1
View File
@@ -128,6 +128,7 @@ static int executeInLoginShell(NSString *path, NSArray *args);
- (void)startWatchingVimDir;
- (void)stopWatchingVimDir;
- (void)handleFSEvent;
- (void)loadDefaultFont;
#ifdef MM_ENABLE_PLUGINS
- (void)removePlugInMenu;
@@ -207,7 +208,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
{
if (!(self = [super init])) return nil;
fontContainerRef = loadFonts();
[self loadDefaultFont];
vimControllers = [NSMutableArray new];
cachedVimControllers = [NSMutableArray new];
@@ -1878,6 +1879,49 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[self scheduleVimControllerPreloadAfterDelay:0.5];
}
- (void)loadDefaultFont
{
if (fontContainerRef)
return;
// Load all fonts in the Resouces folder of the app bundle.
NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
// This is the font activation API for OS X 10.5. Only compile
// this code if we're building on OS X 10.5 or later.
if (NULL != ATSFontActivateFromFileReference) { // Weakly linked
ATSFontActivateFromFileReference(&fsRef, kATSFontContextLocal,
kATSFontFormatUnspecified,
NULL, kATSOptionFlagsDefault,
&fontContainerRef);
}
#endif
#if (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4)
// The following font activation API was deprecated in OS X 10.5.
// Don't compile this code unless we're targeting OS X 10.4.
FSSpec fsSpec;
if (fontContainerRef == 0 &&
FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL,
&fsSpec, NULL) == noErr) {
ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
}
#endif
}
}
if (!fontContainerRef)
NSLog(@"WARNING: Failed to activate the default font (the app bundle "
"may be incomplete)");
}
@end // MMAppController (Private)
-5
View File
@@ -225,11 +225,6 @@ extern NSString *VimPBoardType;
// Loads all fonts in the Resouces folder of the app bundle and returns a font
// container reference (which should be used to deactivate the loaded fonts).
ATSFontContainerRef loadFonts();
@interface NSString (MMExtras)
- (NSString *)stringByEscapingSpecialFilenameCharacters;
-33
View File
@@ -100,39 +100,6 @@ NSString *VimPBoardType = @"VimPBoardType";
ATSFontContainerRef
loadFonts()
{
// This loads all fonts from the Resources folder. The fonts are only
// available to the process which loaded them, so loading has to be done
// once for MacVim and an additional time for each Vim process. The
// returned container ref should be used to deactiave the font.
//
// (Code taken from cocoadev.com)
ATSFontContainerRef fontContainerRef = 0;
NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
FSSpec fsSpec;
CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
NULL) == noErr) {
ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
}
}
}
return fontContainerRef;
}
@implementation NSString (MMExtras)
- (NSString *)stringByEscapingSpecialFilenameCharacters