ODB Input Manager installer is version sensitive

The Integration prefs pane states which version of the input manager
currently is installed.  The Input Manager version is bumped from 1.0
to 1.1.
This commit is contained in:
Nico Weber
2008-03-01 20:00:30 +01:00
committed by Bjorn Winckler
parent 8ee6c93248
commit 042108b0ad
5 changed files with 73 additions and 7 deletions
+2
View File
@@ -26,6 +26,8 @@
<string>NSButton</string>
<key>integrationPreferences</key>
<string>NSView</string>
<key>obdBundleVersionLabel</key>
<string>NSTextField</string>
<key>uninstallOdbButton</key>
<string>NSButton</string>
</dict>
Binary file not shown.
+1
View File
@@ -22,6 +22,7 @@
IBOutlet NSPopUpButton *editors;
IBOutlet NSButton *installOdbButton;
IBOutlet NSButton *uninstallOdbButton;
IBOutlet NSTextField* obdBundleVersionLabel;
}
+67 -4
View File
@@ -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:
+3 -3
View File
@@ -6,20 +6,20 @@
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.slashpunt.edit_in_odbeditor</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.1</string>
<key>NSPrincipalClass</key>
<string>EditInODBEditor</string>
</dict>