comparison src/conversation.c @ 2227:a93a6fe22330

[gaim-migrate @ 2237] yay committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 06 Sep 2001 20:46:06 +0000
parents a226ebf4be47
children 8c4ff1a368bd
comparison
equal deleted inserted replaced
2226:2a09a177ed5f 2227:a93a6fe22330
2477 } 2477 }
2478 2478
2479 #if USE_PIXBUF 2479 #if USE_PIXBUF
2480 #include <gdk-pixbuf/gdk-pixbuf.h> 2480 #include <gdk-pixbuf/gdk-pixbuf.h>
2481 #include <gdk-pixbuf/gdk-pixbuf-loader.h> 2481 #include <gdk-pixbuf/gdk-pixbuf-loader.h>
2482 #define SCALE 50 2482
2483 #define SCALE(x) ((gdk_pixbuf_animation_get_width(x) <= 48 && gdk_pixbuf_animation_get_height(x) <= 48) \
2484 ? 48 : 50)
2485 #define SCALEBUF(x) ((gdk_pixbuf_get_width(x) <= 48 && gdk_pixbuf_get_height(x) <= 48) ? 48 : 50)
2483 2486
2484 static gboolean redraw_icon(gpointer data) 2487 static gboolean redraw_icon(gpointer data)
2485 { 2488 {
2486 struct conversation *c = data; 2489 struct conversation *c = data;
2487 2490
2504 frame = g_list_nth_data(frames, c->frame); 2507 frame = g_list_nth_data(frames, c->frame);
2505 switch (gdk_pixbuf_frame_get_action(frame)) { 2508 switch (gdk_pixbuf_frame_get_action(frame)) {
2506 case GDK_PIXBUF_FRAME_RETAIN: 2509 case GDK_PIXBUF_FRAME_RETAIN:
2507 buf = gdk_pixbuf_frame_get_pixbuf(frame); 2510 buf = gdk_pixbuf_frame_get_pixbuf(frame);
2508 scale = gdk_pixbuf_scale_simple(buf, 2511 scale = gdk_pixbuf_scale_simple(buf,
2509 MAX(gdk_pixbuf_get_width(buf) * SCALE / 2512 MAX(gdk_pixbuf_get_width(buf) * SCALE(c->anim) /
2510 gdk_pixbuf_animation_get_width(c->anim), 1), 2513 gdk_pixbuf_animation_get_width(c->anim), 1),
2511 MAX(gdk_pixbuf_get_height(buf) * SCALE / 2514 MAX(gdk_pixbuf_get_height(buf) * SCALE(c->anim) /
2512 gdk_pixbuf_animation_get_height(c->anim), 1), 2515 gdk_pixbuf_animation_get_height(c->anim), 1),
2513 GDK_INTERP_NEAREST); 2516 GDK_INTERP_NEAREST);
2514 gdk_pixbuf_render_pixmap_and_mask(scale, &src, NULL, 0); 2517 gdk_pixbuf_render_pixmap_and_mask(scale, &src, NULL, 0);
2515 gdk_pixbuf_unref(scale); 2518 gdk_pixbuf_unref(scale);
2516 gtk_pixmap_get(GTK_PIXMAP(c->icon), &pm, &bm); 2519 gtk_pixmap_get(GTK_PIXMAP(c->icon), &pm, &bm);
2517 gc = gdk_gc_new(pm); 2520 gc = gdk_gc_new(pm);
2518 gdk_draw_pixmap(pm, gc, src, 0, 0, 2521 gdk_draw_pixmap(pm, gc, src, 0, 0,
2519 MAX(gdk_pixbuf_frame_get_x_offset(frame) * SCALE / 2522 MAX(gdk_pixbuf_frame_get_x_offset(frame) * SCALE(c->anim) /
2520 gdk_pixbuf_animation_get_width(c->anim), 1), 2523 gdk_pixbuf_animation_get_width(c->anim), 1),
2521 MAX(gdk_pixbuf_frame_get_y_offset(frame) * SCALE / 2524 MAX(gdk_pixbuf_frame_get_y_offset(frame) * SCALE(c->anim) /
2522 gdk_pixbuf_animation_get_height(c->anim), 1), 2525 gdk_pixbuf_animation_get_height(c->anim), 1),
2523 -1, -1); 2526 -1, -1);
2524 gdk_pixmap_unref(src); 2527 gdk_pixmap_unref(src);
2525 gtk_widget_queue_draw(c->icon); 2528 gtk_widget_queue_draw(c->icon);
2526 gdk_gc_unref(gc); 2529 gdk_gc_unref(gc);
2527 break; 2530 break;
2528 case GDK_PIXBUF_FRAME_DISPOSE: 2531 case GDK_PIXBUF_FRAME_DISPOSE:
2529 buf = gdk_pixbuf_frame_get_pixbuf(frame); 2532 buf = gdk_pixbuf_frame_get_pixbuf(frame);
2530 scale = gdk_pixbuf_scale_simple(buf, 2533 scale = gdk_pixbuf_scale_simple(buf,
2531 MAX(gdk_pixbuf_get_width(buf) * SCALE / 2534 MAX(gdk_pixbuf_get_width(buf) * SCALE(c->anim) /
2532 gdk_pixbuf_animation_get_width(c->anim), 1), 2535 gdk_pixbuf_animation_get_width(c->anim), 1),
2533 MAX(gdk_pixbuf_get_height(buf) * SCALE / 2536 MAX(gdk_pixbuf_get_height(buf) * SCALE(c->anim) /
2534 gdk_pixbuf_animation_get_height(c->anim), 1), 2537 gdk_pixbuf_animation_get_height(c->anim), 1),
2535 GDK_INTERP_NEAREST); 2538 GDK_INTERP_NEAREST);
2536 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 0); 2539 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 0);
2537 gdk_pixbuf_unref(scale); 2540 gdk_pixbuf_unref(scale);
2538 gtk_pixmap_set(GTK_PIXMAP(c->icon), pm, bm); 2541 gtk_pixmap_set(GTK_PIXMAP(c->icon), pm, bm);
2542 break; 2545 break;
2543 case GDK_PIXBUF_FRAME_REVERT: 2546 case GDK_PIXBUF_FRAME_REVERT:
2544 frame = frames->data; 2547 frame = frames->data;
2545 buf = gdk_pixbuf_frame_get_pixbuf(frame); 2548 buf = gdk_pixbuf_frame_get_pixbuf(frame);
2546 scale = gdk_pixbuf_scale_simple(buf, 2549 scale = gdk_pixbuf_scale_simple(buf,
2547 MAX(gdk_pixbuf_get_width(buf) * SCALE / 2550 MAX(gdk_pixbuf_get_width(buf) * SCALE(c->anim) /
2548 gdk_pixbuf_animation_get_width(c->anim), 1), 2551 gdk_pixbuf_animation_get_width(c->anim), 1),
2549 MAX(gdk_pixbuf_get_height(buf) * SCALE / 2552 MAX(gdk_pixbuf_get_height(buf) * SCALE(c->anim) /
2550 gdk_pixbuf_animation_get_height(c->anim), 1), 2553 gdk_pixbuf_animation_get_height(c->anim), 1),
2551 GDK_INTERP_NEAREST); 2554 GDK_INTERP_NEAREST);
2552 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 0); 2555 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 0);
2553 gdk_pixbuf_unref(scale); 2556 gdk_pixbuf_unref(scale);
2554 gtk_pixmap_set(GTK_PIXMAP(c->icon), pm, bm); 2557 gtk_pixmap_set(GTK_PIXMAP(c->icon), pm, bm);
2614 2617
2615 if (c->anim) { 2618 if (c->anim) {
2616 GList *frames = gdk_pixbuf_animation_get_frames(c->anim); 2619 GList *frames = gdk_pixbuf_animation_get_frames(c->anim);
2617 GdkPixbuf *buf = gdk_pixbuf_frame_get_pixbuf(frames->data); 2620 GdkPixbuf *buf = gdk_pixbuf_frame_get_pixbuf(frames->data);
2618 scale = gdk_pixbuf_scale_simple(buf, 2621 scale = gdk_pixbuf_scale_simple(buf,
2619 MAX(gdk_pixbuf_get_width(buf) * SCALE / 2622 MAX(gdk_pixbuf_get_width(buf) * SCALE(c->anim) /
2620 gdk_pixbuf_animation_get_width(c->anim), 1), 2623 gdk_pixbuf_animation_get_width(c->anim), 1),
2621 MAX(gdk_pixbuf_get_height(buf) * SCALE / 2624 MAX(gdk_pixbuf_get_height(buf) * SCALE(c->anim) /
2622 gdk_pixbuf_animation_get_height(c->anim), 1), 2625 gdk_pixbuf_animation_get_height(c->anim), 1),
2623 GDK_INTERP_NEAREST); 2626 GDK_INTERP_NEAREST);
2624 2627
2625 if (gdk_pixbuf_animation_get_num_frames(c->anim) > 1) { 2628 if (gdk_pixbuf_animation_get_num_frames(c->anim) > 1) {
2626 int delay = MAX(gdk_pixbuf_frame_get_delay_time(frames->data), 13); 2629 int delay = MAX(gdk_pixbuf_frame_get_delay_time(frames->data), 13);
2627 c->frame = 1; 2630 c->frame = 1;
2628 c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c); 2631 c->icon_timer = gtk_timeout_add(delay * 10, redraw_icon, c);
2629 } 2632 }
2630 } else { 2633 } else {
2634 int s;
2631 c->unanim = gdk_pixbuf_loader_get_pixbuf(load); 2635 c->unanim = gdk_pixbuf_loader_get_pixbuf(load);
2632 if (!c->unanim) { 2636 if (!c->unanim) {
2633 gdk_pixbuf_loader_close(load); 2637 gdk_pixbuf_loader_close(load);
2634 return; 2638 return;
2635 } 2639 }
2636 scale = gdk_pixbuf_scale_simple(c->unanim, SCALE, SCALE, GDK_INTERP_NEAREST); 2640 s = SCALEBUF(c->unanim);
2641 scale = gdk_pixbuf_scale_simple(c->unanim, s, s, GDK_INTERP_NEAREST);
2637 } 2642 }
2638 2643
2639 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 0); 2644 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 0);
2640 gdk_pixbuf_unref(scale); 2645 gdk_pixbuf_unref(scale);
2641 2646