diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-04-22 03:43:24 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-04-22 03:43:24 +0800 |
commit | 940383d6760233b3c265abcfbc843ed6e036e845 (patch) | |
tree | 5a4876976788dc55cf169b4f980abd00a4ec5623 | |
parent | 4900743e0d9b494e26e9c18df1ec4dbcb39b67ac (diff) | |
download | gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.tar gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.tar.gz gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.tar.bz2 gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.tar.lz gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.tar.xz gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.tar.zst gsoc2013-evolution-940383d6760233b3c265abcfbc843ed6e036e845.zip |
Added code to create image attachment's icon in non-gui thread.
svn path=/trunk/; revision=31859
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 7 | ||||
-rw-r--r-- | widgets/misc/ChangeLog | 6 | ||||
-rw-r--r-- | widgets/misc/e-attachment-bar.c | 60 |
4 files changed, 78 insertions, 1 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index fb340f1499..a7d92febd6 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,9 @@ +2006-04-22 Srinivasa Ragavan <sragavan@novell.com> + + * em-format-html-display.c: (efhd_attachment_button), + (efhd_format_attachment): Added code to create image cache of image + attachment in the ethread instead of main thread to avoid gui lockup. + 2006-04-21 Sankar P <psankar@novell.com> * mail-mt.c: (do_op_status): diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 6ebf316d54..3a18ad28ab 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -166,6 +166,9 @@ struct _attach_puri { CamelStream *output; unsigned int shown:1; + /* Attachment */ + EAttachment *attachment; + /* image stuff */ int fit_width; int fit_height; @@ -1552,7 +1555,7 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje if (efhd->priv->attachment_bar) { file = camel_mime_part_get_filename(info->puri.part); - new = e_attachment_new_from_mime_part (info->puri.part); + new = info->attachment; if (!file) { file = "attachment.dat"; @@ -2141,6 +2144,8 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, info->handle = handle; info->shown = em_format_is_inline(emf, info->puri.part_id, info->puri.part, handle); info->snoop_mime_type = emf->snoop_mime_type; + info->attachment = e_attachment_new_from_mime_part (info->puri.part); + e_attachment_bar_create_attachment_cache (info->attachment); if (emf->valid) { info->sign = emf->valid->sign.status; diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 0199f9cad3..3e64e1bbe1 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,9 @@ +2006-04-22 Srinivasa Ragavan <sragavan@novell.com> + + + * e-attachment-bar.c: (e_attachment_bar_create_attachment_cache): + Added a new function that creates a attachment with a image cache. + 2006-03-28 Li Yuan <li.yuan@sun.com> **Fixes bug #335618 diff --git a/widgets/misc/e-attachment-bar.c b/widgets/misc/e-attachment-bar.c index 7bf8de6844..c6bf9972f3 100644 --- a/widgets/misc/e-attachment-bar.c +++ b/widgets/misc/e-attachment-bar.c @@ -233,6 +233,66 @@ calculate_height_width(EAttachmentBar *bar, int *new_width, int *new_height) return; } +void +e_attachment_bar_create_attachment_cache (EAttachment *attachment) +{ + + CamelContentType *content_type; + + content_type = camel_mime_part_get_content_type (attachment->body); + + if (camel_content_type_is(content_type, "image", "*")) { + CamelDataWrapper *wrapper; + CamelStreamMem *mstream; + GdkPixbufLoader *loader; + gboolean error = TRUE; + GdkPixbuf *pixbuf; + + wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body)); + mstream = (CamelStreamMem *) camel_stream_mem_new (); + + camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mstream); + + /* Stream image into pixbuf loader */ + loader = gdk_pixbuf_loader_new (); + error = !gdk_pixbuf_loader_write (loader, mstream->buffer->data, mstream->buffer->len, NULL); + gdk_pixbuf_loader_close (loader, NULL); + + if (!error) { + int ratio, width, height; + + /* Shrink pixbuf */ + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + if (width >= height) { + if (width > 48) { + ratio = width / 48; + width = 48; + height = height / ratio; + } + } else { + if (height > 48) { + ratio = height / 48; + height = 48; + width = width / ratio; + } + } + + attachment->pixbuf_cache = gdk_pixbuf_scale_simple (pixbuf, width,height,GDK_INTERP_BILINEAR); + pixbuf = attachment->pixbuf_cache; + g_object_ref(pixbuf); + } else { + attachment->pixbuf_cache = NULL; + g_warning ("GdkPixbufLoader Error"); + } + + /* Destroy everything */ + g_object_unref (loader); + camel_object_unref (mstream); + } +} + static void update (EAttachmentBar *bar) { |