changeset 10381:9f50c31a41f9

[gaim-migrate @ 11607] Gabor Farkas wanted to hack his blist.xml file so he could set buddy icons for jabber buddies, who's screenname's have slashes in them. While I don't recommend this, his patch, which changes how we load buddy icons in conversations to not write tmp files, is good nevertheless. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 15 Dec 2004 20:34:07 +0000
parents bed8d9a7bb88
children 9f28196ed769
files COPYRIGHT src/gtkconv.c
diffstat 2 files changed, 13 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Wed Dec 15 16:27:07 2004 +0000
+++ b/COPYRIGHT	Wed Dec 15 20:34:07 2004 +0000
@@ -52,6 +52,7 @@
 Brian Enigma
 Stefan Esser
 Larry Ewing
+Gabor Farkas
 Jesse Farmer
 Gavan Fantom (gavan)
 Rob Flynn <gaim@robflynn.com>
--- a/src/gtkconv.c	Wed Dec 15 16:27:07 2004 +0000
+++ b/src/gtkconv.c	Wed Dec 15 20:34:07 2004 +0000
@@ -5305,8 +5305,8 @@
 	GaimGtkConversation *gtkconv;
 	GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv));
 
-	char filename[256];
-	FILE *file;
+	GdkPixbufLoader *loader;
+	GdkPixbufAnimation *anim;
 	GError *err = NULL;
 
 	const void *data;
@@ -5372,22 +5372,17 @@
 
 	data = gaim_buddy_icon_get_data(icon, &len);
 
-	/* this is such an evil hack, i don't know why i'm even considering it.
-	 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */
-	/* gdk-pixbuf-loader was leaky? is it still? */
-	g_snprintf(filename, sizeof(filename),
-			"%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d",
-			g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid());
-
-	if (!(file = fopen(filename, "wb")))
+	loader = gdk_pixbuf_loader_new();
+	gdk_pixbuf_loader_write(loader, data, len, NULL);
+	anim = gdk_pixbuf_loader_get_animation(loader);
+	if (anim)
+		g_object_ref(G_OBJECT(anim));
+	gdk_pixbuf_loader_close(loader, &err);
+	g_object_unref(loader);
+
+	if (!anim)
 		return;
-
-	fwrite(data, 1, len, file);
-	fclose(file);
-
-	gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err);
-	/* make sure we remove the file as soon as possible */
-	unlink(filename);
+	gtkconv->u.im->anim = anim;
 
 	if (err) {
 		gaim_debug(GAIM_DEBUG_ERROR, "gtkconv",