Skip to content

Commit

Permalink
SUHost's technique for getting a generic bundle icon did not work, fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean McBride authored and Sean McBride committed Dec 30, 2009
1 parent f8fbf37 commit 152e6f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion SUHost.m
Expand Up @@ -83,7 +83,17 @@ - (NSImage *)icon
iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil];
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
// Use a default icon if none is defined.
if (!icon) { icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(bundle == [NSBundle mainBundle] ? kGenericApplicationIcon : UTGetOSTypeFromString(CFSTR("BNDL")))]; }
if (!icon) {
BOOL isMainBundle = (bundle == [NSBundle mainBundle]);

// Starting with 10.6, iconForFileType: accepts a UTI.
NSString *fileType = nil;
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_5)
fileType = isMainBundle ? NSFileTypeForHFSTypeCode(kGenericApplicationIcon) : @".bundle";
else
fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
}
return icon;
}

Expand Down

0 comments on commit 152e6f9

Please sign in to comment.