adium 4360:acbd654cf912: Work in progress, need a proper backup,...

commits at adium.im commits at adium.im
Fri Dec 9 22:46:57 UTC 2011


details:	http://hg.adium.im/adium/rev/acbd654cf912
revision:	4360:acbd654cf912
branch:		EmoticonsMenu
author:		Adrian Godoroja <robotive at me.com>
date:		Sat Dec 10 00:45:11 2011 +0200

Work in progress, need a proper backup, as i don't want to start over, again :)
Menu opening and positioning should work as expected.

diffs (truncated from 2793 to 1000 lines):

diff -r e857285aa973 -r acbd654cf912 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Fri Dec 09 02:01:26 2011 +0100
+++ b/Adium.xcodeproj/project.pbxproj	Sat Dec 10 00:45:11 2011 +0200
@@ -924,7 +924,6 @@
 		34DC8ADC0A7EEEF7003E1636 /* AIContextMenuTextView.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E1E8176063A3EEC00EB00F7 /* AIContextMenuTextView.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		34DC8ADD0A7EEEF7003E1636 /* AIContextMenuTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E1E8177063A3EEC00EB00F7 /* AIContextMenuTextView.m */; };
 		34DC8AE00A7EEEF7003E1636 /* AIMessageEntryTextView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B5827E80613CE9D0004BD25 /* AIMessageEntryTextView.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		34DC8AE10A7EEEF7003E1636 /* AIMessageEntryTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B5827E90613CE9D0004BD25 /* AIMessageEntryTextView.m */; };
 		34DC8AE40A7EEEF7003E1636 /* stackImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 349DDD5206406A7D00542726 /* stackImage.png */; };
 		34DC8AE50A7EEEF7003E1636 /* AILocalizationAssistance.h in Headers */ = {isa = PBXBuildFile; fileRef = 34D189B1076131850075A380 /* AILocalizationAssistance.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		34DC8AE70A7EEEF7003E1636 /* AILocalizationButtonCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 078C5CD0079EFF87004C75A4 /* AILocalizationButtonCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1442,6 +1441,11 @@
 		9718DF45136A2C5200013760 /* AIImageCollectionView.h in Headers */ = {isa = PBXBuildFile; fileRef = 9718DF43136A2C5200013760 /* AIImageCollectionView.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9718DF46136A2C5200013760 /* AIImageCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9718DF44136A2C5200013760 /* AIImageCollectionView.m */; };
 		9722ABC813257D7F00CAB486 /* ContactListWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9722ABC713257D7F00CAB486 /* ContactListWindow.xib */; };
+		97483A011486DD87002D1FA8 /* AIMessageEntryTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B5827E90613CE9D0004BD25 /* AIMessageEntryTextView.m */; };
+		97483A051486E92C002D1FA8 /* AIMessageViewEmoticonsController.h in Headers */ = {isa = PBXBuildFile; fileRef = 974C753314857BF4000686BA /* AIMessageViewEmoticonsController.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		97483A061486E93E002D1FA8 /* AIMessageViewEmoticonsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 974C753414857BF4000686BA /* AIMessageViewEmoticonsController.m */; };
+		974ECFA614896D900026659E /* emoticons_menu.png in Resources */ = {isa = PBXBuildFile; fileRef = 974C7524148570E2000686BA /* emoticons_menu.png */; };
+		974ECFA714896D9E0026659E /* MessageViewEmoticonsMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 974C752C148578F6000686BA /* MessageViewEmoticonsMenu.xib */; };
 		9760D24613E49A560031FA1A /* AboutDialog_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 9760D24513E49A560031FA1A /* AboutDialog_bg.png */; };
 		97AF5CDB13191DE200550C41 /* AIContactListUserPictureMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97AF5CDA13191DE200550C41 /* AIContactListUserPictureMenuController.m */; };
 		97AF5CF413191E9A00550C41 /* ContactListChangeUserPictureMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97AF5CF313191E9A00550C41 /* ContactListChangeUserPictureMenu.xib */; };
