changeset 22484:ed786719b10a

scale & round the buddy icon in the buddy list before making it square, so rectangular (but non-square) images get rounded corners too. Fixes #2110
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 16 Mar 2008 18:55:07 +0000
parents 7a815907ba5a
children b5af505a7b02
files ChangeLog pidgin/gtkblist.c
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 15 19:41:30 2008 +0000
+++ b/ChangeLog	Sun Mar 16 18:55:07 2008 +0000
@@ -24,6 +24,8 @@
 	* Fix for displaying channel & buddy names in conversation window when
 	  they have '&' in them
 	* Some memory leak fixes, especially in the Text Replacement plugin
+	* Rectangular but non-square buddy icons have rounded corners in the buddy
+	  list
 
 	Finch:
 	* Fix compiling with Glib older than 2.6
--- a/pidgin/gtkblist.c	Sat Mar 15 19:41:30 2008 +0000
+++ b/pidgin/gtkblist.c	Sun Mar 16 18:55:07 2008 +0000
@@ -2498,6 +2498,7 @@
 			purple_buddy_icon_get_scale_size(&prpl_info->icon_spec, &scale_width, &scale_height);
 
 		if (scaled || scale_height > 200 || scale_width > 200) {
+			GdkPixbuf *tmpbuf;
 			float scale_size = scaled ? 32.0 : 200.0;
 			if(scale_height > scale_width) {
 				scale_width = scale_size * (double)scale_width / (double)scale_height;
@@ -2506,12 +2507,17 @@
 				scale_height = scale_size * (double)scale_height / (double)scale_width;
 				scale_width = scale_size;
 			}
-
+			/* scale & round before making square, so rectangular (but non-square)
+			 * images get rounded corners too */
+			tmpbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height);
+			gdk_pixbuf_fill(tmpbuf, 0x00000000);
+			gdk_pixbuf_scale(buf, tmpbuf, 0, 0, scale_width, scale_height, 0, 0, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR);
+			if (pidgin_gdk_pixbuf_is_opaque(tmpbuf))
+				pidgin_gdk_pixbuf_make_round(tmpbuf);
 			ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_size, scale_size);
 			gdk_pixbuf_fill(ret, 0x00000000);
-			gdk_pixbuf_scale(buf, ret, (scale_size-scale_width)/2, (scale_size-scale_height)/2, scale_width, scale_height, (scale_size-scale_width)/2, (scale_size-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR);
-			if (pidgin_gdk_pixbuf_is_opaque(ret))
-				pidgin_gdk_pixbuf_make_round(ret);
+			gdk_pixbuf_copy_area(tmpbuf, 0, 0, scale_width, scale_height, ret, (scale_size-scale_width)/2, (scale_size-scale_height)/2);
+			g_object_unref(G_OBJECT(tmpbuf));
 		} else {
 			ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR);
 		}