Save and restore the "substitution" preferences on 10.5/10.6. For 10.5 users, things like quote replacement are now saved. For 10.6 users, the whole mess of them are.
authorZachary West <zacw@adium.im>
Sat, 29 Aug 2009 19:20:15 -0400
changeset 2598 08f5b3c1e169
parent 2597 07e07f9788a6
child 2599 236abfc3797e
Save and restore the "substitution" preferences on 10.5/10.6. For 10.5 users, things like quote replacement are now saved. For 10.6 users, the whole mess of them are.

A few are now enabled by default, but just the things from before + the 10.6 "spelling" and "text replacement" substitutions.

This also creates AILeopardCompatibility.h.
Adium.xcodeproj/project.pbxproj
Frameworks/AIUtilities Framework/Source/AILeopardCompatibility.h
Frameworks/Adium Framework/Source/AIMessageEntryTextView.m
Plugins/Dual Window Interface/DualWindowDefaults.plist
--- a/Adium.xcodeproj/project.pbxproj	Wed Aug 26 13:17:35 2009 -0400
+++ b/Adium.xcodeproj/project.pbxproj	Sat Aug 29 19:20:15 2009 -0400
@@ -175,6 +175,7 @@
 		11D9156F0FFC0FEB00B39713 /* AIImageShackImageUploader.m in Sources */ = {isa = PBXBuildFile; fileRef = 11D915580FFC0E9C00B39713 /* AIImageShackImageUploader.m */; };
 		11D915720FFC100700B39713 /* AIGenericMultipartImageUploader.m in Sources */ = {isa = PBXBuildFile; fileRef = 11D915710FFC100700B39713 /* AIGenericMultipartImageUploader.m */; };
 		11E786810F8860210014612E /* AIJumpControlPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 11E7867F0F8860210014612E /* AIJumpControlPlugin.m */; };
+		11EC56FC1049E96F00C02587 /* AILeopardCompatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 1156F03D1049E83F002673FC /* AILeopardCompatibility.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		11EE1B4D0CDCFAF40097F246 /* oscar-adium.c in Sources */ = {isa = PBXBuildFile; fileRef = 11EE1B490CDCFAF40097F246 /* oscar-adium.c */; };
 		11EE1B4E0CDCFAF40097F246 /* oscar-adium.h in Headers */ = {isa = PBXBuildFile; fileRef = 11EE1B4A0CDCFAF40097F246 /* oscar-adium.h */; };
 		11EE1B4F0CDCFAF40097F246 /* ssl-openssl.c in Sources */ = {isa = PBXBuildFile; fileRef = 11EE1B4B0CDCFAF40097F246 /* ssl-openssl.c */; };
@@ -1898,6 +1899,7 @@
 		1150A9AE0FBE491300E0BD31 /* tr */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = tr; path = "Plugins/Purple Service/tr.lproj/ESIRCAccountView.nib"; sourceTree = "<group>"; };
 		1150A9AF0FBE491500E0BD31 /* zh_CN */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh_CN; path = "Plugins/Purple Service/zh_CN.lproj/ESIRCAccountView.nib"; sourceTree = "<group>"; };
 		1150A9B00FBE491700E0BD31 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh_TW; path = "Plugins/Purple Service/zh_TW.lproj/ESIRCAccountView.nib"; sourceTree = "<group>"; };
+		1156F03D1049E83F002673FC /* AILeopardCompatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AILeopardCompatibility.h; path = "Frameworks/AIUtilities Framework/Source/AILeopardCompatibility.h"; sourceTree = "<group>"; };
 		1163F0EA0F6C7A8300F12F5D /* AIURLShortenerPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIURLShortenerPlugin.h; path = ../../Source/AIURLShortenerPlugin.h; sourceTree = "<group>"; };
 		1163F0EB0F6C7A8300F12F5D /* AIURLShortenerPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIURLShortenerPlugin.m; path = ../../Source/AIURLShortenerPlugin.m; sourceTree = "<group>"; };
 		1164A90B0F7AD4AB00110AE4 /* AIContentTopic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIContentTopic.h; path = "Frameworks/Adium Framework/Source/AIContentTopic.h"; sourceTree = "<group>"; };
@@ -7463,6 +7465,7 @@
 				6334FF300F9C14BF003C77A9 /* Fun New Controls */,
 				6334FF050F9C14BF003C77A9 /* Fun New Classes */,
 				6334FF020F9C14BF003C77A9 /* Functions */,
+				1156F03D1049E83F002673FC /* AILeopardCompatibility.h */,
 			);
 			name = AIUtilities;
 			sourceTree = "<group>";
