aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-08 07:55:13 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-08 07:55:13 +0000
commiteefe7863dac9cc8046e369d14dfa0224495613ea (patch)
treed558d35059a2cadde2869b1b313698a9eee46213 /src
parentbef4be6edbe3e5748ce6075a2ca65546e16a6d19 (diff)
implemented inline image display.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@97 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/prefs_common.c51
-rw-r--r--src/prefs_common.h3
-rw-r--r--src/procmime.c24
-rw-r--r--src/procmime.h3
-rw-r--r--src/textview.c32
5 files changed, 95 insertions, 18 deletions
diff --git a/src/prefs_common.c b/src/prefs_common.c
index dd74803f..459f1d00 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -145,6 +145,7 @@ static struct Message {
GtkWidget *chkbtn_halfpage;
GtkWidget *chkbtn_resize_image;
+ GtkWidget *chkbtn_inline_image;
} message;
#if USE_GPGME
@@ -543,6 +544,9 @@ static PrefParam param[] = {
{"resize_image", "TRUE", &prefs_common.resize_image, P_BOOL,
&message.chkbtn_resize_image,
prefs_set_data_from_toggle, prefs_set_toggle},
+ {"inline_image", "TRUE", &prefs_common.inline_image, P_BOOL,
+ &message.chkbtn_inline_image,
+ prefs_set_data_from_toggle, prefs_set_toggle},
{"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
NULL, NULL, NULL},
@@ -1427,10 +1431,13 @@ static void prefs_quote_create(void)
scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwin_quotefmt);
- gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
+ TRUE, TRUE, 0);
gtk_scrolled_window_set_policy
(GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+ gtk_scrolled_window_set_shadow_type
+ (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
text_quotefmt = gtk_text_view_new ();
gtk_widget_show (text_quotefmt);
@@ -1467,10 +1474,13 @@ static void prefs_quote_create(void)
scrolledwin_quotefmt = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwin_quotefmt);
- gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox_quote), scrolledwin_quotefmt,
+ TRUE, TRUE, 0);
gtk_scrolled_window_set_policy
(GTK_SCROLLED_WINDOW (scrolledwin_quotefmt),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+ gtk_scrolled_window_set_shadow_type
+ (GTK_SCROLLED_WINDOW (scrolledwin_quotefmt), GTK_SHADOW_IN);
text_fw_quotefmt = gtk_text_view_new ();
gtk_widget_show (text_fw_quotefmt);
@@ -1675,7 +1685,10 @@ static void prefs_message_create(void)
GtkWidget *spinbtn_scrollstep;
GtkWidget *chkbtn_halfpage;
+ GtkWidget *frame_image;
+ GtkWidget *vbox_image;
GtkWidget *chkbtn_resize_image;
+ GtkWidget *chkbtn_inline_image;
vbox1 = gtk_vbox_new (FALSE, VSPACING);
gtk_widget_show (vbox1);
@@ -1797,8 +1810,17 @@ static void prefs_message_create(void)
SET_TOGGLE_SENSITIVITY (chkbtn_smoothscroll, hbox_scr)
- PACK_CHECK_BUTTON(vbox1, chkbtn_resize_image,
+ PACK_FRAME(vbox1, frame_image, _("Images"));
+
+ vbox_image = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox_image);
+ gtk_container_add (GTK_CONTAINER (frame_image), vbox_image);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox_image), 8);
+
+ PACK_CHECK_BUTTON(vbox_image, chkbtn_resize_image,
_("Resize attached large images to fit in the window"));
+ PACK_CHECK_BUTTON(vbox_image, chkbtn_inline_image,
+ _("Display images as inline"));
message.chkbtn_enablecol = chkbtn_enablecol;
message.button_edit_col = button_edit_col;
@@ -1813,6 +1835,7 @@ static void prefs_message_create(void)
message.chkbtn_halfpage = chkbtn_halfpage;
message.chkbtn_resize_image = chkbtn_resize_image;
+ message.chkbtn_inline_image = chkbtn_inline_image;
}
#if USE_GPGME
@@ -1850,7 +1873,7 @@ static void prefs_privacy_create(void)
PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
_("Store passphrase in memory temporarily"));
- vbox3 = gtk_vbox_new (FALSE, 0);
+ vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
gtk_widget_show (vbox3);
gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
@@ -1889,8 +1912,8 @@ static void prefs_privacy_create(void)
gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
gtk_widget_set_size_request (hbox_spc, 12, -1);
- label = gtk_label_new (_("(Setting to '0' will store the passphrase "
- "for the whole session)"));
+ label = gtk_label_new (_("Setting to '0' will store the passphrase "
+ "for the whole session."));
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
@@ -1899,6 +1922,8 @@ static void prefs_privacy_create(void)
SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, vbox3);
+ PACK_VSPACER (vbox2, vbox3, VSPACING_NARROW_2);
+
#ifndef __MINGW32__
PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
_("Grab input while entering a passphrase"));
@@ -1937,6 +1962,7 @@ static void prefs_interface_create(void)
GtkWidget *frame_recv;
GtkWidget *vbox_recv;
GtkWidget *hbox1;
+ GtkWidget *hbox_spc;
GtkWidget *label;
GtkWidget *optmenu_recvdialog;
GtkWidget *menu;
@@ -1979,15 +2005,20 @@ static void prefs_interface_create(void)
(vbox3, checkbtn_immedexec,
_("Execute immediately when moving or deleting messages"));
- hbox1 = gtk_hbox_new (FALSE, 0);
+ hbox1 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
+ hbox_spc = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox_spc);
+ gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
+ gtk_widget_set_size_request (hbox_spc, 12, -1);
+
label = gtk_label_new
- (_("(Messages will be marked until execution "
- "if this is turned off)"));
+ (_("Messages will be marked until execution "
+ "if this is turned off."));
gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 8);
+ gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtkut_widget_set_small_font_size (label);
diff --git a/src/prefs_common.h b/src/prefs_common.h
index b2c42a58..b8075649 100644
--- a/src/prefs_common.h
+++ b/src/prefs_common.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -170,6 +170,7 @@ struct _PrefsCommon
gboolean scroll_halfpage;
gboolean resize_image;
+ gboolean inline_image;
gchar *force_charset;
diff --git a/src/procmime.c b/src/procmime.c
index a603da71..2ee91c96 100644
--- a/src/procmime.c
+++ b/src/procmime.c
@@ -629,8 +629,8 @@ FILE *procmime_decode_content(FILE *outfp, FILE *infp, MimeInfo *mimeinfo)
gint procmime_get_part(const gchar *outfile, const gchar *infile,
MimeInfo *mimeinfo)
{
- FILE *infp, *outfp;
- gchar buf[BUFFSIZE];
+ FILE *infp;
+ gint ret;
g_return_val_if_fail(outfile != NULL, -1);
g_return_val_if_fail(infile != NULL, -1);
@@ -640,14 +640,27 @@ gint procmime_get_part(const gchar *outfile, const gchar *infile,
FILE_OP_ERROR(infile, "fopen");
return -1;
}
+ ret = procmime_get_part_fp(outfile, infp, mimeinfo);
+ fclose(infp);
+
+ return ret;
+}
+
+gint procmime_get_part_fp(const gchar *outfile, FILE *infp, MimeInfo *mimeinfo)
+{
+ FILE *outfp;
+ gchar buf[BUFFSIZE];
+
+ g_return_val_if_fail(outfile != NULL, -1);
+ g_return_val_if_fail(infp != NULL, -1);
+ g_return_val_if_fail(mimeinfo != NULL, -1);
+
if (fseek(infp, mimeinfo->fpos, SEEK_SET) < 0) {
- FILE_OP_ERROR(infile, "fseek");
- fclose(infp);
+ FILE_OP_ERROR("procmime_get_part_fp()", "fseek");
return -1;
}
if ((outfp = fopen(outfile, "wb")) == NULL) {
FILE_OP_ERROR(outfile, "fopen");
- fclose(infp);
return -1;
}
@@ -656,7 +669,6 @@ gint procmime_get_part(const gchar *outfile, const gchar *infile,
procmime_decode_content(outfp, infp, mimeinfo);
- fclose(infp);
if (fclose(outfp) == EOF) {
FILE_OP_ERROR(outfile, "fclose");
unlink(outfile);
diff --git a/src/procmime.h b/src/procmime.h
index c52d4bda..c8b49435 100644
--- a/src/procmime.h
+++ b/src/procmime.h
@@ -152,6 +152,9 @@ FILE *procmime_decode_content (FILE *outfp,
gint procmime_get_part (const gchar *outfile,
const gchar *infile,
MimeInfo *mimeinfo);
+gint procmime_get_part_fp (const gchar *outfile,
+ FILE *infp,
+ MimeInfo *mimeinfo);
FILE *procmime_get_text_content (MimeInfo *mimeinfo,
FILE *infp);
FILE *procmime_get_first_text_content (MsgInfo *msginfo);
diff --git a/src/textview.c b/src/textview.c
index a7af0d01..b66d875a 100644
--- a/src/textview.c
+++ b/src/textview.c
@@ -195,7 +195,8 @@ TextView *textview_create(void)
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_SHADOW_IN);
gtk_widget_set_size_request
@@ -541,6 +542,35 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
if (mimeinfo->mime_type != MIME_TEXT &&
mimeinfo->mime_type != MIME_TEXT_HTML) {
gtk_text_buffer_insert(buffer, &iter, buf, -1);
+ if (mimeinfo->mime_type == MIME_IMAGE &&
+ prefs_common.inline_image) {
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+ gchar *filename;
+
+ filename = procmime_get_tmp_file_name(mimeinfo);
+ if (procmime_get_part_fp(filename, fp, mimeinfo) < 0) {
+ g_warning("Can't get the image file.");
+ g_free(filename);
+ return;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+ g_free(filename);
+ if (error != NULL) {
+ g_warning("%s\n", error->message);
+ g_error_free(error);
+ }
+ if (!pixbuf) {
+ g_warning("Can't load the image.");
+ return;
+ }
+
+ gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf);
+ gtk_text_buffer_insert(buffer, &iter, "\n", 1);
+
+ g_object_unref(G_OBJECT(pixbuf));
+ }
} else {
if (!mimeinfo->main &&
mimeinfo->parent &&