Mercurial > pidgin
diff pidgin/gtkft.c @ 29812:1e8dc177415e
propagate from branch 'im.pidgin.pidgin' (head 267f28808ab6eeda6b5d68f6433f2b3fcf230d4f)
to branch 'im.pidgin.cpw.malu.ft_thumbnails' (head e638c5bb96c2400620511beaf38c52bedb56db4b)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Thu, 18 Feb 2010 21:59:26 +0000 |
parents | 2b9db39bd7ed cb09d358d777 |
children | 6d3a90b49dba |
line wrap: on
line diff
--- a/pidgin/gtkft.c Thu Feb 18 19:29:11 2010 +0000 +++ b/pidgin/gtkft.c Thu Feb 18 21:59:26 2010 +0000 @@ -40,6 +40,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; @@ -1157,6 +1160,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, @@ -1168,7 +1200,7 @@ NULL, NULL, NULL, - NULL + pidgin_xfer_add_thumbnail }; /**************************************************************************