adium-1.4 2679:ad119ec778fc: Add %incomingColor% and %outgoingCo...
commits at adium.im
commits at adium.im
Thu Oct 29 16:57:35 UTC 2009
details: http://hg.adium.im/adium-1.4/rev/ad119ec778fc
revision: 2679:ad119ec778fc
author: Zachary West <zacw at adium.im>
date: Thu Oct 29 12:57:14 2009 -0400
Add %incomingColor% and %outgoingColor%, remove %senderColor% in headers. Fixes #12666.
This also should speed up significantly message display for styles that don't specify a custom set of colors, since we won't be querying the file for every message any longer.
diffs (90 lines):
diff -r 4f51d10a2af5 -r ad119ec778fc Plugins/WebKit Message View/AIWebkitMessageViewStyle.h
--- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.h Thu Oct 29 12:43:40 2009 -0400
+++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.h Thu Oct 29 12:57:14 2009 -0400
@@ -103,6 +103,9 @@
BOOL transparentDefaultBackground;
BOOL allowsUserIcons;
BOOL usingCustomTemplateHTML;
+
+ BOOL checkedSenderColors;
+ NSArray *validSenderColors;
//Behavior
NSDateFormatter *timeStampFormatter;
@@ -236,6 +239,11 @@
*/
@property (readonly, nonatomic) BOOL allowsColors;
+/*!
+ * @brief The style's sender colors
+ */
+ at property (readonly, nonatomic) NSArray *validSenderColors;
+
//Behavior
/*!
* @brief Set the format of dates/time stamps
diff -r 4f51d10a2af5 -r ad119ec778fc Plugins/WebKit Message View/AIWebkitMessageViewStyle.m
--- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Thu Oct 29 12:43:40 2009 -0400
+++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Thu Oct 29 12:57:14 2009 -0400
@@ -55,8 +55,6 @@
// We set back, when the user finishes editing, the correct topic, which wipes out the existance of the span before. We don't need to undo the dbl click action.
#define TOPIC_INDIVIDUAL_WRAPPER @"<span id=\"topicEdit\" ondblclick=\"this.setAttribute('contentEditable', true); this.focus();\">%@</span>"
-static NSArray *validSenderColors;
-
@interface NSMutableString (AIKeywordReplacementAdditions)
- (void) replaceKeyword:(NSString *)word withString:(NSString *)newWord;
- (void) safeReplaceCharactersInRange:(NSRange)range withString:(NSString *)newWord;
@@ -247,6 +245,21 @@
@synthesize allowsCustomBackground, allowsUserIcons, allowsColors, userIconMask;
+- (NSArray *)validSenderColors
+{
+ if(!checkedSenderColors) {
+ NSURL *url = [NSURL fileURLWithPath:[stylePath stringByAppendingPathComponent:@"Incoming/SenderColors.txt"]];
+ NSString *senderColorsFile = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
+
+ if(senderColorsFile)
+ validSenderColors = [[senderColorsFile componentsSeparatedByString:@":"] retain];
+
+ checkedSenderColors = YES;
+ }
+
+ return validSenderColors;
+}
+
- (BOOL)isBackgroundTransparent
{
//Our custom background is only transparent if the user has set a custom color with an alpha component less than 1.0
@@ -776,15 +789,8 @@
[inString replaceKeyword:@"%messageClasses%"
withString:[(contentIsSimilar ? @"consecutive " : @"") stringByAppendingString:[[content displayClasses] componentsJoinedByString:@" "]]];
- if(!validSenderColors) {
- NSURL *url = [NSURL fileURLWithPath:[stylePath stringByAppendingPathComponent:@"Incoming/SenderColors.txt"]];
- NSString *senderColorsFile = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
-
- if(senderColorsFile)
- validSenderColors = [[senderColorsFile componentsSeparatedByString:@":"] retain];
- }
[inString replaceKeyword:@"%senderColor%"
- withString:[NSColor representedColorForObject:contentSource.UID withValidColors:validSenderColors]];
+ withString:[NSColor representedColorForObject:contentSource.UID withValidColors:self.validSenderColors]];
//HAX. The odd conditional here detects the rtl html that our html parser spits out.
[inString replaceKeyword:@"%messageDirection%"
@@ -1149,8 +1155,11 @@
AIListContact *listObject = chat.listObject;
NSString *iconPath = nil;
- [inString replaceKeyword:@"%senderColor%"
- withString:[NSColor representedColorForObject:listObject.UID withValidColors:validSenderColors]];
+ [inString replaceKeyword:@"%incomingColor%"
+ withString:[NSColor representedColorForObject:listObject.UID withValidColors:self.validSenderColors]];
+
+ [inString replaceKeyword:@"%outgoingColor%"
+ withString:[NSColor representedColorForObject:chat.account.UID withValidColors:self.validSenderColors]];
if (listObject) {
iconPath = [listObject valueForProperty:KEY_WEBKIT_USER_ICON];
More information about the commits
mailing list