comparison src/conversation.c @ 3380:d59394b4c5a6

[gaim-migrate @ 3399] Buddy icons don't blow up anymore. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 07 Aug 2002 19:52:31 +0000
parents 3cd2fbddf95a
children e9a89676d120
comparison
equal deleted inserted replaced
3379:b48b73ef172b 3380:d59394b4c5a6
3349 GDK_INTERP_NEAREST); 3349 GDK_INTERP_NEAREST);
3350 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); 3350 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100);
3351 gdk_pixbuf_unref(scale); 3351 gdk_pixbuf_unref(scale);
3352 gtk_pixmap_set(GTK_PIXMAP(c->icon), pm, bm); 3352 gtk_pixmap_set(GTK_PIXMAP(c->icon), pm, bm);
3353 gdk_pixmap_unref(pm); 3353 gdk_pixmap_unref(pm);
3354 gtk_widget_queue_draw(c->icon);
3354 if (bm) 3355 if (bm)
3355 gdk_bitmap_unref(bm); 3356 gdk_bitmap_unref(bm);
3356 delay = MAX(gdk_pixbuf_animation_iter_get_delay_time(c->iter), 13); 3357 delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter) / 10;
3357 #else 3358 #else
3358 frames = gdk_pixbuf_animation_get_frames(c->anim); 3359 frames = gdk_pixbuf_animation_get_frames(c->anim);
3359 frame = g_list_nth_data(frames, c->frame); 3360 frame = g_list_nth_data(frames, c->frame);
3360 switch (gdk_pixbuf_frame_get_action(frame)) { 3361 switch (gdk_pixbuf_frame_get_action(frame)) {
3361 case GDK_PIXBUF_FRAME_RETAIN: 3362 case GDK_PIXBUF_FRAME_RETAIN:
3439 { 3440 {
3440 GList *frames; 3441 GList *frames;
3441 GdkPixbufFrame *frame; 3442 GdkPixbufFrame *frame;
3442 int delay; 3443 int delay;
3443 #if GTK_CHECK_VERSION(1,3,0) 3444 #if GTK_CHECK_VERSION(1,3,0)
3444 delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter); 3445 delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter) / 10;
3445 #else 3446 #else
3446 frames = gdk_pixbuf_animation_get_frames(c->anim); 3447 frames = gdk_pixbuf_animation_get_frames(c->anim);
3447 frame = g_list_nth_data(frames, c->frame); 3448 frame = g_list_nth_data(frames, c->frame);
3448 delay = MAX(gdk_pixbuf_frame_get_delay_time(frame), 13); 3449 delay = MAX(gdk_pixbuf_frame_get_delay_time(frame), 13);
3449 #endif 3450 #endif
3614 { 3615 {
3615 #if USE_PIXBUF || GTK_CHECK_VERSION(1,3,0) 3616 #if USE_PIXBUF || GTK_CHECK_VERSION(1,3,0)
3616 char filename[256]; 3617 char filename[256];
3617 FILE *file; 3618 FILE *file;
3618 #if GTK_CHECK_VERSION(1,3,0) 3619 #if GTK_CHECK_VERSION(1,3,0)
3619 GError *err; 3620 GError *err = NULL;
3620 #endif 3621 #endif
3621 void *data; 3622 void *data;
3622 int len, delay; 3623 int len, delay;
3623 3624
3624 GList *frames; 3625 GList *frames;
3655 fwrite(data, 1, len, file); 3656 fwrite(data, 1, len, file);
3656 fclose(file); 3657 fclose(file);
3657 3658
3658 #if GTK_CHECK_VERSION(1,3,0) 3659 #if GTK_CHECK_VERSION(1,3,0)
3659 c->anim = gdk_pixbuf_animation_new_from_file(filename, &err); 3660 c->anim = gdk_pixbuf_animation_new_from_file(filename, &err);
3661 if (err) {
3662 debug_printf("Buddy icon error: %s\n", err->message);
3663 g_error_free(err);
3664 }
3660 #else 3665 #else
3661 c->anim = gdk_pixbuf_animation_new_from_file(filename); 3666 c->anim = gdk_pixbuf_animation_new_from_file(filename);
3662 #endif 3667 #endif
3663 /* make sure we remove the file as soon as possible */ 3668 /* make sure we remove the file as soon as possible */
3664 unlink(filename); 3669 unlink(filename);
3665 3670
3666 if (!c->anim) 3671 if (!c->anim)
3667 return; 3672 return;
3668 3673
3669 #if GTK_CHECK_VERSION(1,3,0) 3674 #if GTK_CHECK_VERSION(1,3,0)
3675 if (gdk_pixbuf_animation_is_static_image(c->anim)) {
3676 c->iter = NULL;
3677 delay = 0;
3678 buf = gdk_pixbuf_animation_get_static_image(c->anim);
3679 } else {
3670 c->iter = gdk_pixbuf_animation_get_iter(c->anim, NULL); 3680 c->iter = gdk_pixbuf_animation_get_iter(c->anim, NULL);
3671 buf = gdk_pixbuf_animation_iter_get_pixbuf(c->iter); 3681 buf = gdk_pixbuf_animation_iter_get_pixbuf(c->iter);
3682 delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter);
3683 delay = delay / 10;
3684 }
3685 sf = SCALE(c->anim);
3672 scale = gdk_pixbuf_scale_simple(buf, 3686 scale = gdk_pixbuf_scale_simple(buf,
3673 MAX(gdk_pixbuf_get_width(buf) * sf / 3687 MAX(gdk_pixbuf_get_width(buf) * sf /
3674 gdk_pixbuf_animation_get_width(c->anim), 1), 3688 gdk_pixbuf_animation_get_width(c->anim), 1),
3675 MAX(gdk_pixbuf_get_height(buf) * sf / 3689 MAX(gdk_pixbuf_get_height(buf) * sf /
3676 gdk_pixbuf_animation_get_height(c->anim), 1), 3690 gdk_pixbuf_animation_get_height(c->anim), 1),
3677 GDK_INTERP_NEAREST); 3691 GDK_INTERP_NEAREST);
3678 delay = gdk_pixbuf_animation_iter_get_delay_time(c->iter); 3692
3679 #else 3693 #else
3680 c->frame = 1; 3694 c->frame = 1;
3681 frames = gdk_pixbuf_animation_get_frames(c->anim); 3695 frames = gdk_pixbuf_animation_get_frames(c->anim);
3682 buf = gdk_pixbuf_frame_get_pixbuf(frames->data); 3696 buf = gdk_pixbuf_frame_get_pixbuf(frames->data);
3683 sf = SCALE(c->anim); 3697 sf = SCALE(c->anim);
3691 delay = MAX(gdk_pixbuf_frame_get_delay_time(frames->data), 13); 3705 delay = MAX(gdk_pixbuf_frame_get_delay_time(frames->data), 13);
3692 } else { 3706 } else {
3693 delay = 0; 3707 delay = 0;
3694 } 3708 }
3695 #endif 3709 #endif
3696 if (delay) 3710 if (delay)
3697 c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c); 3711 c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c);
3698 3712
3699 3713
3700 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); 3714 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100);
3701 gdk_pixbuf_unref(scale); 3715 gdk_pixbuf_unref(scale);
3702 3716