Mercurial > pidgin.yaz
comparison libgaim/buddyicon.c @ 15223:26357b7f117e
[gaim-migrate @ 18012]
* Get rid of an assertion failure that I think was happening when
you added a new account without setting a custom icon for it, and
you still had the Accounts window open
* A little code-reuse in some buddy icon scaling code
* An minor memleak that could happen when unable open a new file in
$HOME/.gaim/icons/
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 17 Dec 2006 05:04:23 +0000 |
parents | 58a23f416729 |
children |
comparison
equal
deleted
inserted
replaced
15222:3043806ad900 | 15223:26357b7f117e |
---|---|
544 g_hash_table_destroy(account_cache); | 544 g_hash_table_destroy(account_cache); |
545 } | 545 } |
546 | 546 |
547 void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height) | 547 void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height) |
548 { | 548 { |
549 if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { | 549 int new_width, new_height; |
550 int new_width, new_height; | 550 |
551 | 551 new_width = *width; |
552 new_width = *width; | 552 new_height = *height; |
553 new_height = *height; | 553 |
554 | 554 if (*width < spec->min_width) |
555 if(*width < spec->min_width) | 555 new_width = spec->min_width; |
556 new_width = spec->min_width; | 556 else if (*width > spec->max_width) |
557 else if(*width > spec->max_width) | 557 new_width = spec->max_width; |
558 new_width = spec->max_width; | 558 |
559 | 559 if (*height < spec->min_height) |
560 if(*height < spec->min_height) | 560 new_height = spec->min_height; |
561 new_height = spec->min_height; | 561 else if (*height > spec->max_height) |
562 else if(*height > spec->max_height) | 562 new_height = spec->max_height; |
563 new_height = spec->max_height; | 563 |
564 | 564 /* preserve aspect ratio */ |
565 /* preserve aspect ratio */ | 565 if ((double)*height * (double)new_width > |
566 if ((double)*height * (double)new_width > | 566 (double)*width * (double)new_height) { |
567 (double)*width * (double)new_height) { | 567 new_width = 0.5 + (double)*width * (double)new_height / (double)*height; |
568 new_width = 0.5 + (double)*width * (double)new_height / (double)*height; | 568 } else { |
569 } else { | 569 new_height = 0.5 + (double)*height * (double)new_width / (double)*width; |
570 new_height = 0.5 + (double)*height * (double)new_width / (double)*width; | 570 } |
571 } | 571 |
572 | 572 *width = new_width; |
573 *width = new_width; | 573 *height = new_height; |
574 *height = new_height; | 574 } |
575 } | 575 |
576 } | |
577 |