changeset 29871:ce52e101844a

Scale incoming thumbnails in the request dialog if they are overly large WLM seems to send animations in some situations as a series of frames "encoded" in a wide PNG...
author Marcus Lundblad <ml@update.uu.se>
date Mon, 03 May 2010 20:23:17 +0000
parents 5286451c3d44
children a044ddee7878 757a608d6b71 1147389b5424
files libpurple/ft.c pidgin/gtkrequest.c
diffstat 2 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Mon May 03 05:02:30 2010 +0000
+++ b/libpurple/ft.c	Mon May 03 20:23:17 2010 +0000
@@ -521,7 +521,7 @@
 		if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
 			purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL,
 				PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL,
-				thumb, thumb_size, xfer, 
+				thumb, thumb_size, xfer,
 				G_CALLBACK(purple_xfer_choose_file),
 				G_CALLBACK(cancel_recv_cb));
 		} else {
--- a/pidgin/gtkrequest.c	Mon May 03 05:02:30 2010 +0000
+++ b/pidgin/gtkrequest.c	Mon May 03 20:23:17 2010 +0000
@@ -668,6 +668,23 @@
 		if (gdk_pixbuf_loader_write(loader, icon_data, icon_size, NULL)) {
 			pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
 			if (pixbuf) {
+				/* scale the image if it is too large */
+				int width = gdk_pixbuf_get_width(pixbuf);
+				int height = gdk_pixbuf_get_height(pixbuf);
+				if (width > 128 || height > 128) {
+					int scaled_width = width > height ? 128 : (128 * width) / height;
+					int scaled_height = height > width ? 128 : (128 * height) / width;
+					GdkPixbuf *scaled =
+							gdk_pixbuf_scale_simple(pixbuf, scaled_width, scaled_height,
+							    GDK_INTERP_BILINEAR);
+
+					purple_debug_info("pidgin",
+					    "dialog icon was too large, scale it down\n");
+					if (scaled) {
+						g_object_unref(pixbuf);
+						pixbuf = scaled;
+					}
+				}
 				img = gtk_image_new_from_pixbuf(pixbuf);
 			}
 		} else {