# HG changeset patch
# Node ID 8e1a9f6f8833
# Parent  4d842d311595
diff --git a/libpurple/protocols/demo/purpledemocontacts.c b/libpurple/protocols/demo/purpledemocontacts.c
--- a/libpurple/protocols/demo/purpledemocontacts.c
+++ b/libpurple/protocols/demo/purpledemocontacts.c
@@ -29,12 +29,12 @@
 purple_demo_contacts_load_contact_icon(PurpleContactInfo *info,
                                        const char *name)
 {
-	GdkPixbuf *pixbuf = NULL;
+	PurpleAvatar *avatar = NULL;
 	GError *error = NULL;
 	char *path = NULL;
 
 	path = g_strdup_printf("/im/pidgin/purple/demo/buddy_icons/%s.png", name);
-	pixbuf = gdk_pixbuf_new_from_resource(path, &error);
+	avatar = purple_avatar_new_from_resource(path, &error);
 
 	if(error != NULL) {
 		g_message("Failed to load find an icon for %s: %s", path,
@@ -48,10 +48,10 @@
 
 	g_free(path);
 
-	if(GDK_IS_PIXBUF(pixbuf)) {
-		purple_contact_info_set_avatar(info, pixbuf);
+	if(PURPLE_IS_AVATAR(avatar)) {
+		purple_contact_info_set_avatar(info, avatar);
 
-		g_clear_object(&pixbuf);
+		g_clear_object(&avatar);
 	}
 }
 
diff --git a/libpurple/purplecontactinfo.h b/libpurple/purplecontactinfo.h
--- a/libpurple/purplecontactinfo.h
+++ b/libpurple/purplecontactinfo.h
@@ -26,8 +26,7 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
+#include <libpurple/purpleavatar.h>
 #include <libpurple/purplepresence.h>
 #include <libpurple/purpletags.h>
 
@@ -332,7 +331,7 @@
  *
  * Since: 3.0.0
  */
-GdkPixbuf *purple_contact_info_get_avatar(PurpleContactInfo *info);
+PurpleAvatar *purple_contact_info_get_avatar(PurpleContactInfo *info);
 
 /**
  * purple_contact_info_set_avatar:
@@ -346,7 +345,7 @@
  *
  * Since: 3.0.0
  */
-void purple_contact_info_set_avatar(PurpleContactInfo *info, GdkPixbuf *avatar);
+void purple_contact_info_set_avatar(PurpleContactInfo *info, PurpleAvatar *avatar);
 
 /**
  * purple_contact_info_get_presence:
diff --git a/libpurple/purplecontactinfo.c b/libpurple/purplecontactinfo.c
--- a/libpurple/purplecontactinfo.c
+++ b/libpurple/purplecontactinfo.c
@@ -35,7 +35,7 @@
 
 	char *name_for_display;
 
-	GdkPixbuf *avatar;
+	PurpleAvatar *avatar;
 
 	PurplePresence *presence;
 
@@ -484,7 +484,7 @@
 	properties[PROP_AVATAR] = g_param_spec_object(
 		"avatar", "avatar",
 		"The avatar of the contact",
-		GDK_TYPE_PIXBUF,
+		PURPLE_TYPE_AVATAR,
 		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
 	/**
@@ -904,7 +904,7 @@
 	}
 }
 
-GdkPixbuf *
+PurpleAvatar *
 purple_contact_info_get_avatar(PurpleContactInfo *info) {
 	PurpleContactInfoPrivate *priv = NULL;
 
@@ -916,7 +916,7 @@
 }
 
 void
-purple_contact_info_set_avatar(PurpleContactInfo *info, GdkPixbuf *avatar) {
+purple_contact_info_set_avatar(PurpleContactInfo *info, PurpleAvatar *avatar) {
 	PurpleContactInfoPrivate *priv = NULL;
 
 	g_return_if_fail(PURPLE_IS_CONTACT_INFO(info));
diff --git a/libpurple/purpleperson.h b/libpurple/purpleperson.h
--- a/libpurple/purpleperson.h
+++ b/libpurple/purpleperson.h
@@ -26,8 +26,7 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
+#include <libpurple/purpleavatar.h>
 #include <libpurple/purpletags.h>
 
 G_BEGIN_DECLS
@@ -113,7 +112,7 @@
  *
  * Since: 3.0.0
  */
-GdkPixbuf *purple_person_get_avatar_for_display(PurplePerson *person);
+PurpleAvatar *purple_person_get_avatar_for_display(PurplePerson *person);
 
 /**
  * purple_person_get_avatar:
@@ -125,7 +124,7 @@
  *
  * Since: 3.0.0
  */
-GdkPixbuf *purple_person_get_avatar(PurplePerson *person);
+PurpleAvatar *purple_person_get_avatar(PurplePerson *person);
 
 /**
  * purple_person_set_avatar:
@@ -141,7 +140,7 @@
  *
  * Since: 3.0.0
  */
-void purple_person_set_avatar(PurplePerson *person, GdkPixbuf *avatar);
+void purple_person_set_avatar(PurplePerson *person, PurpleAvatar *avatar);
 
 /**
  * purple_person_get_color:
diff --git a/libpurple/purpleperson.c b/libpurple/purpleperson.c
--- a/libpurple/purpleperson.c
+++ b/libpurple/purpleperson.c
@@ -27,8 +27,8 @@
 
 	char *id;
 
-	char *alias;
-	GdkPixbuf *avatar;
+	gchar *alias;
+	PurpleAvatar *avatar;
 	char *color;
 
 	PurpleTags *tags;
@@ -143,11 +143,8 @@
 		/* If the person doesn't have an avatar set, check if the avatar
 		 * changed and notify if it has.
 		 */
-		if(!GDK_IS_PIXBUF(person->avatar)) {
-			if(old_avatar != new_avatar) {
-				g_object_notify_by_pspec(obj,
-				                         properties[PROP_AVATAR_FOR_DISPLAY]);
-			}
+		if(!PURPLE_IS_AVATAR(person->avatar)) {
+			g_object_notify_by_pspec(obj, properties[PROP_AVATAR_FOR_DISPLAY]);
 		}
 
 		g_object_thaw_notify(obj);
@@ -404,7 +401,7 @@
 	properties[PROP_AVATAR] = g_param_spec_object(
 		"avatar", "avatar",
 		"The avatar of this person",
-		GDK_TYPE_PIXBUF,
+		PURPLE_TYPE_AVATAR,
 		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
 	/**
@@ -420,7 +417,7 @@
 	properties[PROP_AVATAR_FOR_DISPLAY] = g_param_spec_object(
 		"avatar-for-display", "avatar-for-display",
 		"The avatar to display for this person",
-		GDK_TYPE_PIXBUF,
+		PURPLE_TYPE_AVATAR,
 		G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
 	/**
@@ -547,13 +544,13 @@
 	}
 }
 
-GdkPixbuf *
+PurpleAvatar *
 purple_person_get_avatar_for_display(PurplePerson *person) {
 	PurpleContactInfo *priority = NULL;
 
 	g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
 
-	if(GDK_IS_PIXBUF(person->avatar)) {
+	if(PURPLE_IS_AVATAR(person->avatar)) {
 		return person->avatar;
 	}
 
@@ -565,7 +562,7 @@
 	return NULL;
 }
 
-GdkPixbuf *
+PurpleAvatar *
 purple_person_get_avatar(PurplePerson *person) {
 	g_return_val_if_fail(PURPLE_IS_PERSON(person), NULL);
 
@@ -573,7 +570,7 @@
 }
 
 void
-purple_person_set_avatar(PurplePerson *person, GdkPixbuf *avatar) {
+purple_person_set_avatar(PurplePerson *person, PurpleAvatar *avatar) {
 	g_return_if_fail(PURPLE_IS_PERSON(person));
 
 	if(g_set_object(&person->avatar, avatar)) {
diff --git a/libpurple/tests/test_contact_info.c b/libpurple/tests/test_contact_info.c
--- a/libpurple/tests/test_contact_info.c
+++ b/libpurple/tests/test_contact_info.c
@@ -38,14 +38,14 @@
 
 static void
 test_purple_contact_info_properties(void) {
+	PurpleAvatar *avatar = NULL;
+	PurpleAvatar *avatar1 = NULL;
 	PurpleContactInfo *info = NULL;
 	PurpleContactInfoPermission permission;
 	PurplePerson *person = NULL;
 	PurplePerson *person1 = NULL;
 	PurplePresence *presence1 = NULL;
 	PurpleTags *tags = NULL;
-	GdkPixbuf *avatar = NULL;
-	GdkPixbuf *avatar1 = NULL;
 	GTimeZone *time_zone = NULL;
 	GTimeZone *time_zone1 = NULL;
 	char *id = NULL;
@@ -58,7 +58,7 @@
 	char *note = NULL;
 	char *name_for_display = NULL;
 
-	avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
+	avatar = g_object_new(PURPLE_TYPE_AVATAR, NULL);
 	person = purple_person_new();
 
 	time_zone = g_time_zone_new_utc();
diff --git a/libpurple/tests/test_person.c b/libpurple/tests/test_person.c
--- a/libpurple/tests/test_person.c
+++ b/libpurple/tests/test_person.c
@@ -63,11 +63,11 @@
 
 static void
 test_purple_person_properties(void) {
+	PurpleAvatar *avatar = NULL;
+	PurpleAvatar *avatar1 = NULL;
+	PurpleAvatar *avatar_for_display = NULL;
 	PurpleContact *person = NULL;
 	PurpleTags *tags = NULL;
-	GdkPixbuf *avatar = NULL;
-	GdkPixbuf *avatar1 = NULL;
-	GdkPixbuf *avatar_for_display = NULL;
 	char *id = NULL;
 	char *alias = NULL;
 	char *color = NULL;
@@ -75,7 +75,7 @@
 	char *name_for_display = NULL;
 
 	/* Create our avatar for testing. */
-	avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
+	avatar = g_object_new(PURPLE_TYPE_AVATAR, NULL);
 
 	/* Use g_object_new so we can test setting properties by name. All of them
 	 * call the setter methods, so by doing it this way we exercise more of the
@@ -132,9 +132,9 @@
 
 static void
 test_purple_person_avatar_for_display_person(void) {
+	PurpleAvatar *avatar = NULL;
 	PurpleContactInfo *info = NULL;
 	PurplePerson *person = NULL;
-	GdkPixbuf *avatar = NULL;
 	guint called = 0;
 
 	person = purple_person_new();
@@ -142,7 +142,7 @@
 	                 G_CALLBACK(test_purple_person_notify_cb), &called);
 	g_signal_connect(person, "notify::avatar-for-display",
 	                 G_CALLBACK(test_purple_person_notify_cb), &called);
-	avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
+	avatar = g_object_new(PURPLE_TYPE_AVATAR, NULL);
 	purple_person_set_avatar(person, avatar);
 	g_assert_cmpuint(called, ==, 2);
 
@@ -159,9 +159,9 @@
 
 static void
 test_purple_person_avatar_for_display_contact(void) {
+	PurpleAvatar *avatar = NULL;
 	PurpleContactInfo *info = NULL;
 	PurplePerson *person = NULL;
-	GdkPixbuf *avatar = NULL;
 	guint called = 0;
 
 	person = purple_person_new();
@@ -169,7 +169,7 @@
 	                 G_CALLBACK(test_purple_person_notify_cb), &called);
 
 	info = purple_contact_info_new("id");
-	avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
+	avatar = g_object_new(PURPLE_TYPE_AVATAR, NULL);
 	purple_contact_info_set_avatar(info, avatar);
 	purple_person_add_contact_info(person, info);
 
@@ -183,7 +183,8 @@
 	/* Now change the avatar on the contact info an verify that we not notified
 	 * of the property changing.
 	 */
-	avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
+	called = 0;
+	avatar = g_object_new(PURPLE_TYPE_AVATAR, NULL);
 	purple_contact_info_set_avatar(info, avatar);
 	g_assert_cmpuint(called, ==, 1);
 
diff --git a/pidgin/pidgincontactlist.c b/pidgin/pidgincontactlist.c
--- a/pidgin/pidgincontactlist.c
+++ b/pidgin/pidgincontactlist.c
@@ -130,11 +130,11 @@
                               PurplePerson *person,
                               G_GNUC_UNUSED gpointer data)
 {
+	PurpleAvatar *avatar = NULL;
 	PurpleContactInfo *info = NULL;
 	PurpleContact *contact = NULL;
 	PurpleBuddyIcon *icon = NULL;
 	GdkTexture *texture = NULL;
-	GdkPixbuf *pixbuf = NULL;
 
 	/* When filtering we get called for rows that have been filtered out. We
 	 * also get called during finalization. I'm not sure why either of these
@@ -149,9 +149,13 @@
 		return NULL;
 	}
 
-	pixbuf = purple_person_get_avatar_for_display(person);
-	if(GDK_IS_PIXBUF(pixbuf)) {
-		return gdk_texture_new_for_pixbuf(pixbuf);
+	avatar = purple_person_get_avatar_for_display(person);
+	if(PURPLE_IS_AVATAR(avatar)) {
+		GdkPixbuf *pixbuf = purple_avatar_get_pixbuf(avatar);
+
+		if(GDK_IS_PIXBUF(pixbuf)) {
+			return gdk_texture_new_for_pixbuf(pixbuf);
+		}
 	}
 
 	/* All of the contact info in the manager are PurpleContact's so this cast
