soc.2009.vulture: ac847fe4: Set the buddy icon correctly from accoun...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Tue Sep 8 09:56:09 EDT 2009


-----------------------------------------------------------------
Revision: ac847fe4bfb33d126f9b996f222066a539485b8e
Ancestor: 820599157e9694212894f8fa5255959a80319bf9
Author: gdick at soc.pidgin.im
Date: 2009-09-08T13:43:37
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/ac847fe4bfb33d126f9b996f222066a539485b8e

Modified files:
        vulture/purpleacct.c vulture/purplebicon.c
        vulture/purplebicon.h

ChangeLog: 

Set the buddy icon correctly from account properties dialogue.

-------------- next part --------------
============================================================
--- vulture/purpleacct.c	741fb5362bd61f03043314c83af2441f6a38ebaf
+++ vulture/purpleacct.c	fa02076800a1870e2d976dd8670b0539a375e8fd
@@ -28,6 +28,8 @@
 #include "purpleacct.h"
 #include "acctmanager.h"
 #include "purpleconv.h"
+#include "purplebicon.h"
+#include "purplemain.h"
 
 
 /**
@@ -175,13 +177,16 @@ void PurpleApplyVultureAccount(VULTURE_A
 	if(lpvac->bSupportsBIcon)
 	{
 		if(!lpvac->bOverrideBIcon)
+		{
 			purple_account_set_bool(lpvac->lppac, "use-global-buddyicon", TRUE);
+			SetAccountBuddyIcon(lpvac->lppac, purple_prefs_get_path(VULTURE_PREFS_ROOT "/accounts/buddyicon"));
+		}
 		else
 		{
 			purple_account_set_bool(lpvac->lppac, "use-global-buddyicon", FALSE);
 
 			szUTF8 = lpvac->szBIcon ? VultureTCHARToUTF8(lpvac->szBIcon) : NULL;
-			purple_account_set_buddy_icon_path(lpvac->lppac, szUTF8);
+			SetAccountBuddyIcon(lpvac->lppac, szUTF8);
 			g_free(szUTF8);
 		}
 	}
============================================================
--- vulture/purplebicon.c	281da5f34d45437233f89bd182d637cbff4582f1
+++ vulture/purplebicon.c	cda8a6fddfb7bc0780191f6fe2cc48334bd6adf8
@@ -441,19 +441,7 @@ static void SetGlobalBuddyIcon(const gch
 			 * setting.
 			 */
 			if(lpprplinfo && purple_account_get_bool(lpaccount, "use-global-buddyicon", TRUE) && lpprplinfo->icon_spec.format)
-			{
-				if(szFilename)
-				{
-					gsize cbImage;
-					gpointer lpvImage = ConvertAndScaleBuddyIcon(szFilename, lpplugin, &cbImage);
-
-					purple_buddy_icons_set_account_icon(lpaccount, lpvImage, cbImage);
-				}
-				else
-					purple_buddy_icons_set_account_icon(lpaccount, NULL, 0);
-
-				purple_account_set_buddy_icon_path(lpaccount, szFilename);
-			}
+				SetAccountBuddyIcon(lpaccount, szFilename);
 		}
 	}
 
@@ -499,3 +487,32 @@ void PurpleRefreshBuddyIcon(const gchar 
 	else
 		VulturePostUIMessage(VUIMSG_NEWGLOBALBICON, NULL);
 }
+
+
+/**
+ * Sets the buddy icon for an account.
+ *
+ * @param	lpaccount	Account.
+ * @param	szFilename	Filename of buddy icon. May be NULL.
+ */
+void SetAccountBuddyIcon(PurpleAccount *lpaccount, const gchar *szFilename)
+{
+	PurplePlugin *lpplugin = purple_find_prpl(purple_account_get_protocol_id(lpaccount));
+
+	if(lpplugin && szFilename)
+	{
+		gsize cbImage;
+		gpointer lpvImage = ConvertAndScaleBuddyIcon(szFilename, lpplugin, &cbImage);
+
+		purple_buddy_icons_set_account_icon(lpaccount, lpvImage, cbImage);
+	}
+	else
+	{
+		/* Don't store a path if we can't set the icon. */
+		szFilename = NULL;
+
+		purple_buddy_icons_set_account_icon(lpaccount, NULL, 0);
+	}
+
+	purple_account_set_buddy_icon_path(lpaccount, szFilename);
+}
============================================================
--- vulture/purplebicon.h	7615e4f4f3a62d690002e779687abe0f20a8e36b
+++ vulture/purplebicon.h	e23b58bf6fdadd78c8eb326dc96471d14db38878
@@ -33,6 +33,7 @@ void PurpleRefreshBuddyIcon(const gchar 
 HBITMAP PurpleGetBlistNodeIcon(PurpleBlistNode *lpblistnode, int cxMax, int cyMax);
 void PurpleGlobalBuddyIconPrefChanged(const char *szName, PurplePrefType preftype, gconstpointer lpvValue, gpointer lpvData);
 void PurpleRefreshBuddyIcon(const gchar *szFilename);
+void SetAccountBuddyIcon(PurpleAccount *lpaccount, const gchar *szFilename);
 
 
 #endif


More information about the Commits mailing list