comparison src/gtkconv.c @ 10483:748aa3c6de36

[gaim-migrate @ 11773] scaling for the buddy icons in the tooltips, and whatever else decided to sneak in on this commit committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 08 Jan 2005 07:25:37 +0000
parents 01558a7faa01
children 47366cf2792b
comparison
equal deleted inserted replaced
10482:1ac8f10ce68d 10483:748aa3c6de36
2351 if (status != NULL) 2351 if (status != NULL)
2352 g_object_unref(status); 2352 g_object_unref(status);
2353 } 2353 }
2354 } 2354 }
2355 2355
2356 static void
2357 get_icon_scale_size(GdkPixbufAnimation *icon, GaimBuddyIconSpec *spec, int *width, int *height)
2358 {
2359 *width = gdk_pixbuf_animation_get_width(icon);
2360 *height = gdk_pixbuf_animation_get_height(icon);
2361
2362 /* this should eventually get smarter about preserving the aspect
2363 * ratio when scaling, but gimmie a break, I just woke up */
2364 if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) {
2365 if(*width < spec->min_width)
2366 *width = spec->min_width;
2367 else if(*width > spec->max_width)
2368 *width = spec->max_width;
2369
2370 if(*height < spec->min_height)
2371 *height = spec->min_height;
2372 else if(*height > spec->max_height)
2373 *height = spec->max_height;
2374 }
2375
2376 /* and now for some arbitrary sanity checks */
2377 if(*width > 100)
2378 *width = 100;
2379 if(*height > 100)
2380 *height = 100;
2381 }
2382
2383 static gboolean 2356 static gboolean
2384 redraw_icon(gpointer data) 2357 redraw_icon(gpointer data)
2385 { 2358 {
2386 GaimConversation *conv = (GaimConversation *)data; 2359 GaimConversation *conv = (GaimConversation *)data;
2387 GaimGtkConversation *gtkconv; 2360 GaimGtkConversation *gtkconv;
2408 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); 2381 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
2409 2382
2410 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); 2383 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL);
2411 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); 2384 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter);
2412 2385
2413 get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : 2386 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec :
2414 NULL, &scale_width, &scale_height); 2387 NULL, &scale_width, &scale_height);
2415 2388
2416 /* this code is ugly, and scares me */ 2389 /* this code is ugly, and scares me */
2417 scale = gdk_pixbuf_scale_simple(buf, 2390 scale = gdk_pixbuf_scale_simple(buf,
2418 MAX(gdk_pixbuf_get_width(buf) * scale_width / 2391 MAX(gdk_pixbuf_get_width(buf) * scale_width /
5441 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); 5414 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter);
5442 if (gtkconv->u.im->animate) 5415 if (gtkconv->u.im->animate)
5443 start_anim(NULL, conv); 5416 start_anim(NULL, conv);
5444 } 5417 }
5445 5418
5446 get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : 5419 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec :
5447 NULL, &scale_width, &scale_height); 5420 NULL, &scale_width, &scale_height);
5448 scale = gdk_pixbuf_scale_simple(buf, 5421 scale = gdk_pixbuf_scale_simple(buf,
5449 MAX(gdk_pixbuf_get_width(buf) * scale_width / 5422 MAX(gdk_pixbuf_get_width(buf) * scale_width /
5450 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), 5423 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1),
5451 MAX(gdk_pixbuf_get_height(buf) * scale_height / 5424 MAX(gdk_pixbuf_get_height(buf) * scale_height /