Mercurial > pidgin
changeset 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 | 1ac8f10ce68d |
children | ec82cbb21fe8 |
files | src/buddyicon.c src/buddyicon.h src/gtkblist.c src/gtkconv.c src/gtkimhtml.c src/gtkutils.c src/gtkutils.h |
diffstat | 7 files changed, 72 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddyicon.c Fri Jan 07 22:44:01 2005 +0000 +++ b/src/buddyicon.c Sat Jan 08 07:25:37 2005 +0000 @@ -451,3 +451,21 @@ { g_hash_table_destroy(account_cache); } + +void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height) +{ + /* this should eventually get smarter about preserving the aspect + * ratio when scaling, but gimmie a break, I just woke up */ + if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { + if(*width < spec->min_width) + *width = spec->min_width; + else if(*width > spec->max_width) + *width = spec->max_width; + + if(*height < spec->min_height) + *height = spec->min_height; + else if(*height > spec->max_height) + *height = spec->max_height; + } +} +
--- a/src/buddyicon.h Fri Jan 07 22:44:01 2005 +0000 +++ b/src/buddyicon.h Sat Jan 08 07:25:37 2005 +0000 @@ -29,6 +29,7 @@ #include "account.h" #include "blist.h" +#include "prpl.h" struct _GaimBuddyIcon { @@ -240,4 +241,16 @@ /*@}*/ +/**************************************************************************/ +/** @name Buddy Icon Helper API */ +/**************************************************************************/ +/*@{*/ + +/** + * Gets display size for a buddy icon + */ +void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height); + +/*@}*/ + #endif /* _GAIM_BUDDYICON_H_ */
--- a/src/gtkblist.c Fri Jan 07 22:44:01 2005 +0000 +++ b/src/gtkblist.c Sat Jan 08 07:25:37 2005 +0000 @@ -2066,7 +2066,7 @@ static GdkPixbuf *gaim_gtk_blist_get_buddy_icon(GaimBlistNode *node, gboolean scaled, gboolean greyed) { - GdkPixbuf *buf, *ret; + GdkPixbuf *buf, *ret = NULL; GdkPixbufLoader *loader; GaimBuddyIcon *icon; const char *data; @@ -2111,13 +2111,22 @@ if (scaled) { ret = gdk_pixbuf_scale_simple(buf,30,30, GDK_INTERP_BILINEAR); g_object_unref(G_OBJECT(buf)); - } else - ret = buf; - - return ret; + } else { + GaimAccount *account = gaim_buddy_get_account(buddy); + int scale_width, scale_height; + GaimPluginProtocolInfo *prpl_info = NULL; + + if(account && account->gc) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); + + gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); + + ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); + g_object_unref(G_OBJECT(buf)); + } } - return NULL; + return ret; } static void gaim_gtk_blist_paint_tip(GtkWidget *widget, GdkEventExpose *event, GaimBlistNode *node)
--- a/src/gtkconv.c Fri Jan 07 22:44:01 2005 +0000 +++ b/src/gtkconv.c Sat Jan 08 07:25:37 2005 +0000 @@ -2353,33 +2353,6 @@ } } -static void -get_icon_scale_size(GdkPixbufAnimation *icon, GaimBuddyIconSpec *spec, int *width, int *height) -{ - *width = gdk_pixbuf_animation_get_width(icon); - *height = gdk_pixbuf_animation_get_height(icon); - - /* this should eventually get smarter about preserving the aspect - * ratio when scaling, but gimmie a break, I just woke up */ - if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { - if(*width < spec->min_width) - *width = spec->min_width; - else if(*width > spec->max_width) - *width = spec->max_width; - - if(*height < spec->min_height) - *height = spec->min_height; - else if(*height > spec->max_height) - *height = spec->max_height; - } - - /* and now for some arbitrary sanity checks */ - if(*width > 100) - *width = 100; - if(*height > 100) - *height = 100; -} - static gboolean redraw_icon(gpointer data) { @@ -2410,7 +2383,7 @@ gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); - get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : + gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); /* this code is ugly, and scares me */ @@ -5443,7 +5416,7 @@ start_anim(NULL, conv); } - get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : + gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); scale = gdk_pixbuf_scale_simple(buf, MAX(gdk_pixbuf_get_width(buf) * scale_width /
--- a/src/gtkimhtml.c Fri Jan 07 22:44:01 2005 +0000 +++ b/src/gtkimhtml.c Sat Jan 08 07:25:37 2005 +0000 @@ -2377,6 +2377,11 @@ * font-family * font-size * text-decoration: underline + * + * TODO: + * background-color + * font-style + * font-weight */ { gchar *style, *color, *background, *family, *size;
--- a/src/gtkutils.c Fri Jan 07 22:44:01 2005 +0000 +++ b/src/gtkutils.c Sat Jan 08 07:25:37 2005 +0000 @@ -1603,3 +1603,17 @@ } g_list_free(files); } + +void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, int *width, int *height) +{ + *width = gdk_pixbuf_get_width(buf); + *height = gdk_pixbuf_get_height(buf); + + gaim_buddy_icon_get_scale_size(spec, width, height); + + /* and now for some arbitrary sanity checks */ + if(*width > 100) + *width = 100; + if(*height > 100) + *height = 100; +}
--- a/src/gtkutils.h Fri Jan 07 22:44:01 2005 +0000 +++ b/src/gtkutils.h Sat Jan 08 07:25:37 2005 +0000 @@ -366,5 +366,10 @@ */ void gaim_dnd_file_manage(GtkSelectionData *sd, GaimAccount *account, const char *who); +/** + * Convenience wrapper for gaim_buddy_icon_get_scale_size + */ +void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, int *width, int *height); + #endif /* _GAIM_GTKUTILS_H_ */