@@ -4604,6 +4608,10 @@
 		9718DF43136A2C5200013760 /* AIImageCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIImageCollectionView.h; path = "Frameworks/AIUtilities Framework/Source/AIImageCollectionView.h"; sourceTree = "<group>"; };
 		9718DF44136A2C5200013760 /* AIImageCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIImageCollectionView.m; path = "Frameworks/AIUtilities Framework/Source/AIImageCollectionView.m"; sourceTree = "<group>"; };
 		9722ABC713257D7F00CAB486 /* ContactListWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ContactListWindow.xib; path = Resources/ContactListWindow.xib; sourceTree = "<group>"; };
+		974C7524148570E2000686BA /* emoticons_menu.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = emoticons_menu.png; path = Resources/emoticons_menu.png; sourceTree = "<group>"; };
+		974C752C148578F6000686BA /* MessageViewEmoticonsMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MessageViewEmoticonsMenu.xib; path = Resources/MessageViewEmoticonsMenu.xib; sourceTree = "<group>"; };
+		974C753314857BF4000686BA /* AIMessageViewEmoticonsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIMessageViewEmoticonsController.h; path = Source/AIMessageViewEmoticonsController.h; sourceTree = "<group>"; };
+		974C753414857BF4000686BA /* AIMessageViewEmoticonsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIMessageViewEmoticonsController.m; path = Source/AIMessageViewEmoticonsController.m; sourceTree = "<group>"; };
 		9760D24513E49A560031FA1A /* AboutDialog_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AboutDialog_bg.png; path = Resources/AboutDialog_bg.png; sourceTree = "<group>"; };
 		97AF5CD913191DE200550C41 /* AIContactListUserPictureMenuController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIContactListUserPictureMenuController.h; path = Source/AIContactListUserPictureMenuController.h; sourceTree = "<group>"; };
 		97AF5CDA13191DE200550C41 /* AIContactListUserPictureMenuController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIContactListUserPictureMenuController.m; path = Source/AIContactListUserPictureMenuController.m; sourceTree = "<group>"; };
@@ -4981,6 +4989,12 @@
 		11C157D504A88DE0008E0C76 /* Emoticons */ = {
 			isa = PBXGroup;
 			children = (
+				11C157D804A88E04008E0C76 /* AIEmoticonController.h */,
+				11C157D904A88E04008E0C76 /* AIEmoticonController.m */,
+				974C753314857BF4000686BA /* AIMessageViewEmoticonsController.h */,
+				974C753414857BF4000686BA /* AIMessageViewEmoticonsController.m */,
+				974C752C148578F6000686BA /* MessageViewEmoticonsMenu.xib */,
+				974C7524148570E2000686BA /* emoticons_menu.png */,
 				C4243C920638E4EA007AD2D9 /* BGEmoticonMenuPlugin.h */,
 				C4243C930638E4EA007AD2D9 /* BGEmoticonMenuPlugin.m */,
 			);
@@ -5859,8 +5873,6 @@
 				34B82C80085A85D800864531 /* AIChatController.m */,
 				F55B415C03AB8B5601A8010A /* AIContentController.h */,
 				F55B415D03AB8B5601A8010A /* AIContentController.m */,
-				11C157D804A88E04008E0C76 /* AIEmoticonController.h */,
-				11C157D904A88E04008E0C76 /* AIEmoticonController.m */,
 				34CA15520CAFDFB2009AA5E3 /* sidebarActionWidget.png */,
 				34A9707D0C96602200F46006 /* sidebarStatusAreaBackground.png */,
 				9E4CF9D104AA69B000415B22 /* Action Support */,
@@ -9038,6 +9050,7 @@
 				112B47670F82E0FC00690E84 /* AIXtraInfo.h in Headers */,
 				34F17FCE0F8EAC34009C5A39 /* AIListOutlineView+Drawing.h in Headers */,
 				63B0EC9D0F8FBB660062476B /* AIProxyListObject.h in Headers */,
+				97483A051486E92C002D1FA8 /* AIMessageViewEmoticonsController.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -9777,6 +9790,8 @@
 				1199AB0610BE13E600646322 /* Authorize.tiff in Resources */,
 				1199AB0710BE13E600646322 /* Deny.tiff in Resources */,
 				1199AB0810BE13E600646322 /* Ignore.tiff in Resources */,
+				974ECFA614896D900026659E /* emoticons_menu.png in Resources */,
+				974ECFA714896D9E0026659E /* MessageViewEmoticonsMenu.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -10469,7 +10484,6 @@
 				34DC8AD80A7EEEF7003E1636 /* DCJoinChatWindowController.m in Sources */,
 				34DC8ADB0A7EEEF7003E1636 /* AIAccountPlusFieldPromptController.m in Sources */,
 				34DC8ADD0A7EEEF7003E1636 /* AIContextMenuTextView.m in Sources */,
-				34DC8AE10A7EEEF7003E1636 /* AIMessageEntryTextView.m in Sources */,
 				34DC8AE80A7EEEF7003E1636 /* AILocalizationButtonCell.m in Sources */,
 				34DC8AEA0A7EEEF7003E1636 /* AILocalizationTextField.m in Sources */,
 				34DC8AEC0A7EEEF7003E1636 /* AILocalizationButton.m in Sources */,
@@ -10506,6 +10520,8 @@
 				112B47680F82E0FC00690E84 /* AIXtraInfo.m in Sources */,
 				34F17FCF0F8EAC34009C5A39 /* AIListOutlineView+Drawing.m in Sources */,
 				63B0EC9C0F8FBB660062476B /* AIProxyListObject.m in Sources */,
+				97483A011486DD87002D1FA8 /* AIMessageEntryTextView.m in Sources */,
+				97483A061486E93E002D1FA8 /* AIMessageViewEmoticonsController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff -r e857285aa973 -r acbd654cf912 Frameworks/Adium Framework/Source/AIMessageEntryTextView.h
--- a/Frameworks/Adium Framework/Source/AIMessageEntryTextView.h	Fri Dec 09 02:01:26 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIMessageEntryTextView.h	Sat Dec 10 00:45:11 2011 +0200
@@ -21,6 +21,7 @@
 @class AIListContact, AIAccount, AIChat;
 
 @protocol AIMessageEntryTextViewDelegate <NSTextViewDelegate,NSObject>
+
 @optional
 /*!
  * @brief Should the tab key trigger an autocomplete?
@@ -35,9 +36,9 @@
 }
 
 @property (readwrite, retain, nonatomic) NSAttributedString *string;
+
 @end
 
-
 @interface AIMessageEntryTextView : AISendingTextView <AITextEntryView, AIListObjectObserver> {
 	AIChat				*chat;
 
@@ -64,18 +65,34 @@
 
 	AISimpleTextView	*characterCounter;
 	NSString			*characterCounterPrefix;
-	NSInteger					maxCharacters;
+	NSInteger			maxCharacters;
 	NSColor				*savedTextColor;
+    
+ at protected
+    // Emoticons
+    BOOL hasEmoticonsMenu;
+    NSButton *emoticonsMenuButton;
 }
 
 @property (readwrite, assign, nonatomic) id<AIMessageEntryTextViewDelegate> delegate;
 
-//Configure
+// Configure
 @property (readwrite, nonatomic) BOOL clearOnEscape;
 @property (readwrite, nonatomic) BOOL homeToStartOfLine;
 @property (readwrite, retain, nonatomic) NSView *associatedView;
 
-//Adium Text Entry
+// Context
+ at property (readwrite, retain, nonatomic) AIChat *chat;
+ at property (readonly, nonatomic) AIListContact *listObject;
+
+// History
+ at property (readwrite, nonatomic) BOOL historyEnabled;
+
+// Emoticons
+ at property (assign) BOOL hasEmoticonsMenu;
+ at property (retain) NSButton *emoticonsMenuButton;
+
+// Adium Text Entry
 - (void)setAttributedString:(NSAttributedString *)inAttributedString;
 - (void)setString:(NSString *)string;
 - (void)setTypingAttributes:(NSDictionary *)attrs;
@@ -83,23 +100,21 @@
 - (void)pasteAsRichText:(id)sender;
 - (NSSize)desiredSize;
 
-//Context
- at property (readwrite, retain, nonatomic) AIChat *chat;
- at property (readonly, nonatomic) AIListContact *listObject;
-
-//Paging
+// Paging
 - (void)scrollPageUp:(id)sender;
 - (void)scrollPageDown:(id)sender;
 
-//History
- at property (readwrite, nonatomic) BOOL historyEnabled;
+// History
 - (void)historyUp;
 - (void)historyDown;
 
-//Push and Pop
+// Push and Pop
 - (void)setPushPopEnabled:(BOOL)inBool;
 - (void)pushContent;
 - (void)popContent;
 - (void)swapContent;
 
+// Emoticons
+- (void)popUpEmoticonsMenu;
+
 @end
diff -r e857285aa973 -r acbd654cf912 Frameworks/Adium Framework/Source/AIMessageEntryTextView.m
--- a/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Fri Dec 09 02:01:26 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Sat Dec 10 00:45:11 2011 +0200
@@ -27,6 +27,8 @@
 #import <Adium/AIInterfaceControllerProtocol.h>
 #import <Adium/AIContentContext.h>
 
+#import <Adium/AIMessageViewEmoticonsController.h>
+
 #import <AIUtilities/AIAttributedStringAdditions.h>
 #import <AIUtilities/AIColorAdditions.h>
 #import <AIUtilities/AITextAttributes.h>
@@ -38,8 +40,9 @@
 
 #import <FriBidi/NSString-FBAdditions.h>
 
-#define MAX_HISTORY					25		//Number of messages to remember in history
-#define ENTRY_TEXTVIEW_PADDING		6		//Padding for auto-sizing
+
+#define MAX_HISTORY					25	// Number of messages to remember in history
+#define ENTRY_TEXTVIEW_PADDING		6	// Padding for auto-sizing
 
 #define KEY_DISABLE_TYPING_NOTIFICATIONS		@"Disable Typing Notifications"
 
@@ -55,7 +58,7 @@
 #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 INDICATOR_RIGHT_PADDING					2	// Padding between right side of the message view and the rightmost indicator
 
 #define PREF_GROUP_CHARACTER_COUNTER			@"Character Counter"
 #define KEY_CHARACTER_COUNTER_ENABLED			@"Character Counter Enabled"
@@ -67,6 +70,8 @@
 #define PASS_TO_SUPERCLASS_DRAG_TYPE_ARRAY [NSArray arrayWithObjects: \
 	NSRTFPboardType, NSStringPboardType, nil]
 
+#pragma mark -
+
 /**
  * @class AISimpleTextView
  * @brief Just draws an attributed string. That's it.
@@ -78,6 +83,7 @@
 @implementation  AISimpleTextView
 
 @synthesize string;
+
 - (void)dealloc
 {
 	[string release];
@@ -86,11 +92,15 @@
 
 - (void)drawRect:(NSRect)rect 
 {
-	[string drawInRect:self.bounds];
+	[string drawInRect:[self bounds]];
 }
+
 @end
 
+#pragma mark -
+
 @interface AIMessageEntryTextView ()
+
 - (void)_setPushIndicatorVisible:(BOOL)visible;
 - (void)positionPushIndicator;
 - (void)_resetCacheAndPostSizeChanged;
@@ -112,12 +122,21 @@
 - (void)frameDidChange:(NSNotification *)notification;
 - (void)toggleMessageSending:(NSNotification *)not;
 - (void)contentObjectAdded:(NSNotification *)notification;
+
+- (void)updateEmoticonsMenuButton;
+
 @end
 
+#pragma mark -
+
 @interface NSMutableAttributedString (AIMessageEntryTextViewAdditions)
+
 - (void)convertForPasteWithTraitsUsingAttributes:(NSDictionary *)inAttributes;
+
 @end
 
+#pragma mark - AIMessageEntryTextView
+
 @implementation AIMessageEntryTextView
 
 - (void)_initMessageEntryTextView
@@ -131,7 +150,7 @@
 	homeToStartOfLine = YES;
 	resizing = NO;
 	enableTypingNotifications = NO;
-	historyArray = [[NSMutableArray alloc] initWithObjects:@"",nil];
+	historyArray = [[NSMutableArray alloc] initWithObjects:@"", nil];
 	pushArray = [[NSMutableArray alloc] init];
 	currentHistoryLocation = 0;
 	[self setDrawsBackground:YES];
@@ -140,10 +159,12 @@
 	characterCounterPrefix = nil;
 	maxCharacters = 0;
 	savedTextColor = nil;
-	
+	hasEmoticonsMenu = NO;
+
 	if ([self respondsToSelector:@selector(setAllowsUndo:)]) {
 		[self setAllowsUndo:YES];
 	}
+    
 	if ([self respondsToSelector:@selector(setAllowsDocumentBackgroundColorChange:)]) {
 		[self setAllowsDocumentBackgroundColorChange:YES];
 	}
@@ -154,25 +175,28 @@
 											 selector:@selector(textDidChange:)
 												 name:NSTextDidChangeNotification 
 											   object:self];
+    
 	[[NSNotificationCenter defaultCenter] addObserver:self
 											 selector:@selector(frameDidChange:) 
 												 name:NSViewFrameDidChangeNotification 
 											   object:self];
+    
 	[[NSNotificationCenter defaultCenter] addObserver:self
-															selector:@selector(toggleMessageSending:)
-																name:@"AIChatDidChangeCanSendMessagesNotification"
-															  object:chat];
-	[[NSNotificationCenter defaultCenter] addObserver:self 
-															selector:@selector(contentObjectAdded:) 
-																name:Content_ContentObjectAdded 
-															  object:nil];
+                                             selector:@selector(toggleMessageSending:)
+                                                 name:@"AIChatDidChangeCanSendMessagesNotification"
+                                               object:chat];
+    
+	[[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(contentObjectAdded:)
+                                                 name:Content_ContentObjectAdded
+                                               object:nil];
 
 	[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_DUAL_WINDOW_INTERFACE];	
 	
 	[[AIContactObserverManager sharedManager] registerListObjectObserver:self];
 }
 
-//Init the text view
+// Init the text view
 - (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)aTextContainer
 {
 	if ((self = [super initWithFrame:frameRect textContainer:aTextContainer])) {
@@ -209,6 +233,7 @@
     [associatedView release];
     [historyArray release]; historyArray = nil;
     [pushArray release]; pushArray = nil;
+    [emoticonsMenuButton release];
 
     [super dealloc];
 }
@@ -231,9 +256,8 @@
 		unichar		 inChar = [charactersIgnoringModifiers characterAtIndex:0];
 		NSUInteger flags = [inEvent modifierFlags];
 		
-		//We have to test ctrl before option, because otherwise we'd miss ctrl-option-* events
-		if (pushPopEnabled &&
-			(flags & NSControlKeyMask) && !(flags & NSShiftKeyMask)) {
+		// We have to test ctrl before option, because otherwise we'd miss ctrl-option-* events
+		if (pushPopEnabled && (flags & NSControlKeyMask) && !(flags & NSShiftKeyMask)) {
 			if (inChar == NSUpArrowFunctionKey) {
 				[self popContent];
 			} else if (inChar == NSDownArrowFunctionKey) {
@@ -243,9 +267,7 @@
 			} else {
 				[super keyDown:inEvent];
 			}
-			
-		} else if (historyEnabled && 
-				   (flags & NSAlternateKeyMask) && !(flags & NSShiftKeyMask)) {
+		} else if (historyEnabled && (flags & NSAlternateKeyMask) && !(flags & NSShiftKeyMask)) {
 			if (inChar == NSUpArrowFunctionKey) {
 				[self historyUp];
 			} else if (inChar == NSDownArrowFunctionKey) {
@@ -253,13 +275,12 @@
 			} else {
 				[super keyDown:inEvent];
 			}
-			
-		} else if (associatedView &&
-				   (flags & NSCommandKeyMask) && !(flags & NSShiftKeyMask)) {
+		} else if (associatedView && (flags & NSCommandKeyMask) && !(flags & NSShiftKeyMask)) {
 			if ((inChar == NSUpArrowFunctionKey || inChar == NSDownArrowFunctionKey) ||
 			   (inChar == NSHomeFunctionKey || inChar == NSEndFunctionKey) ||
 			   (inChar == NSPageUpFunctionKey || inChar == NSPageDownFunctionKey)) {
-				//Pass the associatedView a keyDown event equivalent equal to inEvent except without the modifier flags
+				
+                // Pass the associatedView a keyDown event equivalent equal to inEvent except without the modifier flags
 				[associatedView keyDown:[NSEvent keyEventWithType:[inEvent type]
 														 location:[inEvent locationInWindow]
 													modifierFlags:0
@@ -273,24 +294,21 @@
 			} else {
 				[super keyDown:inEvent];
 			}
-			
-		} else if (associatedView &&
-				   (inChar == NSPageUpFunctionKey || inChar == NSPageDownFunctionKey)) {
-			[associatedView keyDown:inEvent];
-			
+		} else if (associatedView && (inChar == NSPageUpFunctionKey || inChar == NSPageDownFunctionKey)) {
+			[associatedView keyDown:inEvent];	
 		} else if (inChar == NSHomeFunctionKey || inChar == NSEndFunctionKey) {
 			if (homeToStartOfLine) {
 				NSRange	newRange;
 				
 				if (flags & NSShiftKeyMask) {
-					//With shift, select to the beginning/end of the line
+					// With shift, select to the beginning/end of the line
 					NSRange	selectedRange = [self selectedRange];
 					if (inChar == NSHomeFunctionKey) {
-						//Home: from 0 to the current location
+						// Home: from 0 to the current location
 						newRange.location = 0;
 						newRange.length = selectedRange.location;
 					} else {
-						//End: from current location to the end
+						// End: from current location to the end
 						newRange.location = selectedRange.location;
 						newRange.length = [[self string] length] - newRange.location;
 					}
@@ -301,16 +319,14 @@
 				}
 
 				[self setSelectedRange:newRange];
-
-			} else {
-				//If !homeToStartOfLine, pass the keypress to our associated view.
+        } else {
+				// If !homeToStartOfLine, pass the keypress to our associated view.
 				if (associatedView) {
 					[associatedView keyDown:inEvent];
 				} else {
 					[super keyDown:inEvent];					
 				}
 			}
-
 		} else if (inChar == NSTabCharacter) {
 			if ([self.delegate respondsToSelector:@selector(textViewShouldTabComplete:)] &&
 				[self.delegate textViewShouldTabComplete:self]) {
@@ -332,21 +348,21 @@
 	[self.enclosingScrollView scrollWheel:anEvent];
 }
 
-//Text changed
+// Text changed
 - (void)textDidChange:(NSNotification *)notification
 {
-	//Update typing status
+	// Update typing status
 	if (enableTypingNotifications) {
 		[adium.contentController userIsTypingContentForChat:chat hasEnteredText:[[self textStorage] length] > 0];
 	}
 
-	//Hide any existing contact list tooltip when we begin typing
+	// Hide any existing contact list tooltip when we begin typing
 	[adium.interfaceController showTooltipForListObject:nil atScreenPoint:NSZeroPoint onWindow:nil];
 
-    //Reset cache and resize
+    // Reset cache and resize
 	[self _resetCacheAndPostSizeChanged]; 
 	
-	//Update the character counter
+	// Update the character counter
 	if (characterCounter) {
 		[self updateCharacterCounter];
 	}
@@ -392,9 +408,8 @@
 	}
 }
 
+#pragma mark - Configure
 
-//Configure ------------------------------------------------------------------------------------------------------------
-#pragma mark Configure
 @synthesize clearOnEscape, homeToStartOfLine, associatedView;
 
 - (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key
@@ -404,7 +419,7 @@
 		[group isEqualToString:GROUP_ACCOUNT_STATUS] &&
 		(!key || [key isEqualToString:KEY_DISABLE_TYPING_NOTIFICATIONS])) {
 		enableTypingNotifications = ![[chat.account preferenceForKey:KEY_DISABLE_TYPING_NOTIFICATIONS
-																 group:GROUP_ACCOUNT_STATUS] boolValue];
+                                                               group:GROUP_ACCOUNT_STATUS] boolValue];
 	}
 	
 	if (!object && [group isEqualToString:PREF_GROUP_DUAL_WINDOW_INTERFACE]) {
@@ -446,15 +461,15 @@
 	}
 }
 
-//Adium Text Entry -----------------------------------------------------------------------------------------------------
-#pragma mark Adium Text Entry
+#pragma mark - Adium Text Entry
 
 /*!
  * @brief Toggle whether message sending is enabled based on a notification. The notification object is the AIChat of the appropriate message entry view
  */
 - (void)toggleMessageSending:(NSNotification *)not
 {
-	//XXX - We really should query the AIChat about this, but AIChat's "can't send" is really designed for handling offline, not banned. Bringing up the offline messaging dialog when banned would make no sense.
+	// XXX - We really should query the AIChat about this, but AIChat's "can't send" is really designed for handling offline, not banned.
+    // Bringing up the offline messaging dialog when banned would make no sense.
 	[self setSendingEnabled:[[[not userInfo] objectForKey:@"TypingEnabled"] boolValue]];
 }
 
@@ -466,16 +481,16 @@
 	return self.sendingEnabled;
 }
 
