Mercurial > pidgin.yaz
diff pidgin/gtkft.c @ 30218:5502f855ec2b
propagate from branch 'im.pidgin.pidgin' (head 0d33eae1cfd57cb5f459518ad5db14230f13792b)
to branch 'im.pidgin.cpw.malu.ft_thumbnails' (head 787088ed111a5a80051cdedac170a0eae9bdadcc)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 20 Oct 2009 22:32:09 +0000 |
parents | 852ce9929402 |
children | cb09d358d777 |
line wrap: on
line diff
--- a/pidgin/gtkft.c Tue Oct 20 21:20:22 2009 +0000 +++ b/pidgin/gtkft.c Tue Oct 20 22:32:09 2009 +0000 @@ -42,6 +42,9 @@ #define PIDGINXFER(xfer) \ (PidginXferUiData *)(xfer)->ui_data +/* the maximum size of files we will try to make a thumbnail for */ +#define PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL 10 * 1024 * 1024 + struct _PidginXferDialog { gboolean keep_open; @@ -1150,6 +1153,35 @@ pidgin_xfer_dialog_cancel_xfer(xfer_dialog, xfer); } +static void +pidgin_xfer_add_thumbnail(PurpleXfer *xfer) +{ + purple_debug_info("pidgin", "creating thumbnail for transfer\n"); + + if (purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) { + GdkPixbuf *thumbnail = + gdk_pixbuf_new_from_file_at_size( + purple_xfer_get_local_filename(xfer), 128, 128, NULL); + + if (thumbnail) { + gpointer *buffer = NULL; + gsize size; + char *option_keys[2] = {"quality", NULL}; + char *option_values[2] = {"75", NULL}; + gdk_pixbuf_save_to_bufferv(thumbnail, &buffer, &size, "jpeg", + option_keys, option_values, NULL); + + if (buffer) { + purple_debug_info("pidgin", "created thumbnail of %d bytes\n", + size); + purple_xfer_set_thumbnail(xfer, buffer, size); + g_free(buffer); + } + g_object_unref(thumbnail); + } + } +} + static PurpleXferUiOps ops = { pidgin_xfer_new_xfer, @@ -1158,7 +1190,7 @@ pidgin_xfer_update_progress, pidgin_xfer_cancel_local, pidgin_xfer_cancel_remote, - NULL, + pidgin_xfer_add_thumbnail, NULL, NULL, NULL