diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2008-03-28 07:15:51 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2008-03-28 07:15:51 +0000 |
commit | eb8893ef1a4f97c86f0fa4bacb8695f8d26ccb29 (patch) | |
tree | d9cad24a5faf420b73325e6b7eef0df572877b4e /src/compose.c | |
parent | faa04e6bd711567a9b2437d7d99593baac90fad6 (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/compose.c')
-rw-r--r-- | src/compose.c | 58 |
1 files changed, 57 insertions, 1 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) { |