changeset 23122:f6c57e6e8a89

Deprecate pidgin_set_custom_buddy_icon and update the places that use it to use purple_buddy_icons_node_set_custom_icon_from_file instead.
author Etan Reisner <pidgin@unreliablesource.net>
date Thu, 15 May 2008 04:00:22 +0000
parents 2498242c7af7
children 0ca259d5f928
files ChangeLog.API pidgin/gtkconv.c pidgin/gtkutils.c pidgin/gtkutils.h
diffstat 4 files changed, 42 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Thu May 15 03:26:46 2008 +0000
+++ b/ChangeLog.API	Thu May 15 04:00:22 2008 +0000
@@ -16,6 +16,7 @@
 		* purple_buddy_icons_has_custom_icon
 		* purple_buddy_icons_find_custom_icon
 		* purple_buddy_icons_set_custom_icon
+		* pidgin_set_custom_buddy_icon
 
 	perl:
 		Added:
--- a/pidgin/gtkconv.c	Thu May 15 03:26:46 2008 +0000
+++ b/pidgin/gtkconv.c	Thu May 15 04:00:22 2008 +0000
@@ -2724,10 +2724,22 @@
 custom_icon_sel_cb(const char *filename, gpointer data)
 {
 	if (filename) {
+		const gchar *name;
+		PurpleBuddy *buddy;
+		PurpleContact *contact;
 		PidginConversation *gtkconv = data;
 		PurpleConversation *conv = gtkconv->active_conv;
 		PurpleAccount *account = purple_conversation_get_account(conv);
-		pidgin_set_custom_buddy_icon(account, purple_conversation_get_name(conv), filename);
+
+		name = purple_conversation_get_name(conv);
+		buddy = purple_buddy_find(account, name);
+		if (!buddy) {
+			purple_debug_info("custom-icon", "You can only set custom icons for people on your buddylist.\n");
+			return;
+		}
+		contact = purple_buddy_get_contact(buddy);
+
+		purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, filename);
 	}
 }
 
@@ -2769,12 +2781,21 @@
 static void
 remove_custom_icon_cb(GtkWidget *widget, PidginConversation *gtkconv)
 {
-	PurpleConversation *conv;
+	const gchar *name;
+	PurpleBuddy *buddy;
 	PurpleAccount *account;
-
-	conv = gtkconv->active_conv;
+	PurpleContact *contact;
+	PurpleConversation *conv = gtkconv->active_conv;
+
 	account = purple_conversation_get_account(conv);
-	pidgin_set_custom_buddy_icon(account, purple_conversation_get_name(conv), NULL);
+	buddy = purple_buddy_find(account, name);
+	if (!buddy) {
+		return;
+	}
+	contact = purple_buddy_get_contact(buddy);
+	name = purple_conversation_get_name(conv);
+
+	purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, NULL);
 }
 
 static void
--- a/pidgin/gtkutils.c	Thu May 15 03:26:46 2008 +0000
+++ b/pidgin/gtkutils.c	Thu May 15 04:00:22 2008 +0000
@@ -1436,7 +1436,7 @@
 
 static void dnd_image_ok_callback(_DndData *data, int choice)
 {
-	char *filedata;
+	gchar *filedata;
 	size_t size;
 	struct stat st;
 	GError *err = NULL;
@@ -1444,6 +1444,8 @@
 	PidginConversation *gtkconv;
 	GtkTextIter iter;
 	int id;
+	PurpleBuddy *buddy;
+	PurpleContact *contact;
 	switch (choice) {
 	case DND_BUDDY_ICON:
 		if (g_stat(data->filename, &st)) {
@@ -1459,7 +1461,13 @@
 			return;
 		}
 
-		pidgin_set_custom_buddy_icon(data->account, data->who, data->filename);
+		buddy = purple_buddy_find(account, data->who);
+		if (!buddy) {
+			purple_debug_info("custom-icon", "You can only set custom icons for people on your buddylist.\n");
+			break;
+		}
+		contact = purple_buddy_get_contact(buddy);
+		purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, data->filename);
 		break;
 	case DND_FILE_TRANSFER:
 		serv_send_file(purple_account_get_connection(data->account), data->who, data->filename);
@@ -2869,6 +2877,7 @@
 }
 #endif /* ! Gtk 2.6.0 */
 
+#ifndef PURPLE_DISABLE_DEPRECATED
 void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename)
 {
 	PurpleBuddy *buddy;
@@ -2883,6 +2892,7 @@
 	contact = purple_buddy_get_contact(buddy);
 	purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, filename);
 }
+#endif
 
 char *pidgin_make_pretty_arrows(const char *str)
 {
--- a/pidgin/gtkutils.h	Thu May 15 03:26:46 2008 +0000
+++ b/pidgin/gtkutils.h	Thu May 15 04:00:22 2008 +0000
@@ -638,6 +638,7 @@
 											 GError **error);
 #endif
 
+#ifndef PURPLE_DISABLE_DEPRECATED
 /**
  * Set or unset a custom buddyicon for a user.
  *
@@ -645,8 +646,10 @@
  * @param who       The name of the user.
  * @param filename  The path of the custom icon. If this is @c NULL, then any
  *                  previously set custom buddy icon for the user is removed.
+ * @deprecated See purple_buddy_icons_node_set_custom_icon_from_file()
  */
 void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename);
+#endif
 
 /**
  * Converts "->" and "<-" in strings to Unicode arrow characters, for use in referencing