aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPAboutController.m
diff options
context:
space:
mode:
authorStuart Connolly <stuart02@gmail.com>2014-01-19 03:57:43 +0000
committerStuart Connolly <stuart02@gmail.com>2014-01-19 03:57:43 +0000
commit49b797222d0dda7868e5b6ce566723fe2a6248f1 (patch)
tree0468902a1a76cbc55f5ffed573c4c1f8213509b6 /Source/SPAboutController.m
parent8b0f587b6aa4e16a2a7ba88cbb6f3a5165c52f45 (diff)
downloadsequelpro-49b797222d0dda7868e5b6ce566723fe2a6248f1.tar.gz
sequelpro-49b797222d0dda7868e5b6ce566723fe2a6248f1.tar.bz2
sequelpro-49b797222d0dda7868e5b6ce566723fe2a6248f1.zip
Display the short revision hash of the build alongside the revision number in the about dialog.
Diffstat (limited to 'Source/SPAboutController.m')
-rw-r--r--Source/SPAboutController.m54
1 files changed, 49 insertions, 5 deletions
diff --git a/Source/SPAboutController.m b/Source/SPAboutController.m
index c1a5c30a..921e0b83 100644
--- a/Source/SPAboutController.m
+++ b/Source/SPAboutController.m
@@ -35,13 +35,22 @@
static NSString *SPCreditsFilename = @"Credits";
static NSString *SPLicenseFilename = @"License";
+static NSString *SPAboutPanelNibName = @"AboutPanel";
+static NSString *SPShortVersionHashKey = @"SPVersionShortHash";
+
+@interface SPAboutController ()
+
+- (void)_setVersionLabel:(BOOL)isNightly;
+
+@end
+
@implementation SPAboutController
#pragma mark -
- (id)init
{
- return [super initWithWindowNibName:@"AboutPanel"];
+ return [super initWithWindowNibName:SPAboutPanelNibName];
}
- (void)awakeFromNib
@@ -52,10 +61,9 @@ static NSString *SPLicenseFilename = @"License";
BOOL isNightly = [version hasPrefix:@"Nightly"];
// Set the application name, but only include the major version if this is not a nightly build.
- [appNameVersionTextField setStringValue:(isNightly) ? @"Sequel Pro" : [NSString stringWithFormat:@"Sequel Pro %@", version]];
-
- // Set the bundle/build version
- [appBuildVersionTextField setStringValue:[NSString stringWithFormat:@"%@ %@", (isNightly) ? NSLocalizedString(@"Nightly Build", @"nightly build label") : NSLocalizedString(@"Build", @"build label") , [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
+ [appNameVersionTextField setStringValue:isNightly ? @"Sequel Pro" : [NSString stringWithFormat:@"Sequel Pro %@", version]];
+
+ [self _setVersionLabel:isNightly];
// Get the credits file contents
NSAttributedString *credits = [[[NSAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:SPCreditsFilename ofType:@"rtf"] documentAttributes:nil] autorelease];
@@ -90,4 +98,40 @@ static NSString *SPLicenseFilename = @"License";
[appLicensePanel orderOut:self];
}
+#pragma mark -
+#pragma mark Private API
+
+/**
+ * Set the UI version labels.
+ *
+ * @param isNightly Indicates whether or not this is a nightly build.
+ */
+- (void)_setVersionLabel:(BOOL)isNightly
+{
+ NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
+
+ // Get version numbers
+ NSString *bundleVersion = [infoDictionary objectForKey:(NSString *)kCFBundleVersionKey];
+ NSString *versionHash = [infoDictionary objectForKey:SPShortVersionHashKey];
+
+ BOOL hashIsEmpty = !versionHash && ![versionHash length];
+
+ NSString *textFieldString;
+
+ if (!bundleVersion && ![bundleVersion length] && hashIsEmpty) {
+ textFieldString = @"";
+ }
+ else {
+ textFieldString =
+ [NSString stringWithFormat:@"%@ %@%@",
+ isNightly ? NSLocalizedString(@"Nightly Build", @"nightly build label") : NSLocalizedString(@"Build", @"build label"),
+ bundleVersion,
+ hashIsEmpty ? @"" : [NSString stringWithFormat:@" (%@)", versionHash]];
+ }
+
+ NSLog(@"%@", textFieldString);
+
+ [appBuildVersionTextField setStringValue:textFieldString];
+}
+
@end