soc.2009.vulture: 722b0f5a: Expand/collapse contacts.

gdick at soc.pidgin.im gdick at soc.pidgin.im
Sat Jul 25 14:55:34 EDT 2009


-----------------------------------------------------------------
Revision: 722b0f5a5e2a29922cba7e5addb4dda917a380f4
Ancestor: 322f66ad3510a5a862b1e7e50d638810668b55c0
Author: gdick at soc.pidgin.im
Date: 2009-07-25T18:44:52
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/722b0f5a5e2a29922cba7e5addb4dda917a380f4

Modified files:
        vulture/purpleblist.c vulture/purplequeue.c
        vulture/purplequeue.h vulture/resource.h
        vulture/vulture-res.rc vulture/vulture.c
        vulture/vultureblist.c vulture/vultureblist.h

ChangeLog: 

Expand/collapse contacts.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	e4c727b8e4e0477433b216f436822375d9d25371
+++ vulture/purpleblist.c	83e5696f6aa63724f75141c830407f63f3e61dcd
@@ -73,6 +73,7 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 		lpvbn->hti = NULL;
 		lpvbn->lRefCount = 1;
 		lpvbn->lpvbnParent = NULL;
+		lpvbn->bExpanded = FALSE;
 		InitializeCriticalSection(&lpvbn->cs);
 	}
 
@@ -128,8 +129,19 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 				if(lpvbn->lpvbnParent && !lpvbn->lpvbnParent->hti)
 					PurpleBlistUpdateNode(lpbuddylist, lpvbn->lpvbnParent->lpblistnode);
 
-				VultureBListNodeAddRef(lpvbn);
-				VulturePostUIMessage(VUIMSG_UPDATEBLISTNODE, lpvbn);
+				/* If we're a buddy and our contact is
+				 * collapsed, give up at the last minute. We
+				 * still needed all the processing for other
+				 * nodes as if we'd been visible, but we want
+				 * to stop short of actually showing ourselves.
+				 */
+				if(!PURPLE_BLIST_NODE_IS_BUDDY(lpblistnode) ||
+					(lpblistnode->parent->ui_data &&
+					((VULTURE_BLIST_NODE*)lpblistnode->parent->ui_data)->bExpanded))
+				{
+					VultureBListNodeAddRef(lpvbn);
+					VulturePostUIMessage(VUIMSG_UPDATEBLISTNODE, lpvbn);
+				}
 			}
 		}
 		else if(lpvbn->hti)
@@ -170,30 +182,22 @@ static BOOL ShouldShowNode(PurpleBlistNo
 			}
 		}
 
-		break;
+		return FALSE;
 
 	case PURPLE_BLIST_CHAT_NODE:
-		if(purple_account_is_connected(purple_chat_get_account((PurpleChat*)lpblistnode)))
-			return TRUE;
-		break;
+		return purple_account_is_connected(purple_chat_get_account((PurpleChat*)lpblistnode));
 
 	case PURPLE_BLIST_BUDDY_NODE:
 		{
 			PurpleBuddy *lpbuddy = (PurpleBuddy*)lpblistnode;
-
-			if(purple_account_is_connected(purple_buddy_get_account(lpbuddy)) &&
+			return purple_account_is_connected(purple_buddy_get_account(lpbuddy)) &&
 				(purple_presence_is_online(lpbuddy->presence) ||
-				purple_blist_node_get_bool(lpblistnode, "show_offline")))
-				return TRUE;
+				purple_blist_node_get_bool(lpblistnode, "show_offline"));
 		}
 
-		break;
-
 	default:
-		break;
+		return FALSE;
 	}
-
-	return FALSE;
 }
 
 
