From 2dcc7ec7b4a8bca861010859526cfd240ac75308 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Sat, 11 Aug 2012 20:49:55 +0200 Subject: [PATCH] Keep version of mate (installed) in defaults This is so that we know when to update the installed version. --- Frameworks/Preferences/src/Keys.h | 1 + Frameworks/Preferences/src/Keys.mm | 1 + Frameworks/Preferences/src/TerminalPreferences.mm | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/Frameworks/Preferences/src/Keys.h b/Frameworks/Preferences/src/Keys.h index 7e16ceca..19ec8b30 100644 --- a/Frameworks/Preferences/src/Keys.h +++ b/Frameworks/Preferences/src/Keys.h @@ -52,6 +52,7 @@ PUBLIC extern NSString* const kUserDefaultsLastBundleUpdateCheckKey; // ============ PUBLIC extern NSString* const kUserDefaultsMateInstallPathKey; +PUBLIC extern NSString* const kUserDefaultsMateInstallVersionKey; PUBLIC extern NSString* const kUserDefaultsDisableRMateServerKey; PUBLIC extern NSString* const kUserDefaultsRMateServerListenKey; diff --git a/Frameworks/Preferences/src/Keys.mm b/Frameworks/Preferences/src/Keys.mm index 7b730cec..106263c2 100644 --- a/Frameworks/Preferences/src/Keys.mm +++ b/Frameworks/Preferences/src/Keys.mm @@ -119,6 +119,7 @@ NSString* const kUserDefaultsLastBundleUpdateCheckKey = @"lastBundleUpdateChec // ============ NSString* const kUserDefaultsMateInstallPathKey = @"mateInstallPath"; +NSString* const kUserDefaultsMateInstallVersionKey = @"mateInstallVersion"; NSString* const kUserDefaultsDisableRMateServerKey = @"rmateServerDisabled"; NSString* const kUserDefaultsRMateServerListenKey = @"rmateServerListen"; // localhost (default), remote diff --git a/Frameworks/Preferences/src/TerminalPreferences.mm b/Frameworks/Preferences/src/TerminalPreferences.mm index ca164ffc..f4c0143d 100644 --- a/Frameworks/Preferences/src/TerminalPreferences.mm +++ b/Frameworks/Preferences/src/TerminalPreferences.mm @@ -7,6 +7,7 @@ #import #import #import +#import #import #import #import @@ -218,7 +219,10 @@ static bool uninstall_mate (std::string const& path) if(NSString* path = self.mateInstallPath) { if(access([path fileSystemRepresentation], F_OK) != 0) + { [[NSUserDefaults standardUserDefaults] removeObjectForKey:kUserDefaultsMateInstallPathKey]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:kUserDefaultsMateInstallVersionKey]; + } } installPathPopUp.target = self; @@ -249,7 +253,12 @@ static bool uninstall_mate (std::string const& path) if(NSString* srcPath = [[NSBundle mainBundle] pathForResource:@"mate" ofType:nil]) { if(install_mate(to_s(srcPath), to_s(dstPath))) + { [self setMateInstallPath:dstPath]; + std::string res = io::exec(to_s(srcPath), "--version", NULL); + if(regexp::match_t const& m = regexp::search("\\Amate ([\\d.]+)", res.data(), res.data() + res.size())) + [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithUTF8String:res.data() + m.begin(1) length:m.end(1) - m.begin(1)] forKey:kUserDefaultsMateInstallVersionKey]; + } } else {