aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2000-10-01 11:48:33 +0800
committerIain Holmes <iain@src.gnome.org>2000-10-01 11:48:33 +0800
commitf8b0f806eda3880363e28fa929c461e810bd3383 (patch)
treeefeb843a9ce1b90ac679ae3f70f3dba8480745e1 /mail
parent9d6c76ce37be81f83d3df0cf2bfc8d81adfa18e8 (diff)
downloadgsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.tar
gsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.tar.gz
gsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.tar.bz2
gsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.tar.lz
gsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.tar.xz
gsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.tar.zst
gsoc2013-evolution-f8b0f806eda3880363e28fa929c461e810bd3383.zip
Eye-candy, eye-candy.
Added attachment image thumbnailing to mail-display.c svn path=/trunk/; revision=5649
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog6
-rw-r--r--mail/mail-display.c110
2 files changed, 106 insertions, 10 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4efd9d252e..183b82b1da 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2000-10-01 Iain Holmes <iain@helixcode.com>
+
+ * mail-display.c (on_object_requested): If the attachment is an image
+ display a thumbnail of it, instead of the generic image icon.
+
2000-09-29 Miguel de Icaza <miguel@helixcode.com>
* folder-browser-factory.c: Add print preview verb here.
@@ -384,6 +389,7 @@
(thread_messages_free): Remove the return, run as is.
(prune_empty): Plugged another small leak.
+>>>>>>> 1.552
2000-09-11 Jeffrey Stedfast <fejj@helixcode.com>
* mail-callbacks.c (run_filter_ondemand): Updated to use the new
diff --git a/mail/mail-display.c b/mail/mail-display.c
index bc864b0aca..20a9a1cd41 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -26,6 +26,10 @@
#include <libgnomevfs/gnome-vfs-mime-info.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <bonobo/bonobo-ui-toolbar-icon.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk-pixbuf/gdk-pixbuf-loader.h>
+
#define PARENT_TYPE (gtk_vbox_get_type ())
static GtkObjectClass *mail_display_parent_class;
@@ -355,17 +359,103 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
const char *icon;
GtkWidget *pixmap, *ebox;
- icon = gnome_vfs_mime_get_value (eb->type, "icon-filename");
- if (icon) {
- pixmap = gnome_pixmap_new_from_file_at_size (icon,
- 24, 24);
- } else {
- char *filename;
+ if (strncmp (eb->type, "image", 5) == 0) {
+ CamelDataWrapper *iwrapper;
+ CamelStream *mstream;
+ GdkPixbufLoader *loader;
+ GdkPixbuf *pixbuf, *mini;
+ gboolean error;
+ char tmp[4096];
+ int len;
+
+ /* Get a pixbuf from the wrapper */
+
+ mstream = camel_stream_mem_new ();
+ iwrapper = camel_medium_get_content_object (medium);
+ camel_data_wrapper_write_to_stream (iwrapper, mstream);
+ camel_stream_reset (mstream);
+
+ /* ...convert the CamelStreamMem to a GdkPixbuf... */
+ loader = gdk_pixbuf_loader_new ();
+
+ do {
+ len = camel_stream_read (mstream, tmp, 4096);
+ if (len > 0) {
+ error = !gdk_pixbuf_loader_write (loader,
+ tmp,
+ len);
+ if (error)
+ break;
+ } else {
+ if (camel_stream_eos (mstream))
+ break;
+ error = TRUE;
+ break;
+ }
+ } while (!camel_stream_eos (mstream));
+
+ if (error) {
+ icon = gnome_vfs_mime_get_value (eb->type, "icon-filename");
+ if (icon) {
+ pixmap = gnome_pixmap_new_from_file_at_size
+ (icon, 24, 24);
+ } else {
+ char *filename;
+
+
+ filename = gnome_pixmap_file ("gnome-unknown.png");
+ pixmap = gnome_pixmap_new_from_file_at_size
+ (filename, 24, 24);
+ g_free (filename);
+ }
+ } else {
+ int width, height, ratio;
+
+ pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+
+ if (width >= height) {
+ if (width > 24) {
+ ratio = width / 24;
+ width = 24;
+ height /= ratio;
+ }
+ } else {
+ if (height > 24) {
+ ratio = height / 24;
+ height = 24;
+ width /= ratio;
+ }
+ }
- filename = gnome_pixmap_file ("gnome-unknown.png");
- pixmap = gnome_pixmap_new_from_file_at_size (filename,
+ mini = gdk_pixbuf_scale_simple (pixbuf,
+ width, height,
+ GDK_INTERP_BILINEAR);
+ /* Use this, because it is the gdk-pixbuf
+ version of gnome_pixmap. We need this
+ because Imlib is not threadsafe, and
+ it was causing all sorts of problems */
+ pixmap = bonobo_ui_toolbar_icon_new_from_pixbuf (mini);
+ gdk_pixbuf_unref (mini);
+ }
+
+ camel_object_unref (CAMEL_OBJECT (mstream));
+ gdk_pixbuf_loader_close (loader);
+ gtk_object_destroy (GTK_OBJECT (loader));
+ } else {
+ icon = gnome_vfs_mime_get_value (eb->type, "icon-filename");
+ if (icon) {
+ pixmap = gnome_pixmap_new_from_file_at_size (icon,
24, 24);
- g_free (filename);
+ } else {
+ char *filename;
+
+ filename = gnome_pixmap_file ("gnome-unknown.png");
+ pixmap = gnome_pixmap_new_from_file_at_size (filename,
+ 24, 24);
+ g_free (filename);
+ }
}
ebox = gtk_event_box_new ();
@@ -418,7 +508,7 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
ba = g_byte_array_new ();
cstream = camel_stream_mem_new_with_byte_array (ba);
wrapper = camel_medium_get_content_object (medium);
- camel_data_wrapper_write_to_stream (wrapper, cstream);
+ camel_data_wrapper_write_to_stream (wrapper, cstream);
/* ...convert the CamelStreamMem to a BonoboStreamMem... */
bstream = bonobo_stream_mem_create (ba->data, ba->len, TRUE, FALSE);