============================================================
--- vulture/purplequeue.c	fbb3b5ffe704c67af911d81a046e582c64afc5b5
+++ vulture/purplequeue.c	19a07741826bd13526233187fa34d3acf7ff281a
@@ -277,18 +277,20 @@ static void DispatchPurpleCall(PURPLE_CA
 		{
 			VULTURE_MAKE_CONTEXT_MENU *lpvmcm = lppurplecall->lpvParam;
 			
-			if(lpvmcm->lpvblistnode->lpblistnode)
-			{
-				if(lpvmcm->bExtraItems)
+			EnterCriticalSection(&lpvmcm->lpvblistnode->cs);
+				if(lpvmcm->lpvblistnode->lpblistnode)
 				{
-					if(PURPLE_BLIST_NODE_IS_BUDDY(lpvmcm->lpvblistnode->lpblistnode) || PURPLE_BLIST_NODE_IS_CONTACT(lpvmcm->lpvblistnode->lpblistnode))
-						PurpleMakeBuddyMenu(lpvmcm->hmenu, EFFECTIVE_BUDDY(lpvmcm->lpvblistnode->lpblistnode), lpvmcm->lplpglistVMA);
-					else if(PURPLE_BLIST_NODE_IS_CHAT(lpvmcm->lpvblistnode->lpblistnode))
-						PurpleMakeChatMenu(lpvmcm->hmenu, lpvmcm->lpvblistnode->lpblistnode, lpvmcm->lplpglistVMA);
-				}
+					if(lpvmcm->bExtraItems)
+					{
+						if(PURPLE_BLIST_NODE_IS_BUDDY(lpvmcm->lpvblistnode->lpblistnode) || PURPLE_BLIST_NODE_IS_CONTACT(lpvmcm->lpvblistnode->lpblistnode))
+							PurpleMakeBuddyMenu(lpvmcm->hmenu, EFFECTIVE_BUDDY(lpvmcm->lpvblistnode->lpblistnode), lpvmcm->lplpglistVMA);
+						else if(PURPLE_BLIST_NODE_IS_CHAT(lpvmcm->lpvblistnode->lpblistnode))
+							PurpleMakeChatMenu(lpvmcm->hmenu, lpvmcm->lpvblistnode->lpblistnode, lpvmcm->lplpglistVMA);
+					}
 
-				PurpleCommonMakeMenu(lpvmcm->hmenu, lpvmcm->lpvblistnode->lpblistnode);
-			}
+					PurpleCommonMakeMenu(lpvmcm->hmenu, lpvmcm->lpvblistnode->lpblistnode);
+				}
+			LeaveCriticalSection(&lpvmcm->lpvblistnode->cs);
 		}
 
 		break;
