-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beware of falling bricks! Huge refactoring commit #1: cleansing Spark…
…le of the plague that was SUUtilities.
- Loading branch information
andym
committed
Dec 22, 2007
1 parent
535416a
commit 63011aa
Showing
28 changed files
with
551 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// NSBundle+SUAdditions.h | ||
// Sparkle | ||
// | ||
// Created by Andy Matuschak on 12/21/07. | ||
// Copyright 2007 Andy Matuschak. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface NSBundle (SUAdditions) | ||
/*! | ||
@method | ||
@abstract Returns a name for the bundle suitable for display to the user. | ||
@discussion This is performed by asking NSFileManager for the display name of the bundle. | ||
*/ | ||
- (NSString *)name; | ||
|
||
/*! | ||
@method | ||
@abstract Returns the current internal version of the bundle. | ||
@discussion This uses the CFBundleVersion info value. This string is not appropriate for display to users: use -displayVersion instead. | ||
*/ | ||
- (NSString *)version; | ||
|
||
/*! | ||
@method | ||
@abstract Returns the bundle's version, suitable for display to the user. | ||
@discussion If the CFBundleShortVersionString is available and different from the CFBundleVersion, this looks like CFBundleShortVersionString (CFBundleVersion). If the version strings are the same or CFBundleShortVersionString is not defined, this is equivalent to -version. | ||
*/ | ||
- (NSString *)displayVersion; | ||
|
||
/*! | ||
@method | ||
@abstract Returns a suitable icon for this bundle. | ||
@discussion Uses the CFBundleIconFile icon if defined; otherwise, uses the default application icon. | ||
*/ | ||
- (NSImage *)icon; | ||
|
||
/*! | ||
@method | ||
@abstract Returns whether the application is running from a disk image. | ||
*/ | ||
- (BOOL)isRunningFromDiskImage; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// NSBundle+SUAdditions.m | ||
// Sparkle | ||
// | ||
// Created by Andy Matuschak on 12/21/07. | ||
// Copyright 2007 Andy Matuschak. All rights reserved. | ||
// | ||
|
||
#import "NSBundle+SUAdditions.h" | ||
#import "NSWorkspace_RBAdditions.h" | ||
|
||
@implementation NSBundle (SUAdditions) | ||
|
||
- (NSString *)name | ||
{ | ||
NSString *name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"]; | ||
if (name) | ||
return name; | ||
else | ||
return [[[NSFileManager defaultManager] displayNameAtPath:[self bundlePath]] stringByDeletingPathExtension]; | ||
} | ||
|
||
- (NSString *)version | ||
{ | ||
return [self objectForInfoDictionaryKey:@"CFBundleVersion"]; | ||
} | ||
|
||
- (NSString *)displayVersion | ||
{ | ||
NSString *shortVersionString = [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; | ||
if (shortVersionString) | ||
{ | ||
if ([shortVersionString isEqualToString:[self version]]) | ||
return shortVersionString; | ||
else | ||
return [shortVersionString stringByAppendingFormat:@" (%@)", [self version]]; | ||
} | ||
else | ||
return [self version]; // Fall back on the normal version string. | ||
} | ||
|
||
- (NSImage *)icon | ||
{ | ||
// Cache the application icon. | ||
NSString *iconPath = [self pathForResource:[self objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"]; | ||
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease]; | ||
if (icon) | ||
return icon; | ||
else // Use a default icon if none is defined. | ||
return [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)]; | ||
} | ||
|
||
- (BOOL)isRunningFromDiskImage | ||
{ | ||
return [[[NSWorkspace sharedWorkspace] propertiesForPath:[self bundlePath]] objectForKey:NSWorkspace_RBimagefilepath] != nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.