-//Set our string, preserving the selected range
+// Set our string, preserving the selected range
 - (void)setAttributedString:(NSAttributedString *)inAttributedString
 {
     NSUInteger			length = [inAttributedString length];
     NSRange 	oldRange = [self selectedRange];
 
-    //Change our string
+    // Change our string
     [[self textStorage] setAttributedString:inAttributedString];
 
-    //Restore the old selected range
+    // Restore the old selected range
     if (oldRange.location < length) {
         if (oldRange.location + oldRange.length <= length) {
             [self setSelectedRange:oldRange];
@@ -484,20 +499,20 @@
         }
     }
 
-    //Notify everyone that our text changed
+    // Notify everyone that our text changed
     [[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification object:self];
 }
 
-//Set our string (plain text)
+// Set our string (plain text)
 - (void)setString:(NSString *)string
 {
     [super setString:string];
 
-    //Notify everyone that our text changed
+    // Notify everyone that our text changed
     [[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification object:self];
 }
 
-//Set our typing format
+// Set our typing format
 - (void)setTypingAttributes:(NSDictionary *)attrs
 {
 	[super setTypingAttributes:attrs];
@@ -505,14 +520,14 @@
 	[self setInsertionPointColor:[[attrs objectForKey:NSBackgroundColorAttributeName] contrastingColor]];
 }
 
-#pragma mark Pasting
+#pragma mark - Pasting
 
 - (BOOL)handlePasteAsRichText
 {
 	NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard];
 	BOOL		 handledPaste = NO;
 	
-	//Types is ordered by the preference for handling of the data; enumerating it lets us allow the sending application's hints to be followed.
+	// Types is ordered by the preference for handling of the data; enumerating it lets us allow the sending application's hints to be followed.
 	for (NSString *type in generalPasteboard.types) {
 		if ([type isEqualToString:NSRTFDPboardType]) {
 			NSData *data = [generalPasteboard dataForType:NSRTFDPboardType];
@@ -520,7 +535,7 @@
 			handledPaste = YES;
 			
 		} else if ([PASS_TO_SUPERCLASS_DRAG_TYPE_ARRAY containsObject:type]) {
-			//When we hit a type we should let the superclass handle, break without doing anything
+			// When we hit a type we should let the superclass handle, break without doing anything
 			break;
 			
 		} else if ([FILES_AND_IMAGES_TYPES containsObject:type]) {
@@ -535,7 +550,7 @@
 	return handledPaste;
 }
 
-//Paste as rich text without altering our typing attributes
+// Paste as rich text without altering our typing attributes
 - (void)pasteAsRichText:(id)sender
 {
 	NSDictionary	*attributes = [[self typingAttributes] copy];
@@ -578,7 +593,7 @@
 			data = nil;
 		}
 		
-		//Failed. Try again with the string type.
+		// Failed. Try again with the string type.
 		if (!data && ![type isEqualToString:NSStringPboardType]) {
 			if ([[[NSPasteboard generalPasteboard] types] containsObject:NSStringPboardType]) {
 				type = NSStringPboardType;
@@ -591,7 +606,7 @@
 		}
 		
 		if (!data) {
-			//We still didn't get valid data... maybe super can handle it
+			// We still didn't get valid data... maybe super can handle it
 			@try {
 				[self paste:sender];
 			} @catch (NSException *localException) {
@@ -621,7 +636,7 @@
 																	documentAttributes:NULL];
 				}
 			} @catch (NSException *localException) {
-				//Error while reading the RTF or HTML data, which can happen. Fall back on plain text
+				// Error while reading the RTF or HTML data, which can happen. Fall back on plain text
 				if ([[[NSPasteboard generalPasteboard] types] containsObject:NSStringPboardType]) {
 					data = [generalPasteboard dataForType:NSStringPboardType];
 					NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
@@ -644,20 +659,20 @@
 		NSRange			selectedRange = [self selectedRange];
 		NSTextStorage	*textStorage = [self textStorage];
 		
-		//Prepare the undo operation
+		// Prepare the undo operation
 		NSUndoManager	*undoManager = [self undoManager];
 		[[undoManager prepareWithInvocationTarget:textStorage]
 				replaceCharactersInRange:NSMakeRange(selectedRange.location, [attributedString length])
 					withAttributedString:[textStorage attributedSubstringFromRange:selectedRange]];
 		[undoManager setActionName:AILocalizedString(@"Paste", nil)];
 		
-		//Perform the paste
+		// Perform the paste
 		[textStorage replaceCharactersInRange:selectedRange
 						 withAttributedString:attributedString];
 		// Align our text properly (only need to if the first character was changed)
 		if (selectedRange.location == 0)
 			[self setBaseWritingDirection:[[textStorage string] baseWritingDirection]];
-		//Notify that we changed our text
+		// Notify that we changed our text
 		[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification
 															object:self];
 		[attributedString release];
@@ -669,7 +684,7 @@
 		}
 
 	} else {		
-		//If we didn't handle it yet, let super try to deal with it
+		// If we didn't handle it yet, let super try to deal with it
 		[self paste:sender];
 	}
 
@@ -682,22 +697,22 @@
 	[self scrollRangeToVisible:[self selectedRange]];
 }
 
-#pragma mark Deletion
+#pragma mark - Deletion
 
 - (void)deleteBackward:(id)sender
 {
-	//Perform the delete
+	// Perform the delete
 	[super deleteBackward:sender];
 	
-	//If we are now an empty string, and we still have a link active, clear the link
+	// If we are now an empty string, and we still have a link active, clear the link
 	if ([[self textStorage] length] == 0) {
 		[self clearLinkAttribute];
 	}
 }
 
-//Contact menu ---------------------------------------------------------------------------------------------------------
-#pragma mark Contact menu
-//Set and return the selected chat (to auto-configure the contact menu)
+#pragma mark - Contact menu
+
+// Set and return the selected chat (to auto-configure the contact menu)
 - (void)setChat:(AIChat *)inChat
 {
     if (chat != inChat) {
@@ -722,12 +737,12 @@
 					  context:NULL];
 		}
 		
-		//Observe preferences changes for typing enable/disable
+		// Observe preferences changes for typing enable/disable
 		[adium.preferenceController registerPreferenceObserver:self forGroup:GROUP_ACCOUNT_STATUS];
     }
 	
-	//Set up the character counter for this chat's list object.
-	//This is done regardless of a chat changing because destination changes need to trigger this.
+	// Set up the character counter for this chat's list object.
+	// This is done regardless of a chat changing because destination changes need to trigger this.
 	if(!chat.isGroupChat) {
 		[self setCharacterCounterMaximum:[chat.listObject integerValueForProperty:@"Character Counter Max"]];
 		[self setCharacterCounterVisible:([chat.listObject valueForProperty:@"Character Counter Max"] != nil)];
@@ -740,7 +755,7 @@
     return chat;
 }
 
-//Return the selected list object (to auto-configure the contact menu)
+// Return the selected list object (to auto-configure the contact menu)
 - (AIListContact *)listObject
 {
 	return chat.listObject;
@@ -751,23 +766,22 @@
 	return [chat preferredListObject];
 }
 
-//Auto Sizing ----------------------------------------------------------------------------------------------------------
-#pragma mark Auto-sizing
-//Returns our desired size
+#pragma mark - Auto-sizing
+
+// Returns our desired size
 - (NSSize)desiredSize
 {
     if (_desiredSizeCached.width == 0) {
         CGFloat 		textHeight;
         if ([[self textStorage] length] != 0) {
-            //If there is text in this view, let the container tell us its height
+            // If there is text in this view, let the container tell us its height
 
-			//Force glyph generation.  We must do this or usedRectForTextContainer might only return a rect for a
-			//portion of our text.
+			// Force glyph generation.  We must do this or usedRectForTextContainer might only return a rect for a portion of our text.
             [[self layoutManager] glyphRangeForTextContainer:[self textContainer]];            
 
             textHeight = [[self layoutManager] usedRectForTextContainer:[self textContainer]].size.height;
         } else {
-            //Otherwise, we use the current typing attributes to guess what the height of a line should be
+            // Otherwise, we use the current typing attributes to guess what the height of a line should be
 			textHeight = [NSAttributedString stringHeightForAttributes:[self typingAttributes]];
         }
 
@@ -784,10 +798,10 @@
     return _desiredSizeCached;
 }
 
-//Reset the desired size cache when our frame changes
 - (void)frameDidChange:(NSNotification *)notification
 {
-	//resetCacheAndPostSizeChanged can get us right back to here, resulting in an infinite loop if we're not careful
+    // Reset the desired size cache when our frame changes
+	// resetCacheAndPostSizeChanged can get us right back to here, resulting in an infinite loop if we're not careful
 	if (!resizing) {
 		resizing = YES;
 		[self _resetCacheAndPostSizeChanged];
@@ -808,9 +822,9 @@
 	}
 }
 
-//Paging ---------------------------------------------------------------------------------------------------------------
-#pragma mark Paging
-//Page up or down in the message view
+#pragma mark - Paging
+
+// Page up or down in the message view
 - (void)scrollPageUp:(id)sender
 {
     if (associatedView && [associatedView respondsToSelector:@selector(pageUp:)]) {
@@ -819,6 +833,7 @@
 		[super scrollPageUp:sender];
 	}
 }
+
 - (void)scrollPageDown:(id)sender
 {
     if (associatedView && [associatedView respondsToSelector:@selector(pageDown:)]) {
@@ -828,61 +843,60 @@
 	}
 }
 
+#pragma mark - History
 
-//History --------------------------------------------------------------------------------------------------------------
-#pragma mark History
 @synthesize historyEnabled;
 
-//Move up through the history
+// Move up through the history
 - (void)historyUp
 {
     if (currentHistoryLocation == 0) {
-		//Store current message
+		// Store current message
         [historyArray replaceObjectAtIndex:0 withObject:[[[self textStorage] copy] autorelease]];
     }
 	
     if (currentHistoryLocation < [historyArray count]-1) {
-        //Move up
+        // Move up
         currentHistoryLocation++;
 		
-        //Display history
+        // Display history
         [self setAttributedString:[historyArray objectAtIndex:currentHistoryLocation]];
     }
 }
 
-//Move down through history
+// Move down through history
 - (void)historyDown
 {
     if (currentHistoryLocation > 0) {
-        //Move down
+        // Move down
         currentHistoryLocation--;
 		
-        //Display history
+        // Display history
         [self setAttributedString:[historyArray objectAtIndex:currentHistoryLocation]];
 	}
 }
 
-//Update history when content is sent
+// Update history when content is sent
 - (IBAction)sendContent:(id)sender
 {
 	NSAttributedString	*textStorage = [self textStorage];
 	
-	//Add to history if there is text being sent
+	// Add to history if there is text being sent
 	[historyArray insertObject:[[textStorage copy] autorelease] atIndex:1];
 	if ([historyArray count] > MAX_HISTORY) {
 		[historyArray removeLastObject];
 	}
 
-	currentHistoryLocation = 0; //Move back to bottom of history
+	currentHistoryLocation = 0; // Move back to bottom of history
 
-	//Send the content
+	// Send the content
 	[super sendContent:sender];
 	
-	//Clear the undo/redo stack as it makes no sense to carry between sends (the history is for that)
+	// Clear the undo/redo stack as it makes no sense to carry between sends (the history is for that)
 	[[self undoManager] removeAllActions];
 }
 
-//Populate the history with messages from the message history
+// Populate the history with messages from the message history
 - (void)contentObjectAdded:(NSNotification *)notification
 {
 	AIContentObject *content = [notification.userInfo objectForKey:@"AIContentObject"];
@@ -896,15 +910,15 @@
 	}
 }
 
-//Push and Pop ---------------------------------------------------------------------------------------------------------
-#pragma mark Push and Pop
-//Enable/Disable push-pop
+#pragma mark - Push and Pop
+
+// Enable/Disable push-pop
 - (void)setPushPopEnabled:(BOOL)inBool
 {
 	pushPopEnabled = inBool;
 }
 
-//Push out of the message entry field
+// Push out of the message entry field
 - (void)pushContent
 {
 	if ([[self textStorage] length] != 0 && pushPopEnabled) {
@@ -914,20 +928,21 @@
 	}
 }
 
-//Pop into the message entry field
+// Pop into the message entry field
 - (void)popContent
 {
     if ([pushArray count] && pushPopEnabled) {
         [self setAttributedString:[pushArray lastObject]];
-        [self setSelectedRange:NSMakeRange([[self textStorage] length], 0)]; //selection to end
+        [self setSelectedRange:NSMakeRange([[self textStorage] length], 0)]; // selection to end
         [pushArray removeLastObject];
+        
         if ([pushArray count] == 0) {
             [self _setPushIndicatorVisible:NO];
         }
     }
 }
 
-//Swap current content
+// Swap current content
 - (void)swapContent
 {
 	if (pushPopEnabled) {
@@ -946,25 +961,25 @@
 	}
 }
 
-//Push indicator
+// Push indicator
 - (void)_setPushIndicatorVisible:(BOOL)visible
 {
-	static NSImage	*pushIndicatorImage = nil;
+	static NSImage *pushIndicatorImage = nil;
 	
-	//
-	if (!pushIndicatorImage) pushIndicatorImage = [[NSImage imageNamed:@"stackImage" forClass:[self class]] retain];
+	if (!pushIndicatorImage) {
+    	pushIndicatorImage = [[NSImage imageNamed:@"stackImage" forClass:[self class]] retain];
+    }
 
     if (visible && !pushIndicatorVisible) {
         pushIndicatorVisible = visible;
 		
-        //Push text over to make room for indicator
+        // Push text over to make room for indicator
         NSSize size = [self frame].size;
         size.width -= ([pushIndicatorImage size].width);
         [self setFrameSize:size];
 				
 		// Make the indicator and set its action. It is a button with no border.
-		pushIndicator = [[NSButton alloc] initWithFrame:
-            NSMakeRect(0, 0, [pushIndicatorImage size].width, [pushIndicatorImage size].height)]; 
+		pushIndicator = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, [pushIndicatorImage size].width, [pushIndicatorImage size].height)]; 
 		[pushIndicator setButtonType:NSMomentaryPushButton];
         [pushIndicator setAutoresizingMask:(NSViewMinXMargin)];
         [pushIndicator setImage:pushIndicatorImage];
@@ -978,30 +993,40 @@
 		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(positionIndicators:) name:NSViewBoundsDidChangeNotification object:[self superview]];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(positionIndicators:) name:NSViewFrameDidChangeNotification object:[self superview]];
 		