@@ -356,19 +358,40 @@ static void DispatchPurpleCall(PURPLE_CA
 		{
 			VULTURE_BLIST_NODE_STRING_PAIR *lpvblnstringpair = lppurplecall->lpvParam;
 
-			if(lpvblnstringpair->lpvblistnode->lpblistnode)
-			{
-				if(lpvblnstringpair->sz)
+			EnterCriticalSection(&lpvblnstringpair->lpvblistnode->cs);
+				if(lpvblnstringpair->lpvblistnode->lpblistnode)
 				{
-					gchar *szFilename = VultureTCHARToUTF8(lpvblnstringpair->sz);
+					if(lpvblnstringpair->sz)
+					{
+						gchar *szFilename = VultureTCHARToUTF8(lpvblnstringpair->sz);
 
-					purple_buddy_icons_node_set_custom_icon_from_file(lpvblnstringpair->lpvblistnode->lpblistnode, szFilename);
+						purple_buddy_icons_node_set_custom_icon_from_file(lpvblnstringpair->lpvblistnode->lpblistnode, szFilename);
 
-					g_free(szFilename);
+						g_free(szFilename);
+					}
+					else
+					{
+						purple_buddy_icons_node_set_custom_icon(lpvblnstringpair->lpvblistnode->lpblistnode, NULL, 0);
+					}
 				}
-				else
+			LeaveCriticalSection(&lpvblnstringpair->lpvblistnode->cs);
+		}
+
+		break;
+
+	case PC_UPDATEBLISTCHILDREN:
+		{
+			PurpleBlistNode *lpblistnode = ((VULTURE_BLIST_NODE*)lppurplecall->lpvParam)->lpblistnode;
+			
+			if(lpblistnode)
+			{
+				PurpleBlistNode *lpblistnodeChild;
+
+				for(lpblistnodeChild = purple_blist_node_get_first_child(lpblistnode);
+					lpblistnodeChild;
+					lpblistnodeChild = purple_blist_node_get_sibling_next(lpblistnodeChild))
 				{
-					purple_buddy_icons_node_set_custom_icon(lpvblnstringpair->lpvblistnode->lpblistnode, NULL, 0);
+					PurpleBlistUpdateNode(purple_get_blist(), lpblistnodeChild);
 				}
 			}
 		}
============================================================
--- vulture/purplequeue.h	39ebf80110057edb2e4e69c0701690c9f2a45903
+++ vulture/purplequeue.h	323b68d1531a12509450d4dc972706a06c2c7bcc
@@ -106,6 +106,9 @@ enum PURPLE_CALL_ID
 
 	/* (VULTURE_BLIST_NODE_STRING_PAIR*) */
 	PC_SETCUSTOMICON,
+
+	/* (VULTURE_BLIST_NODE*) */
+	PC_UPDATEBLISTCHILDREN,
 };
 
 
============================================================
--- vulture/resource.h	669e6a63c1cf0159b89a21101ca82ecf35f96b66
+++ vulture/resource.h	8306d4cc85e6eacd12af55990ef440051f30fc23
@@ -48,9 +48,10 @@
 #define IDM_BLIST_CONTEXT_BLOCK                 40209
 #define IDM_BLIST_CONTEXT_CUSTOMICON            40210
 #define IDM_BLIST_CONTEXT_REMOVEICON            40211
-#define IDM_BLIST_CONTEXT_SHOWBUDDIES           40212
+#define IDM_BLIST_CONTEXT_EXPAND                40212
 #define IDM_BLIST_CONTEXT_AUTOJOIN              40213
 #define IDM_BLIST_CONTEXT_PROPERTIES            40214
+#define IDM_BLIST_CONTEXT_COLLAPSE              40215
 
 #define IDM_CONV                                1003
 #define IDM_CONV_CONV_CLOSE                     40401
============================================================
--- vulture/vulture-res.rc	2e43bbe3fd1f175873a471b01ed720ef7ea845e6
+++ vulture/vulture-res.rc	203657cc904f978725217a80f1e5f8f32c4987c5
@@ -59,12 +59,11 @@ IDM_CONV MENU
 	MENUITEM "Set custom &icon...", IDM_BLIST_CONTEXT_CUSTOMICON, MFT_STRING \
 	MENUITEM "Remo&ve custom icon", IDM_BLIST_CONTEXT_REMOVEICON, MFT_STRING
 
-#define CONTACT_TAIL \
+#define CONTACT_COMMON \
 	MENUITEM "", 0, MFT_SEPARATOR \
 	CONTEXT_CUSTOMICON \
 	CONTEXT_ALIAS_REMOVE \
-	MENUITEM "", 0, MFT_SEPARATOR \
-	MENUITEM "Sho&w individual buddies", IDM_BLIST_CONTEXT_SHOWBUDDIES, MFT_STRING, MFS_GRAYED
+	MENUITEM "", 0, MFT_SEPARATOR
 
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDM_BLIST_CONTEXT MENUEX
@@ -78,13 +77,15 @@ IDM_BLIST_CONTEXT MENUEX
 	POPUP "Contact (Composite)"
 	{
 		BUDDY_CONTACT_COMMON
-		CONTACT_TAIL
+		CONTACT_COMMON
+		MENUITEM "Sho&w individual buddies", IDM_BLIST_CONTEXT_EXPAND, MFT_STRING
 	}
 
 	POPUP "Contact (Basic)"
 	{
 		CONTEXT_VIEWLOG
-		CONTACT_TAIL
+		CONTACT_COMMON
+		MENUITEM "Sho&w individual buddies", IDM_BLIST_CONTEXT_COLLAPSE, MFT_STRING, MFS_CHECKED
 	}
 
 	POPUP "Chat"
============================================================
--- vulture/vulture.c	7afb980eef536b50f2edb07386d4fe9b4cef6f1f
+++ vulture/vulture.c	86f939a2eadf509b573f45ad8598422ab79c34cd
============================================================
--- vulture/vultureblist.c	e4f1ec40843f6d2462a429673608e34ffe9883e6
+++ vulture/vultureblist.c	4635b9a4a2216a9d20932de1046680e9ceb08955
@@ -620,34 +620,33 @@ static INT_PTR CALLBACK BuddyListDlgProc
 							/* Assume we need to ask the core for extra items. */
 							vmcm.bExtraItems = TRUE;
 
-							/* Reading lpvblistnode->nodetype is atomic and so
-							 * we don't need our critical section.
-							 */
-							switch(lpvblistnode->nodetype)
-							{
-							case PURPLE_BLIST_BUDDY_NODE:
-								hmenuSubmenu = GetSubMenu(hmenu, CMI_BUDDY);
-								break;
+							EnterCriticalSection(&lpvblistnode->cs);
+								switch(lpvblistnode->nodetype)
+								{
+								case PURPLE_BLIST_BUDDY_NODE:
+									hmenuSubmenu = GetSubMenu(hmenu, CMI_BUDDY);
+									break;
 
-							case PURPLE_BLIST_CONTACT_NODE:
-								if(TreeView_GetChild(lpnmhdr->hwndFrom, tvitem.hItem))
-								{
-									hmenuSubmenu = GetSubMenu(hmenu, CMI_CONTACT_BASIC);
-									vmcm.bExtraItems = FALSE;
-								}
-								else
-									hmenuSubmenu = GetSubMenu(hmenu, CMI_CONTACT_COMPOSITE);
+								case PURPLE_BLIST_CONTACT_NODE:
+									if(lpvblistnode->bExpanded)
+									{
+										hmenuSubmenu = GetSubMenu(hmenu, CMI_CONTACT_BASIC);
+										vmcm.bExtraItems = FALSE;
+									}
+									else
+										hmenuSubmenu = GetSubMenu(hmenu, CMI_CONTACT_COMPOSITE);
 
-								break;
+									break;
 
-							case PURPLE_BLIST_CHAT_NODE:
-								hmenuSubmenu = GetSubMenu(hmenu, CMI_CHAT);
-								break;
+								case PURPLE_BLIST_CHAT_NODE:
+									hmenuSubmenu = GetSubMenu(hmenu, CMI_CHAT);
+									break;
 
-							default:
-								vmcm.bExtraItems = FALSE;
-								break;
-							}
+								default:
+									vmcm.bExtraItems = FALSE;
+									break;
+								}
+							LeaveCriticalSection(&lpvblistnode->cs);
 
 							vmcm.hmenu = hmenuSubmenu;
 							vmcm.lpvblistnode = lpvblistnode;
@@ -931,8 +930,10 @@ static void RemoveBListNode(HWND hwndBli
 {
 	if(lpvbn->hti)
 	{
-		TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
-		lpvbn->hti = NULL;
+		EnterCriticalSection(&lpvbn->cs);
+			TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
+			lpvbn->hti = NULL;
+		LeaveCriticalSection(&lpvbn->cs);
 
 		/* Release the reference belonging to the pointer
 		 * cached in the tree-item.
@@ -961,6 +962,35 @@ static void RunBuddyMenuCmd(HWND hwndBud
 	case IDM_BLIST_CONTEXT_SHOWOFFLINE:
 		VultureEnqueueAsyncPurpleCall(PC_TOGGLESHOWOFFLINE, lpvblistnode);
 		break;
+
+	case IDM_BLIST_CONTEXT_COLLAPSE:
+		EnterCriticalSection(&lpvblistnode->cs);
+		{
+			HTREEITEM hti;
+
+			lpvblistnode->bExpanded = FALSE;
+
+			while((hti = TreeView_GetChild(hwndBuddies, lpvblistnode->hti)))
+			{
+				TVITEM tvi;
+
+				tvi.hItem = hti;
+				tvi.mask = TVIF_PARAM;
+				TreeView_GetItem(hwndBuddies, &tvi);
+
+				RemoveBListNode(hwndBuddies, (VULTURE_BLIST_NODE*)tvi.lParam);
+			}
+		}
+		LeaveCriticalSection(&lpvblistnode->cs);
+
+		break;
+
+	case IDM_BLIST_CONTEXT_EXPAND:
+		lpvblistnode->bExpanded = TRUE;
+		VultureSingleSyncPurpleCall(PC_UPDATEBLISTCHILDREN, lpvblistnode);
+		PostMessage(hwndBuddies, TVM_EXPAND, TVE_EXPAND, (LPARAM)lpvblistnode->hti);
+
+		break;
 	}
 }
 
============================================================
--- vulture/vultureblist.h	2b2ca0a4da9b9fd73b04ec96c87f0a9755710c58
+++ vulture/vultureblist.h	166afd028ea80d8397fe633ecd5396a3236e6d9e
@@ -39,6 +39,7 @@ typedef struct _VULTURE_BLIST_NODE
 	struct _VULTURE_BLIST_NODE	*lpvbnParent;
 	LONG				lRefCount;
 	CRITICAL_SECTION		cs;
+	BOOL				bExpanded;
 } VULTURE_BLIST_NODE;
 
 typedef struct _VULTURE_ALIAS_NODE


More information about the Commits mailing list