adium-1.4 2776:790da92cabb6: When cycling chats (using "Next Cha...
commits at adium.im
commits at adium.im
Sat Nov 21 21:57:56 UTC 2009
details: http://hg.adium.im/adium-1.4/rev/790da92cabb6
revision: 2776:790da92cabb6
author: Zachary West <zacw at adium.im>
date: Sat Nov 21 16:57:52 2009 -0500
When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
diffs (135 lines):
diff -r 3031d60eb00f -r 790da92cabb6 Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h
--- a/Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h Sat Nov 21 13:22:15 2009 -0500
+++ b/Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h Sat Nov 21 16:57:52 2009 -0500
@@ -165,7 +165,7 @@
* @brief Active Chat property
*
* Setter brings the tab/window for a chat to the front and sets it as active
- * If no chat is active (a non-chat window is focued, or Adium is not focused), getter returns nil.
+ * If no chat is active (a non-chat window is focused, or Adium is not focused), getter returns nil.
*/
@property (nonatomic, retain) AIChat *activeChat;
@@ -192,6 +192,14 @@
- (NSArray *)openChatsInContainerWithID:(NSString *)containerID;
/*!
+ * @brief The container ID for a chat
+ *
+ * @param chat The chat to look up
+ * @returns The container ID for the container the chat is in.
+ */
+- (NSString *)containerIDForChat:(AIChat *)chat;
+
+/*!
* @brief Get an array of the containerIDs of all open containers
*/
@property (nonatomic, readonly) NSArray *openContainerIDs;
@@ -209,14 +217,14 @@
/*!
* @brief Cycles to the next open chat, making it active
*
- * This crosses container boundaries.
+ * This does not cross container boundaries. If there is no currently active chat, this has no effect.
*/
- (void)nextChat:(id)sender;
/*!
* @brief Cycles to the previous open chat, making it active
*
- * This crosses container boundaries.
+ * This does not cross container boundaries. If there is no currently active chat, this has no effect.
*/
- (void)previousChat:(id)sender;
diff -r 3031d60eb00f -r 790da92cabb6 Source/AIChatCyclingPlugin.m
--- a/Source/AIChatCyclingPlugin.m Sat Nov 21 13:22:15 2009 -0500
+++ b/Source/AIChatCyclingPlugin.m Sat Nov 21 16:57:52 2009 -0500
@@ -116,7 +116,11 @@
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
- return [[adium.interfaceController openChats] count] != 0;
+ if (!adium.interfaceController.activeChat) return NO;
+
+ NSString *containerID = [adium.interfaceController containerIDForChat:adium.interfaceController.activeChat];
+
+ return ([adium.interfaceController openChatsInContainerWithID:containerID].count > 0);
}
/*!
diff -r 3031d60eb00f -r 790da92cabb6 Source/AIInterfaceController.m
--- a/Source/AIInterfaceController.m Sat Nov 21 13:22:15 2009 -0500
+++ b/Source/AIInterfaceController.m Sat Nov 21 16:57:52 2009 -0500
@@ -750,6 +750,17 @@
}
/*!
+ * @brief The container ID for a chat
+ *
+ * @param chat The chat to look up
+ * @returns The container ID for the container the chat is in.
+ */
+- (NSString *)containerIDForChat:(AIChat *)chat
+{
+ return [interfacePlugin containerIDForChat:chat];
+}
+
+/*!
* @brief Resets the cache of open chats
*/
- (void)_resetOpenChatsCache
@@ -1085,16 +1096,17 @@
*/
- (void)nextChat:(id)sender
{
- NSArray *openChats = [self openChats];
+ if (!activeChat) return;
+
+ NSString *containerID = [self containerIDForChat:activeChat];
+ NSArray *chats = [self openChatsInContainerWithID:containerID];
- if ([openChats count]) {
- if (activeChat) {
- NSInteger chatIndex = [openChats indexOfObject:activeChat]+1;
- [self setActiveChat:[openChats objectAtIndex:(chatIndex < [openChats count] ? chatIndex : 0)]];
- } else {
- [self setActiveChat:[openChats objectAtIndex:0]];
- }
- }
+ NSInteger nextChat = [chats indexOfObject:activeChat] + 1;
+
+ if (nextChat >= chats.count)
+ nextChat = 0;
+
+ [self setActiveChat:[chats objectAtIndex:nextChat]];
}
/*!
@@ -1102,16 +1114,17 @@
*/
- (void)previousChat:(id)sender
{
- NSArray *openChats = [self openChats];
+ if (!activeChat) return;
- if ([openChats count]) {
- if (activeChat) {
- NSInteger chatIndex = [openChats indexOfObject:activeChat]-1;
- [self setActiveChat:[openChats objectAtIndex:(chatIndex >= 0 ? chatIndex : [openChats count]-1)]];
- } else {
- [self setActiveChat:[openChats lastObject]];
- }
- }
+ NSString *containerID = [self containerIDForChat:activeChat];
+ NSArray *chats = [self openChatsInContainerWithID:containerID];
+
+ NSInteger nextChat = [chats indexOfObject:activeChat] - 1;
+
+ if (nextChat < 0)
+ nextChat = chats.count - 1;
+
+ [self setActiveChat:[chats objectAtIndex:nextChat]];
}
//Selected contact ------------------------------------------------
More information about the commits
mailing list