comparison src/gtkconv.c @ 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 a7a4db67040c
children c432b927b0b1
comparison
equal deleted inserted replaced
10380:bed8d9a7bb88 10381:9f50c31a41f9
5303 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) 5303 gaim_gtkconv_update_buddy_icon(GaimConversation *conv)
5304 { 5304 {
5305 GaimGtkConversation *gtkconv; 5305 GaimGtkConversation *gtkconv;
5306 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); 5306 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv));
5307 5307
5308 char filename[256]; 5308 GdkPixbufLoader *loader;
5309 FILE *file; 5309 GdkPixbufAnimation *anim;
5310 GError *err = NULL; 5310 GError *err = NULL;
5311 5311
5312 const void *data; 5312 const void *data;
5313 size_t len; 5313 size_t len;
5314 5314
5370 if (icon == NULL) 5370 if (icon == NULL)
5371 return; 5371 return;
5372 5372
5373 data = gaim_buddy_icon_get_data(icon, &len); 5373 data = gaim_buddy_icon_get_data(icon, &len);
5374 5374
5375 /* this is such an evil hack, i don't know why i'm even considering it. 5375 loader = gdk_pixbuf_loader_new();
5376 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ 5376 gdk_pixbuf_loader_write(loader, data, len, NULL);
5377 /* gdk-pixbuf-loader was leaky? is it still? */ 5377 anim = gdk_pixbuf_loader_get_animation(loader);
5378 g_snprintf(filename, sizeof(filename), 5378 if (anim)
5379 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", 5379 g_object_ref(G_OBJECT(anim));
5380 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); 5380 gdk_pixbuf_loader_close(loader, &err);
5381 5381 g_object_unref(loader);
5382 if (!(file = fopen(filename, "wb"))) 5382
5383 if (!anim)
5383 return; 5384 return;
5384 5385 gtkconv->u.im->anim = anim;
5385 fwrite(data, 1, len, file);
5386 fclose(file);
5387
5388 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err);
5389 /* make sure we remove the file as soon as possible */
5390 unlink(filename);
5391 5386
5392 if (err) { 5387 if (err) {
5393 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", 5388 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv",
5394 "Buddy icon error: %s\n", err->message); 5389 "Buddy icon error: %s\n", err->message);
5395 g_error_free(err); 5390 g_error_free(err);