-        [self positionPushIndicator]; //Set the indicators initial position
+        [self positionPushIndicator]; // Set the indicators initial position
 		
+		// Reposition the emoticons menu button
+		if ([self hasEmoticonsMenu]) {
+			[self updateEmoticonsMenuButton];
+		}
     } else if (!visible && pushIndicatorVisible) {
         pushIndicatorVisible = visible;
 
-        //Push text back
+        // Push text back
         NSSize size = [self frame].size;
         size.width += [pushIndicatorImage size].width;
         [self setFrameSize:size];
 
-		//Unsubcribe, if necessary.
-		if (!characterCounter) {
+		// Unsubcribe, if necessary.
+		if (!characterCounter && ![self hasEmoticonsMenu]) {
 			[[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewBoundsDidChangeNotification object:[self superview]];
 			[[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewFrameDidChangeNotification object:[self superview]];
 		}
-		//Remove indicator
+        
+		// Remove indicator
         [pushIndicator removeFromSuperview];
         [pushIndicator release]; pushIndicator = nil;
 		
 		[self positionPushIndicator];
+		
+		// Reposition the emoticons menu button
+		if ([self hasEmoticonsMenu]) {
+			[self updateEmoticonsMenuButton];
+		}
     }
 }
 
-//Reposition the push indicator into lower right corner
+// Reposition the push indicator into lower right corner
 - (void)positionPushIndicator
 {
     NSRect visRect = [[self superview] bounds];
@@ -1012,23 +1037,32 @@
     [[self enclosingScrollView] setNeedsDisplay:YES];
 }
 
-#pragma mark Indicators Positioning
+#pragma mark - Indicators Positioning
 
 /**
  * @brief Dispatch for both indicators to observe bounds & frame changes of their superview
  *
  * Stupid that this is necessary, but you can only remove an entire object from a notification center's observer list,
  * not on a per-method basis.
+ * Updates emoticons menu button also.
  */
 - (void)positionIndicators:(NSNotification *)notification
 {
-	if (pushIndicatorVisible)
+	if (pushIndicatorVisible) {
 		[self positionPushIndicator];
-	if (characterCounter)
+    }
+    
+	if (characterCounter) {
 		[self positionCharacterCounter];
+    }
+	
+	// Update emoticons menu button
+	if ([self hasEmoticonsMenu]) {
+		[self updateEmoticonsMenuButton];	
+	}
 }
 
-#pragma mark Character Counter
+#pragma mark - Character Counter
 
 /**
  * @brief Makes the character counter for this view visible.
@@ -1053,8 +1087,8 @@
         size.width += NSWidth([characterCounter frame]);
         [self setFrameSize:size];
 
-		//Unsubscribe, if necessary.
-		if (!pushIndicatorVisible) {
+		// Unsubscribe, if necessary.
+		if (!pushIndicatorVisible && ![self hasEmoticonsMenu]) {
 			[[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewBoundsDidChangeNotification object:[self superview]];
 			[[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewFrameDidChangeNotification object:[self superview]];
 		}
@@ -1063,8 +1097,14 @@




More information about the commits mailing list