aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-03-28 07:15:51 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-03-28 07:15:51 +0000
commiteb8893ef1a4f97c86f0fa4bacb8695f8d26ccb29 (patch)
treed9cad24a5faf420b73325e6b7eef0df572877b4e /src
parentfaa04e6bd711567a9b2437d7d99593baac90fad6 (diff)
the feature to confirm missing attachments was added.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1968 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/compose.c58
-rw-r--r--src/prefs_common_dialog.c33
2 files changed, 89 insertions, 2 deletions
diff --git a/src/compose.c b/src/compose.c
index 71691daf..86323e4a 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2008 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
@@ -255,6 +255,7 @@ static void compose_select_account (Compose *compose,
static gboolean compose_check_for_valid_recipient
(Compose *compose);
static gboolean compose_check_entries (Compose *compose);
+static gboolean compose_check_attachments (Compose *compose);
static gint compose_send (Compose *compose);
static gint compose_write_to_file (Compose *compose,
@@ -2851,6 +2852,55 @@ static gboolean compose_check_entries(Compose *compose)
return TRUE;
}
+static gboolean compose_check_attachments(Compose *compose)
+{
+ GtkTextView *text = GTK_TEXT_VIEW(compose->text);
+ GtkTextBuffer *buffer;
+ GtkTextIter iter, pos;
+ gchar **strv;
+ gint i;
+ gboolean attach_found = FALSE;
+
+ if (!prefs_common.check_attach)
+ return TRUE;
+ if (!prefs_common.check_attach_str)
+ return TRUE;
+
+ if (compose->use_attach &&
+ gtk_tree_model_iter_n_children
+ (GTK_TREE_MODEL(compose->attach_store), NULL) > 0)
+ return TRUE;
+
+ buffer = gtk_text_view_get_buffer(text);
+ gtk_text_buffer_get_start_iter(buffer, &iter);
+
+ strv = g_strsplit(prefs_common.check_attach_str, ",", -1);
+ for (i = 0; strv[i] != NULL; i++) {
+ g_strstrip(strv[i]);
+ if (strv[i][0] == '\0')
+ continue;
+ if (gtkut_text_buffer_find(buffer, &iter, strv[i], FALSE,
+ &pos)) {
+ attach_found = TRUE;
+ break;
+ }
+ }
+
+ g_strfreev(strv);
+
+ if (attach_found) {
+ AlertValue aval;
+
+ aval = alertpanel(_("Attachment is missing"),
+ _("There is no attachment. Send it without attachments?"),
+ GTK_STOCK_YES, GTK_STOCK_NO, NULL);
+ if (aval != G_ALERTDEFAULT)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void compose_lock(Compose *compose)
{
compose->lock_count++;
@@ -2878,6 +2928,10 @@ static gint compose_send(Compose *compose)
compose_unlock(compose);
return 1;
}
+ if (compose_check_attachments(compose) == FALSE) {
+ compose_unlock(compose);
+ return 1;
+ }
if (!main_window_toggle_online_if_offline(main_window_get())) {
compose_unlock(compose);
@@ -6410,6 +6464,8 @@ static void compose_send_later_cb(gpointer data, guint action,
if (compose_check_entries(compose) == FALSE)
return;
+ if (compose_check_attachments(compose) == FALSE)
+ return;
queue = account_get_special_folder(compose->account, F_QUEUE);
if (!queue) {
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c
index 8c672bd3..46ae1905 100644
--- a/src/prefs_common_dialog.c
+++ b/src/prefs_common_dialog.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2008 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
@@ -81,6 +81,9 @@ static struct Send {
GtkWidget *optmenu_encoding_method;
GtkWidget *optmenu_mime_fencoding_method;
+
+ GtkWidget *checkbtn_check_attach;
+ GtkWidget *entry_check_attach_str;
} p_send;
static struct Compose {
@@ -291,6 +294,10 @@ static PrefsUIData ui_data[] = {
prefs_set_data_from_optmenu, prefs_set_optmenu},
{"mime_filename_encoding_method", &p_send.optmenu_mime_fencoding_method,
prefs_set_data_from_optmenu, prefs_set_optmenu},
+ {"check_attach", &p_send.checkbtn_check_attach,
+ prefs_set_data_from_toggle, prefs_set_toggle},
+ {"check_attach_str", &p_send.entry_check_attach_str,
+ prefs_set_data_from_entry, prefs_set_entry},
/* {"allow_jisx0201_kana", NULL, NULL, NULL}, */
@@ -871,6 +878,9 @@ static void prefs_send_create(void)
GtkWidget *label_encoding_desc;
GtkWidget *label_fencoding;
GtkWidget *label_fencoding_desc;
+ GtkWidget *label;
+ GtkWidget *checkbtn_check_attach;
+ GtkWidget *entry_check_attach_str;
vbox1 = gtk_vbox_new (FALSE, VSPACING);
gtk_widget_show (vbox1);
@@ -947,11 +957,32 @@ static void prefs_send_create(void)
"MIME header: most popular, but violates RFC 2047\n"
"RFC 2231: conforms to standard, but not popular"));
+ PACK_CHECK_BUTTON (vbox1, checkbtn_check_attach,
+ _("Confirm attachments when the following strings (comma-separated) are found in the message body"));
+ gtk_label_set_line_wrap(GTK_LABEL(GTK_BIN(checkbtn_check_attach)->child), TRUE);
+
+ hbox1 = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox1);
+ gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
+
+ entry_check_attach_str = gtk_entry_new ();
+ gtk_widget_show (entry_check_attach_str);
+ gtk_box_pack_start (GTK_BOX (hbox1), entry_check_attach_str,
+ TRUE, TRUE, 0);
+ label = gtk_label_new (_("(Ex: attach)"));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
+
+ SET_TOGGLE_SENSITIVITY(checkbtn_check_attach, entry_check_attach_str);
+
p_send.checkbtn_savemsg = checkbtn_savemsg;
p_send.checkbtn_filter_sent = checkbtn_filter_sent;
p_send.optmenu_encoding_method = optmenu_trencoding;
p_send.optmenu_mime_fencoding_method = optmenu_fencoding;
+
+ p_send.checkbtn_check_attach = checkbtn_check_attach;
+ p_send.entry_check_attach_str = entry_check_attach_str;
}
static void prefs_compose_create(void)