Replaced a number of uses of [NSImage initWithContentsOfFile:] by a wrapper over [NSBundle imageForResource:], so they should scale up properly on retina displays.
--- a/Frameworks/AIUtilities Framework/Source/AIBundleAdditions.h Tue Jul 24 19:22:25 2012 +0100
+++ b/Frameworks/AIUtilities Framework/Source/AIBundleAdditions.h Tue Jul 24 21:38:06 2012 +0200
@@ -18,5 +18,6 @@
- (NSSet *)supportedDocumentExtensions;
+- (NSImage *)AI_imageForResource:(NSString *)resource; --- a/Frameworks/AIUtilities Framework/Source/AIBundleAdditions.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Frameworks/AIUtilities Framework/Source/AIBundleAdditions.m Tue Jul 24 21:38:06 2012 +0200
@@ -15,6 +15,13 @@
#import "AIBundleAdditions.h"
+#import "AIApplicationAdditions.h" +@interface NSBundle (LionCompatibility) +- (NSImage *)imageForResource:(NSString *)name; @implementation NSBundle (AIBundleAdditions)
@@ -54,4 +61,17 @@
return supportedDocumentTypes;
+- (NSImage *)AI_imageForResource:(NSString *)resource + if ([NSApp isOnLionOrNewer]) { + resource = [resource stringByDeletingPathExtension]; + return [self imageForResource:resource]; + return [[[NSImage alloc] initByReferencingFile:[self pathForImageResource:resource]] autorelease]; --- a/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m Tue Jul 24 21:38:06 2012 +0200
@@ -15,6 +15,7 @@
#import "AIImageAdditions.h"
+#import "AIBundleAdditions.h" @interface NSImage (AIImageAdditions_PRIVATE)
@@ -27,22 +28,11 @@
+ (NSImage *)imageNamed:(NSString *)name forClass:(Class)inClass loadLazily:(BOOL)flag
ownerBundle = [NSBundle bundleForClass:inClass];
- imagePath = [ownerBundle pathForImageResource:name];
- image = [[NSImage alloc] initByReferencingFile:imagePath];
- image = [[NSImage alloc] initWithContentsOfFile:imagePath];
- return [image autorelease];
+ return [ownerBundle AI_imageForResource:name]; // Returns an image from the owners bundle with the specified name
--- a/Frameworks/Adium Framework/Source/AIGroupChatStatusIcons.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Frameworks/Adium Framework/Source/AIGroupChatStatusIcons.m Tue Jul 24 21:38:06 2012 +0200
@@ -17,6 +17,7 @@
#import "AIGroupChatStatusIcons.h"
#import <AIUtilities/AIColorAdditions.h>
+#import <AIUtilities/AIBundleAdditions.h> @interface AIGroupChatStatusIcons()
+ (NSURL *)currentPackURL;
@@ -116,14 +117,11 @@
- (NSImage *)imageForKey:(NSString *)key
- NSString *imagePath = nil;
if (!iconInfo || ![iconInfo objectForKey:key]) {
- imagePath = [xtraBundle pathForImageResource:[iconInfo objectForKey:key]];
- return [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
+ return [xtraBundle AI_imageForResource:[iconInfo objectForKey:key]]; #pragma mark Color retrieval
--- a/Frameworks/Adium Framework/Source/AIStatusIcons.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Frameworks/Adium Framework/Source/AIStatusIcons.m Tue Jul 24 21:38:06 2012 +0200
@@ -20,6 +20,7 @@
#import <Adium/AIStatusIcons.h>
#import <Adium/AIStatusControllerProtocol.h>
#import <AIUtilities/AIImageAdditions.h>
+#import <AIUtilities/AIBundleAdditions.h> @implementation AIStatusIcons
@@ -331,10 +332,9 @@
- NSString *anIconPath = [inPath stringByAppendingPathComponent:[previewIconNames objectForKey:iconID]];
- if ((anIcon = [[[NSImage alloc] initWithContentsOfFile:anIconPath] autorelease])) {
+ if ((anIcon = [xtraBundle AI_imageForResource:[previewIconNames objectForKey:iconID]])) { NSSize anIconSize = [anIcon size];
NSRect targetRect = NSMakeRect(xOrigin, 0, PREVIEW_MENU_IMAGE_SIZE, PREVIEW_MENU_IMAGE_SIZE);
--- a/Plugins/Purple Service/AMPurpleJabberServiceDiscoveryBrowserController.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Plugins/Purple Service/AMPurpleJabberServiceDiscoveryBrowserController.m Tue Jul 24 21:38:06 2012 +0200
@@ -19,6 +19,7 @@
#import <libpurple/jabber.h>
#import <Adium/DCJoinChatWindowController.h>
#import "DCPurpleJabberJoinChatViewController.h"
+#import <AIUtilities/AIBundleAdditions.h> @implementation AMPurpleJabberServiceDiscoveryBrowserController
@@ -311,7 +312,7 @@
BOOL expanded = [outlineView isItemExpanded:item];
if (expanded && [item items] == nil) {
- downloadprogress = [[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForResource:@"downloadprogress" ofType:@"png"]];
+ downloadprogress = [[NSBundle bundleForClass:[self class]] AI_imageForResource:@"downloadprogress"]; NSSize imgsize = [downloadprogress size];
NSImage *img = [[NSImage alloc] initWithSize:imgsize];
NSAffineTransform *transform = [NSAffineTransform transform];
--- a/Source/AIMenuBarIcons.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Source/AIMenuBarIcons.m Tue Jul 24 21:38:06 2012 +0200
@@ -15,6 +15,7 @@
#import "AIMenuBarIcons.h"
+#import <AIUtilities/AIBundleAdditions.h> #import <Adium/AIXtraInfo.h>
#import <AIUtilities/AIImageAdditions.h>
#import <QuartzCore/CoreImage.h>
@@ -68,15 +69,12 @@
- (NSImage *)imageForKey:(NSString *)keyName
// This set doesn't contain an Icons dictionary entry. It's invalid.
- imagePath = [xtraBundle pathForImageResource:[iconInfo objectForKey:keyName]];
- return [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
+ return [xtraBundle AI_imageForResource:[iconInfo objectForKey:keyName]]; - (BOOL)keyOfTypeExists:(NSString *)keyName
@@ -122,10 +120,9 @@
for (NSString *iconID in [NSArray arrayWithObjects:@"Online",@"Offline",nil]) {
- NSString *anIconPath = [menuIconsBundle pathForImageResource:[imageInfo objectForKey:iconID]];
- if ((anIcon = [[[NSImage alloc] initWithContentsOfFile:anIconPath] autorelease])) {
+ if ((anIcon = [menuIconsBundle AI_imageForResource:[imageInfo objectForKey:iconID]])) { NSSize anIconSize = [anIcon size];
NSRect targetRect = NSMakeRect(xOrigin, 0, PREVIEW_MENU_IMAGE_SIZE, PREVIEW_MENU_IMAGE_SIZE);
--- a/Source/AIStatusIconPreviewController.m Tue Jul 24 19:22:25 2012 +0100
+++ b/Source/AIStatusIconPreviewController.m Tue Jul 24 21:38:06 2012 +0200
@@ -15,6 +15,7 @@
#import "AIStatusIconPreviewController.h"
+#import <AIUtilities/AIBundleAdditions.h> @implementation AIStatusIconPreviewController
@@ -35,8 +36,7 @@
images = [[NSMutableArray alloc] init];
for (NSString *imageName in [iconDict objectEnumerator]) {
- NSString *imagePath = [resourcePath stringByAppendingPathComponent:imageName];
- NSImage *image = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
+ NSImage *image = [xtraInfo.bundle AI_imageForResource:imageName]; [images addObject:image];