@@ -9159,6 +9162,7 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				11EC56FC1049E96F00C02587 /* AILeopardCompatibility.h in Headers */,
 				6334FFFF0F9C14C2003C77A9 /* AIFunctions.h in Headers */,
 				633400010F9C14C2003C77A9 /* JVMarkedScroller.h in Headers */,
 				633400030F9C14C2003C77A9 /* AIMutableOwnerArray.h in Headers */,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Frameworks/AIUtilities Framework/Source/AILeopardCompatibility.h	Sat Aug 29 19:20:15 2009 -0400
@@ -0,0 +1,49 @@
+/*
+ *  AILeopardCompatibility.h
+ *  Adium
+ *
+ *  Created by Zachary West on 2009-08-29.
+ *  Copyright 2009  . All rights reserved.
+ *
+ */
+
+#ifndef AILeopardCompatibility
+#define AILeopardCompatibility
+
+#import <AvailabilityMacros.h>
+
+#ifndef MAC_OS_X_VERSION_10_6
+#define MAC_OS_X_VERSION_10_6 1060
+#endif //ndef MAC_OS_X_VERSION_10_6
+
+#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED
+
+#ifdef __OBJC__
+@interface NSTextView(NSTextViewLeopardMethods)
+- (void)setAutomaticDataDetectionEnabled:(BOOL)flag;
+- (BOOL)isAutomaticDataDetectionEnabled;
+- (void)toggleAutomaticDataDetection:(id)sender;
+
+- (void)setAutomaticDashSubstitutionEnabled:(BOOL)flag;
+- (BOOL)isAutomaticDashSubstitutionEnabled;
+- (void)toggleAutomaticDashSubstitution:(id)sender;
+
+- (void)setAutomaticTextReplacementEnabled:(BOOL)flag;
+- (BOOL)isAutomaticTextReplacementEnabled;
+- (void)toggleAutomaticTextReplacement:(id)sender;
+
+- (void)setAutomaticSpellingCorrectionEnabled:(BOOL)flag;
+- (BOOL)isAutomaticSpellingCorrectionEnabled;
+- (void)toggleAutomaticSpellingCorrection:(id)sender;
+@end
+#endif
+
+#else //Not compiling for 10.6
+
+#if !defined(NS_REQUIRES_NIL_TERMINATION)
+#define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel))
+#endif
+
+#endif //MAC_OS_X_VERSION_10_6
+
+#endif //AILeopardCompatibility
--- a/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Wed Aug 26 13:17:35 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Sat Aug 29 19:20:15 2009 -0400
@@ -37,8 +37,9 @@
 #import <AIUtilities/AIBezierPathAdditions.h>
 #import <Adium/AIContactControllerProtocol.h>
 
+#import <FriBidi/NSString-FBAdditions.h>
 
-#import <FriBidi/NSString-FBAdditions.h>
+#import <AIUtilities/AILeopardCompatibility.h>
 
 #define MAX_HISTORY					25		//Number of messages to remember in history
 #define ENTRY_TEXTVIEW_PADDING		6		//Padding for auto-sizing
@@ -49,6 +50,14 @@
 #define KEY_GRAMMAR_CHECKING					@"Grammar Checking Enabled"
 #define	PREF_GROUP_DUAL_WINDOW_INTERFACE		@"Dual Window Interface"
 
+#define KEY_SUBSTITUTION_DASH					@"Smart Dash Substitutions"
+#define KEY_SUBSTITUTION_DATA_DETECTORS			@"Smart Data Detectors Substitutions"
+#define KEY_SUBSTITUTION_REPLACEMENT			@"Text Replacement Substitutions"
+#define KEY_SUBSTITUTION_SPELLING				@"Spelling Substitutions"
+#define KEY_SUBSTITUTION_COPY_PASTE				@"Smart Copy Paste Substitutions"
+#define KEY_SUBSTITUTION_QUOTE					@"Smart Quote Substitutions"
+#define KEY_SUBSTITUTION_LINK					@"Smart Links Substitutions"
+
 #define INDICATOR_RIGHT_PADDING					2		// Padding between right side of the message view and the rightmost indicator
 
 #define PREF_GROUP_CHARACTER_COUNTER			@"Character Counter"
@@ -392,16 +401,42 @@
 																 group:GROUP_ACCOUNT_STATUS] boolValue];
 	}
 	
