soc.2009.vulture: 064b8c11: Status icons in combo-box. We use Pidgin...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Mon Jul 27 16:55:29 EDT 2009


-----------------------------------------------------------------
Revision: 064b8c11a5801e9a418c183c6830e59e738a2887
Ancestor: 722b0f5a5e2a29922cba7e5addb4dda917a380f4
Author: gdick at soc.pidgin.im
Date: 2009-07-27T20:52:18
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/064b8c11a5801e9a418c183c6830e59e738a2887

Added files:
        vulture/res/status.bmp
Added directories:
        vulture/res
Modified files:
        vulture/resource.h vulture/vulture-res.rc
        vulture/vultureblist.c

ChangeLog: 

Status icons in combo-box. We use Pidgin's icons, at least for the time being.

-------------- next part --------------
============================================================
# vulture/res/status.bmp is binary
============================================================
--- vulture/resource.h	8306d4cc85e6eacd12af55990ef440051f30fc23
+++ vulture/resource.h	c60b43d575373f275229fe49057eb7cc9923cde7
@@ -63,6 +63,9 @@
 #define IDR_ACCEL_MAIN                          2001
 
 
+#define IDB_STATUS_ICONS                        3001
+
+
 #define IDS_ERROR_BLIST                         1
 #define IDS_ERROR_PURPLEINIT                    2
 #define IDS_ACCMGR_ACCOUNT                      3
============================================================
--- vulture/vulture-res.rc	203657cc904f978725217a80f1e5f8f32c4987c5
+++ vulture/vulture-res.rc	cdc489321f0878a09c10307c09e48a89f520efeb
@@ -240,3 +240,10 @@ 1                  RT_MANIFEST    ".\\ma
 //
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 1                  RT_MANIFEST    ".\\manifest.xml"
+
+
+
+//
+// Bitmap resources
+//
+IDB_STATUS_ICONS        BITMAP "res\\status.bmp"
\ No newline at end of file
============================================================
--- vulture/vultureblist.c	4635b9a4a2216a9d20932de1046680e9ceb08955
+++ vulture/vultureblist.c	3ef1a8be976cd15568c8b695e2fdc97914dc7aa2
@@ -63,6 +63,7 @@ static void RemoveNodeRequest(HWND hwndB
 
 
 #define BLIST_MARGIN 6
+#define CX_STATUSICON 16
 
 enum CONTEXT_MENU_INDICES
 {
@@ -72,12 +73,23 @@ enum CONTEXT_MENU_INDICES
 	CMI_CHAT,
 };
 
+enum STATUS_ICONS
+{
+	SICON_AVAILABLE = 0,
+	SICON_AWAY,
+	SICON_BUSY,
+	SICON_INVISIBLE,
+	SICON_OFFLINE,
+	SICON_EXTAWAY,
+};
 
+
 HWND g_hwndMain = NULL;
 GList *g_lpglistConvContainers = NULL;
 
 static GList *g_lpglistStatuses = NULL;
 static HWND g_hwndStatusDlg = NULL, g_hwndBListDlg = NULL;
+static HIMAGELIST g_himlStatusIcons = NULL;
 
 
 
@@ -158,6 +170,9 @@ static LRESULT CALLBACK MainWndProc(HWND
 			int i, iCount;
 			HMENU hmenu = GetMenu(hwnd);
 
+			/* Load and initialise image lists. */
+			g_himlStatusIcons = ImageList_LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_STATUS_ICONS), CX_STATUSICON, 0, 0, IMAGE_BITMAP, LR_CREATEDIBSECTION);
+
 			g_hwndStatusDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_STATUS), hwnd, StatusDlgProc);
 			g_hwndBListDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_BLIST), hwnd, BuddyListDlgProc);
 
@@ -395,8 +410,11 @@ static LRESULT CALLBACK MainWndProc(HWND
 		if(g_lpglistConvContainers)
 			g_list_free(g_lpglistConvContainers);
 
-		PostQuitMessage(VEC_SUCCESS);
+		return 0;
 
+	case WM_NCDESTROY:
+		ImageList_Destroy(g_himlStatusIcons);
+		PostQuitMessage(VEC_SUCCESS);
 		return 0;
 	}
 
@@ -441,6 +459,12 @@ static INT_PTR CALLBACK StatusDlgProc(HW
 			lpsdd->wndprocStatusMsgOrig = (WNDPROC)GetWindowLongPtr(hwndStatusMsg, GWLP_WNDPROC);
 			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)lpsdd);
 			SetWindowLongPtr(hwndStatusMsg, GWLP_WNDPROC, (LONG)StatusMsgBoxSubclassProc);
+
+			/* Set the combo's image-lists, and tell it to
+			 * recalculate its size.
+			 */
+			SendDlgItemMessage(hwndDlg, IDC_CBEX_STATUS, CBEM_SETIMAGELIST, 0, (LPARAM)g_himlStatusIcons);
+			SetWindowPos(GetDlgItem(hwndDlg, IDC_CBEX_STATUS), NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
 		}
 
 		/* Let the system set the focus. */
@@ -769,9 +793,23 @@ static void PopulateStatusList(HWND hwnd
  */
 static void PopulateStatusList(HWND hwndComboStatus)
 {
+	static GHashTable *s_lpghashStatusIcons = NULL;
+
 	GList *lpglistStatusRover;
 	GArray *lpgarrayWaitContext;
 
+	/* Initialise the lookup table of status icons the first time. */
+	if(!s_lpghashStatusIcons)
+	{
+		s_lpghashStatusIcons = g_hash_table_new(NULL, NULL);
+		g_hash_table_insert(s_lpghashStatusIcons, (gpointer)PURPLE_STATUS_AVAILABLE, (gpointer)SICON_AVAILABLE);
+		g_hash_table_insert(s_lpghashStatusIcons, (gpointer)PURPLE_STATUS_AWAY, (gpointer)SICON_AWAY);
+		g_hash_table_insert(s_lpghashStatusIcons, (gpointer)PURPLE_STATUS_UNAVAILABLE, (gpointer)SICON_BUSY);
+		g_hash_table_insert(s_lpghashStatusIcons, (gpointer)PURPLE_STATUS_INVISIBLE, (gpointer)SICON_INVISIBLE);
+		g_hash_table_insert(s_lpghashStatusIcons, (gpointer)PURPLE_STATUS_OFFLINE, (gpointer)SICON_OFFLINE);
+		g_hash_table_insert(s_lpghashStatusIcons, (gpointer)PURPLE_STATUS_EXTENDED_AWAY, (gpointer)SICON_EXTAWAY);
+	}
+
 	if(g_lpglistStatuses)
 		VulturePurpleFreeStatusList(g_lpglistStatuses);
 
@@ -792,6 +830,12 @@ static void PopulateStatusList(HWND hwnd
 		cbexitem.pszText = lpvss->szTitle ? lpvss->szTitle : TEXT("");
 		cbexitem.lParam = (LPARAM)lpvss;
 
+		if(g_hash_table_lookup_extended(s_lpghashStatusIcons, (gpointer)lpvss->psprim, NULL, (gpointer*)&cbexitem.iImage))
+		{
+			cbexitem.iSelectedImage = cbexitem.iImage;
+			cbexitem.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
+		}
+
 		/* Add at end of list. */
 		cbexitem.iItem = -1;
 


More information about the Commits mailing list