soc.2009.vulture: ff449a69: Show context menu for buddies in buddy l...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Thu Jul 16 18:25:27 EDT 2009


-----------------------------------------------------------------
Revision: ff449a695fe56c628800212fcfd9de7f41f75f08
Ancestor: 028c203c7ef4e31e2f30ae6d31e7a6ead0ea727c
Author: gdick at soc.pidgin.im
Date: 2009-07-16T11:46:41
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/ff449a695fe56c628800212fcfd9de7f41f75f08

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

ChangeLog: 

Show context menu for buddies in buddy list.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	93a123a7d454de0af4f5db9b7e0cc5d17b50c318
+++ vulture/purpleblist.c	803071d56717d4032ab124a3292d0be7b0bdbd7f
@@ -83,6 +83,8 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 			lpvbn->lpvbnParent = lpblistnode->parent ? (VULTURE_BLIST_NODE*)lpblistnode->parent->ui_data : NULL;
 			if(lpvbn->lpvbnParent) VultureBListNodeAddRef(lpvbn->lpvbnParent);
 
+			lpvbn->nodetype = lpblistnode->type;
+
 			switch(lpblistnode->type)
 			{
 			case PURPLE_BLIST_GROUP_NODE:
@@ -231,7 +233,7 @@ void VultureBListNodeRelease(VULTURE_BLI
  *
  * @param	lpvbn	Node.
  */
-void PurpleBListNodeDoubleClicked(VULTURE_BLIST_NODE *lpvbn)
+void PurpleBListNodeActivated(VULTURE_BLIST_NODE *lpvbn)
 {
 	if(lpvbn->lpblistnode &&
 		(PURPLE_BLIST_NODE_IS_CONTACT(lpvbn->lpblistnode) || PURPLE_BLIST_NODE_IS_BUDDY(lpvbn->lpblistnode)))
============================================================
--- vulture/purpleblist.h	2fb47b93d38fe9e0418bb9bb99d657da6ec30b65
+++ vulture/purpleblist.h	8fda2a675d558096e29191f6e55eaa1ac51b7ad4
@@ -34,6 +34,7 @@ typedef struct _VULTURE_BLIST_NODE
 typedef struct _VULTURE_BLIST_NODE
 {
 	PurpleBlistNode			*lpblistnode;
+	PurpleBlistNodeType		nodetype;
 	LPTSTR				szNodeText;
 	HTREEITEM			hti;
 	struct _VULTURE_BLIST_NODE	*lpvbnParent;
@@ -46,7 +47,7 @@ void VultureBListNodeRelease(VULTURE_BLI
 void PurpleBlistUpdateNode(PurpleBuddyList *lpbuddylist, PurpleBlistNode *lpblistnode);
 void PurpleBlistRemoveNode(PurpleBuddyList *lpbuddylist, PurpleBlistNode *lpblistnode);
 void VultureBListNodeRelease(VULTURE_BLIST_NODE *lpvblnode);
-void PurpleBListNodeDoubleClicked(VULTURE_BLIST_NODE *lpvbn);
+void PurpleBListNodeActivated(VULTURE_BLIST_NODE *lpvbn);
 LPTSTR PurpleBuddyGetStatusText(PurpleBuddy *lpbuddy);
 void PurpleBuddyStatusChanged(PurpleBuddy *lpbuddy, PurpleStatus *lpstatusOld, PurpleStatus *lpstatusNew);
 
============================================================
--- vulture/purplequeue.c	799b95ff480055c663a50cc5b3d7c8f93621a4fe
+++ vulture/purplequeue.c	c8d03c413912a1e71932bf8917306339fd2da624
@@ -216,8 +216,8 @@ static void DispatchPurpleCall(PURPLE_CA
 
 		break;
 
-	case PC_BLISTNODEDBLCLKED:
-		PurpleBListNodeDoubleClicked((VULTURE_BLIST_NODE*)lppurplecall->lpvParam);
+	case PC_BLISTNODEACTIVATED:
+		PurpleBListNodeActivated((VULTURE_BLIST_NODE*)lppurplecall->lpvParam);
 		break;
 
 	case PC_CONVGETTITLE:
============================================================
--- vulture/purplequeue.h	b43814d4efcb0e33511f3b359092d4454360f9fa
+++ vulture/purplequeue.h	db8cec4ed6eddc3e65d57a5b2c77b3f16f65d1f8
@@ -63,7 +63,7 @@ enum PURPLE_CALL_ID
 	PC_GETSTATUSMSG,
 
 	/* (VULTURE_BLIST_NODE*) Node double-clicked.  */
-	PC_BLISTNODEDBLCLKED,
+	PC_BLISTNODEACTIVATED,
 
 	/* (VULTURE_CONV_GET_STRING*) Retrieves the conversation's title. */
 	PC_CONVGETTITLE,
============================================================
--- vulture/resource.h	0ad9ca7d3183d5898acafedab6fe097213fc9f6d
+++ vulture/resource.h	73f206b82322d3979b81de5f6758091262a5a5d5
@@ -2,41 +2,60 @@
 #define IDC_STATIC (-1)
 #endif
 
-#define IDD_STATUS                              101
-#define IDM_BLIST                               103
-#define IDD_BLIST                               105
-#define IDD_ACCOUNTS                            107
-#define IDR_ACCEL_MAIN                          109
-#define IDM_CONV                                111
-#define IDD_CONVCONT                            113
-#define IDD_IM                                  115
-#define IDD_CHAT                                117
-#define IDD_JOINCHAT                            119
-#define IDC_CBEX_ACCOUNTS                       1000
-#define IDC_STATIC_DETAILS                      1001
-#define IDC_TAB_CONVERSATIONS                   1001
+#define IDC_BTN_ACCOUNT_ADD                     40005
+#define IDC_BTN_ACCOUNT_DELETE                  40007
+#define IDC_BTN_ACCOUNT_PROPERTIES              40006
 #define IDC_BUDDY_ICON                          1002
-#define IDC_TREE_NAMES                          1002
-#define IDC_LIST_ACCOUNTS                       1003
+#define IDC_CBEX_ACCOUNTS                       1000
 #define IDC_CBEX_STATUS                         1004
-#define IDM_BLIST_BUDDIES_CLOSE                 40000
-#define IDM_CONV_CONV_CLOSE                     40000
-#define IDS_ERROR_BLIST                         40000
-#define IDM_BLIST_ACCOUNTS_MANAGE               40001
-#define IDS_ERROR_PURPLEINIT                    40001
-#define IDM_BLIST_BUDDIES_JOINCHAT              40002
-#define IDS_ACCMGR_ACCOUNT                      40002
 #define IDC_EDIT_STATUSMSG                      40003
-#define IDS_ACCMGR_PROTOCOL                     40003
-#define IDC_TREE_BLIST                          40004
-#define IDS_ERROR_CONVCONTCLASS                 40004
-#define IDC_BTN_ACCOUNT_ADD                     40005
-#define IDS_ERROR_RICHEDIT                      40005
-#define IDC_BTN_ACCOUNT_PROPERTIES              40006
-#define IDC_BTN_ACCOUNT_DELETE                  40007
+#define IDC_LIST_ACCOUNTS                       1003
 #define IDC_RICHEDIT_CONV                       40008
 #define IDC_RICHEDIT_INPUT                      40010
+#define IDC_STATIC_DETAILS                      1001
+#define IDC_STATIC_ICON                         40014
 #define IDC_STATIC_NAME                         40011
 #define IDC_STATIC_STATUS                       40013
 #define IDC_STATIC_TOPIC                        40013
-#define IDC_STATIC_ICON                         40014
+#define IDC_TAB_CONVERSATIONS                   1001
+#define IDC_TREE_BLIST                          40004
+#define IDC_TREE_NAMES                          1002
+
+
+#define IDD_ACCOUNTS                            101
+#define IDD_BLIST                               102
+#define IDD_CHAT                                103
+#define IDD_CONVCONT                            104
+#define IDD_IM                                  105
+#define IDD_JOINCHAT                            106
+#define IDD_STATUS                              107
+
+
+#define IDM_BLIST                               1001
+#define IDM_BLIST_ACCOUNTS_MANAGE               40001
+#define IDM_BLIST_BUDDIES_CLOSE                 40000
+#define IDM_BLIST_BUDDIES_JOINCHAT              40002
+
+#define IDM_BLIST_CONTEXT                       1002
+#define IDM_BLIST_CONTEXT_IM                    40201
+#define IDM_BLIST_CONTEXT_GETINFO               40202
+#define IDM_BLIST_CONTEXT_SENDFILE              40203
+#define IDM_BLIST_CONTEXT_ADDPOUNCE     	40204
+#define IDM_BLIST_CONTEXT_VIEWLOG               40205
+#define IDM_BLIST_CONTEXT_SHOWOFFLINE           40206
+#define IDM_BLIST_CONTEXT_ALIAS                 40207
+#define IDM_BLIST_CONTEXT_REMOVE                40208
+
+#define IDM_CONV                                1003
+#define IDM_CONV_CONV_CLOSE                     40401
+
+
+#define IDR_ACCEL_MAIN                          2001
+
+
+#define IDS_ERROR_BLIST                         1
+#define IDS_ERROR_PURPLEINIT                    2
+#define IDS_ACCMGR_ACCOUNT                      3
+#define IDS_ACCMGR_PROTOCOL                     4
+#define IDS_ERROR_CONVCONTCLASS                 5
+#define IDS_ERROR_RICHEDIT                      6
============================================================
--- vulture/vulture-res.rc	3fd1722bbe5b7004106cb01e70d64450dab506f2
+++ vulture/vulture-res.rc	dfbf98a56dbd7d901356d923da3530f67a930847
@@ -27,7 +27,6 @@ IDM_BLIST MENU
 }
 
 
-
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDM_CONV MENU
 {
@@ -38,7 +37,27 @@ IDM_CONV MENU
 }
 
 
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDM_BLIST_CONTEXT MENUEX
+{
+	POPUP "Buddy"
+	{
+		MENUITEM "Start &conversation", IDM_BLIST_CONTEXT_IM, MFT_STRING, MFS_DEFAULT
+		MENUITEM "Get &info", IDM_BLIST_CONTEXT_GETINFO, MFT_STRING, MFS_GRAYED
+		MENUITEM "Send &file...", IDM_BLIST_CONTEXT_SENDFILE, MFT_STRING, MFS_GRAYED
+		MENUITEM "Add &pounce...", IDM_BLIST_CONTEXT_ADDPOUNCE, MFT_STRING, MFS_GRAYED
+		MENUITEM "View &log", IDM_BLIST_CONTEXT_VIEWLOG, MFT_STRING, MFS_GRAYED
 
+		MENUITEM "", 0, MFT_SEPARATOR
+
+		MENUITEM "Show when &offline", IDM_BLIST_CONTEXT_SHOWOFFLINE, MFT_STRING, MFS_GRAYED
+		MENUITEM "Set &alias...", IDM_BLIST_CONTEXT_ALIAS, MFT_STRING, MFS_GRAYED
+		MENUITEM "&Remove from buddy list", IDM_BLIST_CONTEXT_REMOVE, MFT_STRING, MFS_GRAYED
+	}
+}
+
+
+
 //
 // Dialog resources
 //
============================================================
--- vulture/vultureblist.c	cf3bf4b64c56df113ed9db7a6d80e0881666e3b5
+++ vulture/vultureblist.c	00d43bf3136e54ba21a2d6a696c307e9eff9279a
@@ -60,7 +60,12 @@ static void RemoveBListNode(HWND hwndBli
 
 #define BLIST_MARGIN 6
 
+enum CONTEXT_MENU_INDICES
+{
+	CMI_BUDDY = 0,
+};
 
+
 HWND g_hwndMain = NULL;
 GList *g_lpglistConvContainers = NULL;
 
@@ -550,6 +555,30 @@ static INT_PTR CALLBACK BuddyListDlgProc
 
 		return TRUE;
 
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDM_BLIST_CONTEXT_IM:
+			{
+				TVITEM tvitem;
+				HWND hwndBlist = GetDlgItem(hwndDlg, IDC_TREE_BLIST);
+
+				if((tvitem.hItem = TreeView_GetSelection(hwndBlist)))
+				{
+					tvitem.mask = TVIF_PARAM;
+					TreeView_GetItem(hwndBlist, &tvitem);
+					
+					VultureEnqueueAsyncPurpleCall(PC_BLISTNODEACTIVATED, (VULTURE_BLIST_NODE*)tvitem.lParam);
+
+					return TRUE;
+				}
+			}
+
+			break;
+		}
+
+		break;
+
 	case WM_NOTIFY:
 		{
 			LPNMHDR lpnmhdr = (LPNMHDR)lParam;
@@ -573,13 +602,64 @@ static INT_PTR CALLBACK BuddyListDlgProc
 							tvitem.mask = TVIF_PARAM;
 							TreeView_GetItem(lpnmhdr->hwndFrom, &tvitem);
 							
-							VultureEnqueueAsyncPurpleCall(PC_BLISTNODEDBLCLKED, (VULTURE_BLIST_NODE*)tvitem.lParam);
+							VultureEnqueueAsyncPurpleCall(PC_BLISTNODEACTIVATED, (VULTURE_BLIST_NODE*)tvitem.lParam);
 
 							return TRUE;
 						}
 					}
 
 					break;
+
+				case NM_RCLICK:
+					{
+						TVITEM tvitem;
+
+						tvitem.hItem = TreeView_GetDropHilight(lpnmhdr->hwndFrom);
+						if(!tvitem.hItem) tvitem.hItem = TreeView_GetSelection(lpnmhdr->hwndFrom);
+
+						if(tvitem.hItem)
+						{
+							VULTURE_BLIST_NODE *lpvblistnode;
+							HMENU hmenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_BLIST_CONTEXT));
+							int iMenuIndex = -1;
+
+							/* Really select this node. */
+							TreeView_SelectItem(lpnmhdr->hwndFrom, tvitem.hItem);
+
+							tvitem.mask = TVIF_PARAM;
+							TreeView_GetItem(lpnmhdr->hwndFrom, &tvitem);
+
+							lpvblistnode = (VULTURE_BLIST_NODE*)tvitem.lParam;
+
+							EnterCriticalSection(&lpvblistnode->cs);
+
+								switch(lpvblistnode->nodetype)
+								{
+								case PURPLE_BLIST_BUDDY_NODE:
+									iMenuIndex = CMI_BUDDY;
+									break;
+
+								default:
+									break;
+								}
+
+							LeaveCriticalSection(&lpvblistnode->cs);
+
+							if(iMenuIndex >= 0)
+							{
+								POINT ptMouse;
+
+								GetCursorPos(&ptMouse);
+								TrackPopupMenu(GetSubMenu(hmenu, iMenuIndex), TPM_RIGHTBUTTON, ptMouse.x, ptMouse.y, 0, hwndDlg, NULL);
+							}
+
+							DestroyMenu(hmenu);
+
+							return TRUE;
+						}
+					}
+
+					break;
 				}
 			}
 		}


More information about the Commits mailing list