-	if (!object &&
-		[group isEqualToString:PREF_GROUP_DUAL_WINDOW_INTERFACE] &&
-		(!key || [key isEqualToString:KEY_SPELL_CHECKING])) {
-		[self setContinuousSpellCheckingEnabled:[[prefDict objectForKey:KEY_SPELL_CHECKING] boolValue]];
-	}
+	if (!object && [group isEqualToString:PREF_GROUP_DUAL_WINDOW_INTERFACE]) {
+		if (!key || [key isEqualToString:KEY_GRAMMAR_CHECKING]) {
+			[self setGrammarCheckingEnabled:[[prefDict objectForKey:KEY_GRAMMAR_CHECKING] boolValue]];
+		}
 
-	if (!object &&
-		[group isEqualToString:PREF_GROUP_DUAL_WINDOW_INTERFACE] &&
-		(!key || [key isEqualToString:KEY_GRAMMAR_CHECKING])) {
-		[self setGrammarCheckingEnabled:[[prefDict objectForKey:KEY_GRAMMAR_CHECKING] boolValue]];
+		if (!key || [key isEqualToString:KEY_SPELL_CHECKING]) {
+			[self setContinuousSpellCheckingEnabled:[[prefDict objectForKey:KEY_SPELL_CHECKING] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_DASH]) {
+			[self setAutomaticDashSubstitutionEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_DASH] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_DATA_DETECTORS]) {
+			[self setAutomaticDataDetectionEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_DATA_DETECTORS] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_REPLACEMENT]) {
+			[self setAutomaticTextReplacementEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_REPLACEMENT] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_SPELLING]) {
+			[self setAutomaticSpellingCorrectionEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_SPELLING] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_COPY_PASTE]) {
+			[self setSmartInsertDeleteEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_COPY_PASTE] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_QUOTE]) {
+			[self setAutomaticQuoteSubstitutionEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_QUOTE] boolValue]];
+		}
+		
+		if (!key || [key isEqualToString:KEY_SUBSTITUTION_LINK]) {
+			[self setAutomaticLinkDetectionEnabled:[[prefDict objectForKey:KEY_SUBSTITUTION_LINK] boolValue]];
+		}
 	}
 }
 
@@ -1382,6 +1417,90 @@
 										  group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
 }
 
+#pragma mark Substitutions
+/*!
+ * @brief Dash substitution was toggled
+ */
+- (void)toggleAutomaticDashSubstitution:(id)sender
+{
+	[super toggleAutomaticDashSubstitution:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self isAutomaticDashSubstitutionEnabled]]
+									   forKey:KEY_SUBSTITUTION_DASH
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
+
+/*!
+ * @brief Data Detector substitution was toggled
+ */
+- (void)toggleAutomaticDataDetection:(id)sender
+{
+	[super toggleAutomaticDataDetection:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self isAutomaticDataDetectionEnabled]]
+									   forKey:KEY_SUBSTITUTION_DATA_DETECTORS
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
+
+/*!
+ * @brief Text Replacement substitution was toggled
+ */
+- (void)toggleAutomaticTextReplacement:(id)sender
+{
+	[super toggleAutomaticTextReplacement:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self isAutomaticTextReplacementEnabled]]
+									   forKey:KEY_SUBSTITUTION_REPLACEMENT
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
+
+/*!
+ * @brief Spelling replacement substitution was toggled
+ */
+- (void)toggleAutomaticSpellingCorrection:(id)sender
+{
+	[super toggleAutomaticSpellingCorrection:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self isAutomaticSpellingCorrectionEnabled]]
+									   forKey:KEY_SUBSTITUTION_SPELLING
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
+
+/*!
+ * @brief Smart insert delete was toggled
+ */
+- (void)toggleSmartInsertDelete:(id)sender
+{
+	[super toggleSmartInsertDelete:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self smartInsertDeleteEnabled]]
+									   forKey:KEY_SUBSTITUTION_COPY_PASTE
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
+
+/*!
+ * @brief Smart quote substitution was toggled
+ */
+- (void)toggleAutomaticQuoteSubstitution:(id)sender
+{
+	[super toggleAutomaticQuoteSubstitution:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self isAutomaticQuoteSubstitutionEnabled]]
+									   forKey:KEY_SUBSTITUTION_QUOTE
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
+
+/*!
+ * @brief Smart link substitution was toggled
+ */
+- (void)toggleAutomaticLinkDetection:(id)sender
+{
+	[super toggleAutomaticLinkDetection:sender];
+	
+	[adium.preferenceController setPreference:[NSNumber numberWithBool:[self isAutomaticLinkDetectionEnabled]]
+									   forKey:KEY_SUBSTITUTION_LINK
+										group:PREF_GROUP_DUAL_WINDOW_INTERFACE];
+}
 
 #pragma mark Writing Direction
 - (void)toggleBaseWritingDirection:(id)sender
--- a/Plugins/Dual Window Interface/DualWindowDefaults.plist	Wed Aug 26 13:17:35 2009 -0400
+++ b/Plugins/Dual Window Interface/DualWindowDefaults.plist	Sat Aug 29 19:20:15 2009 -0400
@@ -18,5 +18,15 @@
 	<true/>
 	<key>UserList Width</key>
 	<integer>150</integer>
+	<key>Smart Dash Substitutions</key>
+	<true/>
+	<key>Text Replacement Substitutions</key>
+	<true/>
+	<key>Spelling Substitutions</key>
+	<true/>
+	<key>Smart Copy Paste Substitutions</key>
+	<true/>
+	<key>Smart Links Substitutions</key>
+	<true/>
 </dict>
 </plist>