adium 2506:ef0c39fdfdaf: Patch from Ariel Chinn to make user col...
commits at adium.im
commits at adium.im
Sat Jun 20 19:29:04 UTC 2009
details: http://hg.adium.im/adium/rev/ef0c39fdfdaf
revision: 2506:ef0c39fdfdaf
author: David Smith <catfish.man at gmail.com>
date: Sat Jun 20 12:28:51 2009 -0700
Patch from Ariel Chinn to make user coloring generic so it can be used in the log viewer
diffs (78 lines):
diff -r 792549532d2a -r ef0c39fdfdaf Frameworks/AIUtilities Framework/Source/AIColorAdditions.h
--- a/Frameworks/AIUtilities Framework/Source/AIColorAdditions.h Fri Jun 19 10:26:06 2009 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIColorAdditions.h Sat Jun 20 12:28:51 2009 -0700
@@ -307,3 +307,16 @@
+ (id)colorWithHTMLString:(NSString *)str defaultColor:(NSColor *)defaultColor;
@end
+
+ at interface NSColor (AIColorAdditions_ObjectColor)
+
+/*! @brief Compute a colour for an object based on it's hash, represnted in an HTML color name from within a list of valid colours.
+ *
+ * @param anObject an object for which to compute a matching colour.
+ * @param validColors an NSArray containing a list of valid colours to return. If nil or empty, the colour will be chosen from a default list.
+ *
+ * @return An NSString containing an HTML colour name.
+ */
++ (NSString *)representedColorForObject: (id)anObject withValidColors: (NSArray *)validColors;
+
+ at end
diff -r 792549532d2a -r ef0c39fdfdaf Frameworks/AIUtilities Framework/Source/AIColorAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m Fri Jun 19 10:26:06 2009 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m Sat Jun 20 12:28:51 2009 -0700
@@ -21,6 +21,8 @@
#import "AIStringAdditions.h"
#import <string.h>
+#define VALID_COLORS_ARRAY [[NSArray alloc] initWithObjects:@"aqua", @"aquamarine", @"blue", @"blueviolet", @"brown", @"burlywood", @"cadetblue", @"chartreuse", @"chocolate", @"coral", @"cornflowerblue", @"crimson", @"cyan", @"darkblue", @"darkcyan", @"darkgoldenrod", @"darkgreen", @"darkgrey", @"darkkhaki", @"darkmagenta", @"darkolivegreen", @"darkorange", @"darkorchid", @"darkred", @"darksalmon", @"darkseagreen", @"darkslateblue", @"darkslategrey", @"darkturquoise", @"darkviolet", @"deeppink", @"deepskyblue", @"dimgrey", @"dodgerblue", @"firebrick", @"forestgreen", @"fuchsia", @"gold", @"goldenrod", @"green", @"greenyellow", @"grey", @"hotpink", @"indianred", @"indigo", @"lawngreen", @"lightblue", @"lightcoral", @"lightgreen", @"lightgrey", @"lightpink", @"lightsalmon", @"lightseagreen", @"lightskyblue", @"lightslategrey", @"lightsteelblue", @"lime", @"limegreen", @"magenta", @"maroon", @"mediumaquamarine", @"mediumblue", @"mediumorchid", @"mediumpurple", @"mediumseagreen!
", @"mediumslateblue", @"mediumspringgreen", @"mediumturquoise", @"mediumvioletred", @"midnightblue", @"navy", @"olive", @"olivedrab", @"orange", @"orangered", @"orchid", @"palegreen", @"paleturquoise", @"palevioletred", @"peru", @"pink", @"plum", @"powderblue", @"purple", @"red", @"rosybrown", @"royalblue", @"saddlebrown", @"salmon", @"sandybrown", @"seagreen", @"sienna", @"silver", @"skyblue", @"slateblue", @"slategrey", @"springgreen", @"steelblue", @"tan", @"teal", @"thistle", @"tomato", @"turquoise", @"violet", @"yellowgreen", nil]
+
static const float ONE_THIRD = 1.0/3.0;
static const float ONE_SIXTH = 1.0/6.0;
static const float TWO_THIRD = 2.0/3.0;
@@ -604,6 +606,20 @@
@end
+ at implementation NSColor (AIColorAdditions_ObjectColor)
+
++ (NSString *)representedColorForObject: (id)anObject withValidColors: (NSArray *)validColors
+{
+ NSArray *validColorsArray = validColors;
+
+ if (!validColorsArray || [validColorsArray count] == 0)
+ validColorsArray = VALID_COLORS_ARRAY;
+
+ return [validColorsArray objectAtIndex:([anObject hash] % ([validColorsArray count]))];
+}
+
+ at end
+
//Convert hex to an int
int hexToInt(char hex)
{
diff -r 792549532d2a -r ef0c39fdfdaf Plugins/WebKit Message View/AIWebkitMessageViewStyle.m
--- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Fri Jun 19 10:26:06 2009 -0400
+++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m Sat Jun 20 12:28:51 2009 -0700
@@ -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>"
-#define VALID_SENDER_COLORS_ARRAY [[NSArray alloc] initWithObjects:@"aqua", @"aquamarine", @"blue", @"blueviolet", @"brown", @"burlywood", @"cadetblue", @"chartreuse", @"chocolate", @"coral", @"cornflowerblue", @"crimson", @"cyan", @"darkblue", @"darkcyan", @"darkgoldenrod", @"darkgreen", @"darkgrey", @"darkkhaki", @"darkmagenta", @"darkolivegreen", @"darkorange", @"darkorchid", @"darkred", @"darksalmon", @"darkseagreen", @"darkslateblue", @"darkslategrey", @"darkturquoise", @"darkviolet", @"deeppink", @"deepskyblue", @"dimgrey", @"dodgerblue", @"firebrick", @"forestgreen", @"fuchsia", @"gold", @"goldenrod", @"green", @"greenyellow", @"grey", @"hotpink", @"indianred", @"indigo", @"lawngreen", @"lightblue", @"lightcoral", @"lightgreen", @"lightgrey", @"lightpink", @"lightsalmon", @"lightseagreen", @"lightskyblue", @"lightslategrey", @"lightsteelblue", @"lime", @"limegreen", @"magenta", @"maroon", @"mediumaquamarine", @"mediumblue", @"mediumorchid", @"mediumpurple", @"mediums!
eagreen", @"mediumslateblue", @"mediumspringgreen", @"mediumturquoise", @"mediumvioletred", @"midnightblue", @"navy", @"olive", @"olivedrab", @"orange", @"orangered", @"orchid", @"palegreen", @"paleturquoise", @"palevioletred", @"peru", @"pink", @"plum", @"powderblue", @"purple", @"red", @"rosybrown", @"royalblue", @"saddlebrown", @"salmon", @"sandybrown", @"seagreen", @"sienna", @"silver", @"skyblue", @"slateblue", @"slategrey", @"springgreen", @"steelblue", @"tan", @"teal", @"thistle", @"tomato", @"turquoise", @"violet", @"yellowgreen", nil]
-
static NSArray *validSenderColors;
@interface NSMutableString (AIKeywordReplacementAdditions)
@@ -788,11 +786,9 @@
if(senderColorsFile)
validSenderColors = [[senderColorsFile componentsSeparatedByString:@":"] retain];
- if(!validSenderColors || [validSenderColors count] == 0)
- validSenderColors = VALID_SENDER_COLORS_ARRAY;
}
[inString replaceKeyword:@"%senderColor%"
- withString:[validSenderColors objectAtIndex:([contentSource.UID hash] % ([validSenderColors count]))]];
+ withString:[NSColor representedColorForObject:contentSource.UID withValidColors:validSenderColors]];
//HAX. The odd conditional here detects the rtl html that our html parser spits out.
[inString replaceKeyword:@"%messageDirection%"
More information about the commits
mailing list