diff --git a/Sparkle/SUApplicationInfo.h b/Sparkle/SUApplicationInfo.h index db4dd1ca..9aeeca68 100644 --- a/Sparkle/SUApplicationInfo.h +++ b/Sparkle/SUApplicationInfo.h @@ -10,11 +10,13 @@ NS_ASSUME_NONNULL_BEGIN +@class SUHost; + @interface SUApplicationInfo : NSObject + (BOOL)isBackgroundApplication:(NSApplication *)application; -+ (NSImage *)bestIconForBundle:(NSBundle *)bundle; ++ (NSImage *)bestIconForHost:(SUHost *)host; @end diff --git a/Sparkle/SUApplicationInfo.m b/Sparkle/SUApplicationInfo.m index c8fec0be..eb349af3 100644 --- a/Sparkle/SUApplicationInfo.m +++ b/Sparkle/SUApplicationInfo.m @@ -8,6 +8,7 @@ #import "SUApplicationInfo.h" #import "SUBundleIcon.h" +#import "SUHost.h" @implementation SUApplicationInfo @@ -16,16 +17,16 @@ return (application.activationPolicy == NSApplicationActivationPolicyAccessory); } -+ (NSImage *)bestIconForBundle:(NSBundle *)bundle ++ (NSImage *)bestIconForHost:(SUHost *)host { - NSURL *iconURL = [SUBundleIcon iconURLForBundle:bundle]; + NSURL *iconURL = [SUBundleIcon iconURLForHost:host]; NSImage *icon = (iconURL == nil) ? nil : [[NSImage alloc] initWithContentsOfURL:iconURL]; // Use a default icon if none is defined. if (!icon) { // this asumption may not be correct (eg. even though we're not the main bundle, it could be still be a regular app) // but still better than nothing if no icon was included - BOOL isMainBundle = (bundle == [NSBundle mainBundle]); + BOOL isMainBundle = [host.bundle isEqualTo:[NSBundle mainBundle]]; NSString *fileType = isMainBundle ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle; icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType]; diff --git a/Sparkle/SUAutomaticUpdateAlert.m b/Sparkle/SUAutomaticUpdateAlert.m index f49dae6e..5e1ae37e 100644 --- a/Sparkle/SUAutomaticUpdateAlert.m +++ b/Sparkle/SUAutomaticUpdateAlert.m @@ -61,7 +61,7 @@ - (NSImage *__nonnull)applicationIcon { - return [SUApplicationInfo bestIconForBundle:self.host.bundle]; + return [SUApplicationInfo bestIconForHost:self.host]; } - (NSString *__nonnull)titleText diff --git a/Sparkle/SUBundleIcon.h b/Sparkle/SUBundleIcon.h index f42be2fd..3e709b5d 100644 --- a/Sparkle/SUBundleIcon.h +++ b/Sparkle/SUBundleIcon.h @@ -10,9 +10,11 @@ NS_ASSUME_NONNULL_BEGIN +@class SUHost; + @interface SUBundleIcon : NSObject -+ (NSURL * _Nullable)iconURLForBundle:(NSBundle *)bundle; ++ (NSURL * _Nullable)iconURLForHost:(SUHost *)host; @end diff --git a/Sparkle/SUBundleIcon.m b/Sparkle/SUBundleIcon.m index a3d86a80..97e22698 100644 --- a/Sparkle/SUBundleIcon.m +++ b/Sparkle/SUBundleIcon.m @@ -7,21 +7,23 @@ // #import "SUBundleIcon.h" +#import "SUHost.h" @implementation SUBundleIcon -+ (NSURL *)iconURLForBundle:(NSBundle *)bundle +// Note: To obtain the most current bundle icon file from the Info dictionary, this should take a SUHost, not a NSBundle ++ (NSURL *)iconURLForHost:(SUHost *)host { - NSString *resource = [bundle objectForInfoDictionaryKey:@"CFBundleIconFile"]; + NSString *resource = [host objectForInfoDictionaryKey:@"CFBundleIconFile"]; if (resource == nil || ![resource isKindOfClass:[NSString class]]) { return nil; } - NSURL *iconURL = [bundle URLForResource:resource withExtension:@"icns"]; + NSURL *iconURL = [host.bundle URLForResource:resource withExtension:@"icns"]; // The resource could already be containing the path extension, so try again without the extra extension if (iconURL == nil) { - iconURL = [bundle URLForResource:resource withExtension:nil]; + iconURL = [host.bundle URLForResource:resource withExtension:nil]; } return iconURL; } diff --git a/Sparkle/SUStatusController.m b/Sparkle/SUStatusController.m index cdca9ff8..eb5ecbfc 100644 --- a/Sparkle/SUStatusController.m +++ b/Sparkle/SUStatusController.m @@ -66,7 +66,7 @@ - (NSImage *)applicationIcon { - return [SUApplicationInfo bestIconForBundle:self.host.bundle]; + return [SUApplicationInfo bestIconForHost:self.host]; } - (void)beginActionWithTitle:(NSString *)aTitle maxProgressValue:(double)aMaxProgressValue statusText:(NSString *)aStatusText diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 99d4ddba..e0f5cb90 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -314,7 +314,7 @@ // are focused to inform the user since there is no dock icon to notify them. if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) { [NSApp activateIgnoringOtherApps:YES]; } - [alert setIcon:[SUApplicationInfo bestIconForBundle:self.host.bundle]]; + [alert setIcon:[SUApplicationInfo bestIconForHost:self.host]]; [alert runModal]; if ([[updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)]) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index efda7f45..e44f00de 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -221,7 +221,7 @@ - (NSImage *)applicationIcon { - return [SUApplicationInfo bestIconForBundle:self.host.bundle]; + return [SUApplicationInfo bestIconForHost:self.host]; } - (NSString *)titleText diff --git a/Sparkle/SUUpdatePermissionPrompt.m b/Sparkle/SUUpdatePermissionPrompt.m index 23ee647e..a6b96378 100644 --- a/Sparkle/SUUpdatePermissionPrompt.m +++ b/Sparkle/SUUpdatePermissionPrompt.m @@ -100,7 +100,7 @@ - (NSImage *)icon { - return [SUApplicationInfo bestIconForBundle:self.host.bundle]; + return [SUApplicationInfo bestIconForHost:self.host]; } - (NSString *)promptDescription