diff --git a/src/MacVim/English.lproj/Preferences.nib/classes.nib b/src/MacVim/English.lproj/Preferences.nib/classes.nib
index 1f6d11ed4a..d8cde7bef5 100644
--- a/src/MacVim/English.lproj/Preferences.nib/classes.nib
+++ b/src/MacVim/English.lproj/Preferences.nib/classes.nib
@@ -26,6 +26,8 @@
NSButton
integrationPreferences
NSView
+ obdBundleVersionLabel
+ NSTextField
uninstallOdbButton
NSButton
diff --git a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib
index c413ad6797..9d20775da9 100644
Binary files a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib and b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib differ
diff --git a/src/MacVim/MMPreferenceController.h b/src/MacVim/MMPreferenceController.h
index f86b509db2..255a522955 100644
--- a/src/MacVim/MMPreferenceController.h
+++ b/src/MacVim/MMPreferenceController.h
@@ -22,6 +22,7 @@
IBOutlet NSPopUpButton *editors;
IBOutlet NSButton *installOdbButton;
IBOutlet NSButton *uninstallOdbButton;
+ IBOutlet NSTextField* obdBundleVersionLabel;
}
diff --git a/src/MacVim/MMPreferenceController.m b/src/MacVim/MMPreferenceController.m
index 9e6f3f98b6..74bee4a724 100644
--- a/src/MacVim/MMPreferenceController.m
+++ b/src/MacVim/MMPreferenceController.m
@@ -83,6 +83,10 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom";
- (void)updateIntegrationPane;
- (void)setOdbEditorByName:(NSString *)name;
- (NSString *)odbEditorBundleIdentifier;
+- (NSString *)odbBundleSourceDir;
+- (NSString *)versionOfBundle:(NSString *)bundlePath;
+- (NSString *)odbBundleInstalledVersion;
+- (NSString *)odbBundleInstallVersion;
@end
@implementation MMPreferenceController
@@ -201,6 +205,8 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom";
// user changes settings in terminal, the changes are reflected in the
// dialog)
+ NSString *versionString;
+
// Check if ODB path exists before calling isFilePackageAtPath: otherwise
// an error is output to stderr on Tiger.
BOOL odbIsInstalled =
@@ -210,16 +216,44 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom";
// enable/disable buttons
if (odbIsInstalled) {
[installOdbButton setTitle:@"Update"];
- [installOdbButton setEnabled:YES]; //XXX: only if there'a new version
[uninstallOdbButton setEnabled:YES];
[editors setEnabled:YES];
+
+ NSString *installVersion = [self odbBundleInstallVersion];
+ NSString *installedVersion = [self odbBundleInstalledVersion];
+ switch ([installedVersion compare:installVersion
+ options:NSNumericSearch]) {
+ case NSOrderedAscending:
+ versionString = [NSString stringWithFormat:
+ @"Latest version is %@, you have %@.",
+ installVersion, installedVersion];
+ [installOdbButton setEnabled:YES];
+ break;
+ case NSOrderedSame:
+ versionString = [NSString stringWithFormat:
+ @"Latest version is %@. You have the latest version.",
+ installVersion];
+ [installOdbButton setEnabled:NO];
+ break;
+ case NSOrderedDescending:
+ versionString = [NSString stringWithFormat:
+ @"Latest version is %@, you have %@.",
+ installVersion, installedVersion];
+ [installOdbButton setEnabled:NO];
+ break;
+ }
} else {
[installOdbButton setTitle:@"Install"];
[installOdbButton setEnabled:YES];
[uninstallOdbButton setEnabled:NO];
[editors setEnabled:NO];
+
+ versionString = [NSString stringWithFormat:@"Latest version is %@.",
+ [self odbBundleInstallVersion]];
}
+ [obdBundleVersionLabel setStringValue:versionString];
+
// make sure the right editor is selected on the popup button
NSString *selectedTitle = kOdbEditorNameNone;
NSArray* keys = [supportedOdbEditors
@@ -259,11 +293,40 @@ NSString *kOdbEditorIdentifierWriteRoom = @"com.hogbaysoftware.WriteRoom";
[self setOdbEditorByName:[sender title]];
}
+- (NSString *)odbBundleSourceDir
+{
+ return [[[NSBundle mainBundle] resourcePath]
+ stringByAppendingString:@"/Edit in ODBEditor"];
+}
+
+// Returns the CFBundleVersion of a bundle. This assumes a bundle exists
+// at bundlePath.
+- (NSString *)versionOfBundle:(NSString *)bundlePath
+{
+ // -[NSBundle initWithPath:] caches a bundle, so if the bundle is replaced
+ // with a new bundle on disk, we get the old version. So we can't use it :-(
+
+ NSString *infoPath = [bundlePath
+ stringByAppendingString:@"/Contents/Info.plist"];
+ NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:infoPath];
+ return [info objectForKey:@"CFBundleVersion"];
+}
+
+- (NSString *)odbBundleInstalledVersion
+{
+ return [self versionOfBundle:ODBEDITOR_PATH];
+}
+
+- (NSString *)odbBundleInstallVersion
+{
+ return [self versionOfBundle:[[self odbBundleSourceDir]
+ stringByAppendingString:@"/Edit in ODBEditor.bundle"]];
+}
+
- (IBAction)installOdb:(id)sender
{
- NSString *source = [[[NSBundle mainBundle] resourcePath]
- stringByAppendingString: @"/Edit in ODBEditor"];
-
+ NSString *source = [self odbBundleSourceDir];
+
// It doesn't hurt to rm -rf the InputManager even if it's not there,
// the code is simpler that way.
NSArray *cmd = [NSArray arrayWithObjects:
diff --git a/src/MacVim/edit-in-odb/Info.plist b/src/MacVim/edit-in-odb/Info.plist
index 4e8d24ce6b..172183c0f5 100644
--- a/src/MacVim/edit-in-odb/Info.plist
+++ b/src/MacVim/edit-in-odb/Info.plist
@@ -6,20 +6,20 @@
English
CFBundleExecutable
${EXECUTABLE_NAME}
- CFBundleName
- ${PRODUCT_NAME}
CFBundleIconFile
CFBundleIdentifier
org.slashpunt.edit_in_odbeditor
CFBundleInfoDictionaryVersion
6.0
+ CFBundleName
+ ${PRODUCT_NAME}
CFBundlePackageType
BNDL
CFBundleSignature
????
CFBundleVersion
- 1.0
+ 1.1
NSPrincipalClass
EditInODBEditor