comparison pidgin/gtkft.c @ 30227: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
comparison
equal deleted inserted replaced
29795:bc2760c74a79 30227:1e8dc177415e
38 #include "gtkutils.h" 38 #include "gtkutils.h"
39 39
40 #define PIDGINXFER(xfer) \ 40 #define PIDGINXFER(xfer) \
41 (PidginXferUiData *)(xfer)->ui_data 41 (PidginXferUiData *)(xfer)->ui_data
42 42
43 /* the maximum size of files we will try to make a thumbnail for */
44 #define PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL 10 * 1024 * 1024
45
43 struct _PidginXferDialog 46 struct _PidginXferDialog
44 { 47 {
45 gboolean keep_open; 48 gboolean keep_open;
46 gboolean auto_clear; 49 gboolean auto_clear;
47 50
1155 { 1158 {
1156 if (xfer_dialog) 1159 if (xfer_dialog)
1157 pidgin_xfer_dialog_cancel_xfer(xfer_dialog, xfer); 1160 pidgin_xfer_dialog_cancel_xfer(xfer_dialog, xfer);
1158 } 1161 }
1159 1162
1163 static void
1164 pidgin_xfer_add_thumbnail(PurpleXfer *xfer)
1165 {
1166 purple_debug_info("pidgin", "creating thumbnail for transfer\n");
1167
1168 if (purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) {
1169 GdkPixbuf *thumbnail =
1170 gdk_pixbuf_new_from_file_at_size(
1171 purple_xfer_get_local_filename(xfer), 128, 128, NULL);
1172
1173 if (thumbnail) {
1174 gpointer *buffer = NULL;
1175 gsize size;
1176 char *option_keys[2] = {"quality", NULL};
1177 char *option_values[2] = {"75", NULL};
1178 gdk_pixbuf_save_to_bufferv(thumbnail, &buffer, &size, "jpeg",
1179 option_keys, option_values, NULL);
1180
1181 if (buffer) {
1182 purple_debug_info("pidgin", "created thumbnail of %d bytes\n",
1183 size);
1184 purple_xfer_set_thumbnail(xfer, buffer, size);
1185 g_free(buffer);
1186 }
1187 g_object_unref(thumbnail);
1188 }
1189 }
1190 }
1191
1160 static PurpleXferUiOps ops = 1192 static PurpleXferUiOps ops =
1161 { 1193 {
1162 pidgin_xfer_new_xfer, 1194 pidgin_xfer_new_xfer,
1163 pidgin_xfer_destroy, 1195 pidgin_xfer_destroy,
1164 pidgin_xfer_add_xfer, 1196 pidgin_xfer_add_xfer,
1166 pidgin_xfer_cancel_local, 1198 pidgin_xfer_cancel_local,
1167 pidgin_xfer_cancel_remote, 1199 pidgin_xfer_cancel_remote,
1168 NULL, 1200 NULL,
1169 NULL, 1201 NULL,
1170 NULL, 1202 NULL,
1171 NULL 1203 pidgin_xfer_add_thumbnail
1172 }; 1204 };
1173 1205
1174 /************************************************************************** 1206 /**************************************************************************
1175 * GTK+ File Transfer API 1207 * GTK+ File Transfer API
1176 **************************************************************************/ 1208 **************************************************************************/