*
* 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
#include "combobox.h"
#include "hooks.h"
#include "privacy.h"
+#include "timing.h"
enum
{
static void compose_attach_parts (Compose *compose,
MsgInfo *msginfo);
-static void compose_beautify_paragraph (Compose *compose,
+static gboolean compose_beautify_paragraph (Compose *compose,
GtkTextIter *par_iter,
gboolean force);
static void compose_wrap_all (Compose *compose);
ENC_ACTION(C_UTF_8)},
{N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Western European (ISO-8859-_1)"),
+ {N_("/_Options/Character _encoding/Western European"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Western European/ISO-8859-_1"),
ENC_ACTION(C_ISO_8859_1)},
- {N_("/_Options/Character _encoding/Western European (ISO-8859-15)"),
+ {N_("/_Options/Character _encoding/Western European/ISO-8859-15"),
ENC_ACTION(C_ISO_8859_15)},
- {N_("/_Options/Character _encoding/Western European (Windows-1252)"),
+ {N_("/_Options/Character _encoding/Western European/Windows-1252"),
ENC_ACTION(C_WINDOWS_1252)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Character _encoding/Central European (ISO-8859-_2)"),
ENC_ACTION(C_ISO_8859_2)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/_Baltic (ISO-8859-13)"),
+ {N_("/_Options/Character _encoding/Baltic"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Baltic/ISO-8859-13"),
ENC_ACTION(C_ISO_8859_13)},
- {N_("/_Options/Character _encoding/Baltic (ISO-8859-_4)"),
+ {N_("/_Options/Character _encoding/Baltic/ISO-8859-_4"),
ENC_ACTION(C_ISO_8859_4)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Character _encoding/Greek (ISO-8859-_7)"),
ENC_ACTION(C_ISO_8859_7)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Hebrew (ISO-8859-_8)"),
+ {N_("/_Options/Character _encoding/Hebrew"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Hebrew/ISO-8859-_8"),
ENC_ACTION(C_ISO_8859_8)},
- {N_("/_Options/Character _encoding/Hebrew (Windows-1255)"),
+ {N_("/_Options/Character _encoding/Hebrew/Windows-1255"),
ENC_ACTION(C_WINDOWS_1255)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Arabic (ISO-8859-_6)"),
+ {N_("/_Options/Character _encoding/Arabic"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Arabic/ISO-8859-_6"),
ENC_ACTION(C_ISO_8859_6)},
- {N_("/_Options/Character _encoding/Arabic (Windows-1256)"),
+ {N_("/_Options/Character _encoding/Arabic/Windows-1256"),
ENC_ACTION(C_CP1256)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Options/Character _encoding/Turkish (ISO-8859-_9)"),
ENC_ACTION(C_ISO_8859_9)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Cyrillic (ISO-8859-_5)"),
+ {N_("/_Options/Character _encoding/Cyrillic"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Cyrillic/ISO-8859-_5"),
ENC_ACTION(C_ISO_8859_5)},
- {N_("/_Options/Character _encoding/Cyrillic (KOI8-_R)"),
+ {N_("/_Options/Character _encoding/Cyrillic/KOI8-_R"),
ENC_ACTION(C_KOI8_R)},
- {N_("/_Options/Character _encoding/Cyrillic (KOI8-U)"),
+ {N_("/_Options/Character _encoding/Cyrillic/KOI8-U"),
ENC_ACTION(C_KOI8_U)},
- {N_("/_Options/Character _encoding/Cyrillic (Windows-1251)"),
+ {N_("/_Options/Character _encoding/Cyrillic/Windows-1251"),
ENC_ACTION(C_WINDOWS_1251)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Japanese (ISO-2022-_JP)"),
+ {N_("/_Options/Character _encoding/Japanese"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Japanese/ISO-2022-_JP"),
ENC_ACTION(C_ISO_2022_JP)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
-
- {N_("/_Options/Character _encoding/Simplified Chinese (_GB2312)"),
+ {N_("/_Options/Character _encoding/Japanese/ISO-2022-JP-2"),
+ ENC_ACTION(C_ISO_2022_JP_2)},
+ {N_("/_Options/Character _encoding/Japanese/_EUC-JP"),
+ ENC_ACTION(C_EUC_JP)},
+ {N_("/_Options/Character _encoding/Japanese/_Shift__JIS"),
+ ENC_ACTION(C_SHIFT_JIS)},
+
+ {N_("/_Options/Character _encoding/Chinese"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Chinese/Simplified (_GB2312)"),
ENC_ACTION(C_GB2312)},
- {N_("/_Options/Character _encoding/Simplified Chinese (GBK)"),
+ {N_("/_Options/Character _encoding/Chinese/Simplified (GBK)"),
ENC_ACTION(C_GBK)},
- {N_("/_Options/Character _encoding/Traditional Chinese (_Big5)"),
+ {N_("/_Options/Character _encoding/Chinese/Traditional (_Big5)"),
ENC_ACTION(C_BIG5)},
- {N_("/_Options/Character _encoding/Traditional Chinese (EUC-_TW)"),
+ {N_("/_Options/Character _encoding/Chinese/Traditional (EUC-_TW)"),
ENC_ACTION(C_EUC_TW)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/Korean (EUC-_KR)"),
+ {N_("/_Options/Character _encoding/Korean"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Korean/EUC-_KR"),
ENC_ACTION(C_EUC_KR)},
- {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
+ {N_("/_Options/Character _encoding/Korean/ISO-2022-KR"),
+ ENC_ACTION(C_ISO_2022_KR)},
- {N_("/_Options/Character _encoding/Thai (TIS-620)"),
+ {N_("/_Options/Character _encoding/Thai"), NULL, NULL, 0, "<Branch>"},
+ {N_("/_Options/Character _encoding/Thai/TIS-620"),
ENC_ACTION(C_TIS_620)},
- {N_("/_Options/Character _encoding/Thai (Windows-874)"),
+ {N_("/_Options/Character _encoding/Thai/Windows-874"),
ENC_ACTION(C_WINDOWS_874)},
{N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
}
if (prefs_common.enable_color && prefs_common.enable_bgcolor) {
- gtk_text_buffer_create_tag(buffer, "quote0",
+ compose->quote0_tag = gtk_text_buffer_create_tag(buffer, "quote0",
"foreground-gdk", "e_color1,
"paragraph-background-gdk", "e_bgcolor1,
NULL);
- gtk_text_buffer_create_tag(buffer, "quote1",
+ compose->quote1_tag = gtk_text_buffer_create_tag(buffer, "quote1",
"foreground-gdk", "e_color2,
"paragraph-background-gdk", "e_bgcolor2,
NULL);
- gtk_text_buffer_create_tag(buffer, "quote2",
+ compose->quote2_tag = gtk_text_buffer_create_tag(buffer, "quote2",
"foreground-gdk", "e_color3,
"paragraph-background-gdk", "e_bgcolor3,
NULL);
} else {
- gtk_text_buffer_create_tag(buffer, "quote0",
+ compose->quote0_tag = gtk_text_buffer_create_tag(buffer, "quote0",
"foreground-gdk", "e_color1,
NULL);
- gtk_text_buffer_create_tag(buffer, "quote1",
+ compose->quote1_tag = gtk_text_buffer_create_tag(buffer, "quote1",
"foreground-gdk", "e_color2,
NULL);
- gtk_text_buffer_create_tag(buffer, "quote2",
+ compose->quote2_tag = gtk_text_buffer_create_tag(buffer, "quote2",
"foreground-gdk", "e_color3,
NULL);
}
- gtk_text_buffer_create_tag(buffer, "signature",
+ compose->signature_tag = gtk_text_buffer_create_tag(buffer, "signature",
"foreground-gdk", &signature_color,
NULL);
- gtk_text_buffer_create_tag(buffer, "link",
+
+ compose->uri_tag = gtk_text_buffer_create_tag(buffer, "link",
"foreground-gdk", &uri_color,
NULL);
compose->no_wrap_tag = gtk_text_buffer_create_tag(buffer, "no_wrap", NULL);
return compose_generic_new( account, NULL, NULL, NULL, listAddress );
}
+#define SCROLL_TO_CURSOR(compose) { \
+ GtkTextMark *cmark = gtk_text_buffer_get_insert( \
+ gtk_text_view_get_buffer( \
+ GTK_TEXT_VIEW(compose->text))); \
+ gtk_text_view_scroll_mark_onscreen( \
+ GTK_TEXT_VIEW(compose->text), \
+ cmark); \
+}
+
Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
GPtrArray *attach_files, GList *listAddress )
{
compose_exec_ext_editor(compose);
compose->draft_timeout_tag = -1;
+ SCROLL_TO_CURSOR(compose);
+
compose->modified = FALSE;
compose_set_title(compose);
return compose;
g_warning("compose_reply_mode(): invalid Compose Mode: %d\n", mode);
}
+ if (compose == NULL) {
+ alertpanel_error(_("Unable to reply. The original email probably doesn't exist."));
+ return NULL;
+ }
ifactory = gtk_item_factory_from_widget(compose->menubar);
compose->rmode = mode;
info = compose->targetinfo;
}
if (info) {
- MimeInfo *mimeinfo = procmime_scan_message(info);
+ MimeInfo *mimeinfo = procmime_scan_message_short(info);
MimeInfo *partinfo = mimeinfo;
while (partinfo && partinfo->type != MIMETYPE_TEXT)
partinfo = procmime_mimeinfo_next(partinfo);
gboolean quote = FALSE;
const gchar *qmark = NULL;
const gchar *body_fmt = NULL;
-
+ START_TIMING("");
g_return_val_if_fail(msginfo != NULL, NULL);
g_return_val_if_fail(msginfo->folder != NULL, NULL);
_("Message reply format error at line %d."));
quote_fmt_reset_vartable();
}
- if (procmime_msginfo_is_encrypted(compose->replyinfo)) {
+
+ if (MSG_IS_ENCRYPTED(compose->replyinfo->flags)) {
compose_force_encryption(compose, account, FALSE);
}
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
-
+ SCROLL_TO_CURSOR(compose);
+
if (compose->deferred_destroy) {
compose_destroy(compose);
return NULL;
}
-
+ END_TIMING();
return compose;
}
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
}
}
+#define BLOCK_WRAP() { \
+ prev_autowrap = compose->autowrap; \
+ buffer = gtk_text_view_get_buffer( \
+ GTK_TEXT_VIEW(compose->text)); \
+ compose->autowrap = FALSE; \
+ \
+ g_signal_handlers_block_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(compose_changed_cb), \
+ compose); \
+ g_signal_handlers_block_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(text_inserted), \
+ compose); \
+}
+#define UNBLOCK_WRAP() { \
+ compose->autowrap = prev_autowrap; \
+ if (compose->autowrap) { \
+ gint old = compose->draft_timeout_tag; \
+ compose->draft_timeout_tag = -2; \
+ compose_wrap_all(compose); \
+ compose->draft_timeout_tag = old; \
+ } \
+ \
+ g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(compose_changed_cb), \
+ compose); \
+ g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(text_inserted), \
+ compose); \
+}
+
Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
{
Compose *compose = NULL;
G_CALLBACK(compose_changed_cb),
compose);
- if (procmime_msginfo_is_encrypted(msginfo)) {
+ if (MSG_IS_ENCRYPTED(msginfo->flags)) {
fp = procmime_get_first_encrypted_text_content(msginfo);
if (fp) {
compose_force_encryption(compose, account, TRUE);
if (fp != NULL) {
gboolean prev_autowrap = compose->autowrap;
-
- compose->autowrap = FALSE;
+ GtkTextBuffer *buffer = textbuf;
+ BLOCK_WRAP();
while (fgets(buf, sizeof(buf), fp) != NULL) {
strcrchomp(buf);
gtk_text_buffer_insert(textbuf, &iter, buf, -1);
}
- compose_wrap_all_full(compose, FALSE);
- compose->autowrap = prev_autowrap;
+ UNBLOCK_WRAP();
fclose(fp);
}
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
compose_set_title(compose);
compose->updating = FALSE;
compose->draft_timeout_tag = -1; /* desinhibit auto-drafting after loading */
+ SCROLL_TO_CURSOR(compose);
if (compose->deferred_destroy) {
compose_destroy(compose);
buf = quote_fmt_get_buffer();
if (buf == NULL) {
gint line = quote_fmt_get_line();
- gchar *msg = g_strdup_printf(err_msg, line);
- alertpanel_error(msg);
- g_free(msg);
+ alertpanel_error(err_msg, line);
goto error;
}
} else
GtkTextMark *mark;
GtkTextIter iter, iter_end;
gint cur_pos;
- gchar *search = NULL;
gboolean prev_autowrap;
- gboolean found = FALSE, shift = FALSE;
-
+ gboolean found = FALSE;
+ gboolean exists = FALSE;
g_return_if_fail(compose->account != NULL);
- prev_autowrap = compose->autowrap;
- compose->autowrap = FALSE;
+ BLOCK_WRAP();
g_signal_handlers_block_by_func(G_OBJECT(buffer),
G_CALLBACK(compose_changed_cb),
gtk_text_buffer_get_end_iter(buffer, &iter);
- search = compose->sig_str;
-again:
- if (replace && search) {
+ exists = (compose->sig_str != NULL);
+
+ if (replace) {
GtkTextIter first_iter, start_iter, end_iter;
gtk_text_buffer_get_start_iter(buffer, &first_iter);
- if (compose->sig_str[0] == '\0')
+ if (!exists || compose->sig_str[0] == '\0')
found = FALSE;
else
- found = gtk_text_iter_forward_search(&first_iter,
- search,
- GTK_TEXT_SEARCH_TEXT_ONLY,
- &start_iter, &end_iter,
- NULL);
+ found = gtk_text_iter_forward_to_tag_toggle(&first_iter,
+ compose->signature_tag);
if (found) {
- gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
- iter = start_iter;
- }
+ /* include previous \n\n */
+ gtk_text_iter_backward_chars(&first_iter, 2);
+ start_iter = first_iter;
+ end_iter = first_iter;
+ /* skip re-start */
+ found = gtk_text_iter_forward_to_tag_toggle(&end_iter,
+ compose->signature_tag);
+ found &= gtk_text_iter_forward_to_tag_toggle(&end_iter,
+ compose->signature_tag);
+ if (found) {
+ gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
+ iter = start_iter;
+ }
+ }
}
- if (replace && !found && search && strlen(search) > 2
- && search[0] == '\n' && search[1] == '\n') {
- search ++;
- shift = TRUE;
- goto again;
- }
g_free(compose->sig_str);
compose->sig_str = compose_get_signature_str(compose);
- if (!compose->sig_str || (replace && !compose->account->auto_sig))
- compose->sig_str = g_strdup("");
cur_pos = gtk_text_iter_get_offset(&iter);
- if (shift && found)
- gtk_text_buffer_insert(buffer, &iter, compose->sig_str + 1, -1);
- else
- gtk_text_buffer_insert(buffer, &iter, compose->sig_str, -1);
- /* skip \n\n */
- gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
- gtk_text_iter_forward_char(&iter);
- gtk_text_iter_forward_char(&iter);
- gtk_text_buffer_get_end_iter(buffer, &iter_end);
- gtk_text_buffer_apply_tag_by_name(buffer,"signature",&iter, &iter_end);
- if (cur_pos > gtk_text_buffer_get_char_count (buffer))
- cur_pos = gtk_text_buffer_get_char_count (buffer);
+ if (!compose->sig_str || (replace && !compose->account->auto_sig)) {
+ g_free(compose->sig_str);
+ compose->sig_str = NULL;
+ } else {
+ gtk_text_buffer_insert(buffer, &iter, compose->sig_str, -1);
+ /* remove \n\n */
+ gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
+ gtk_text_iter_forward_chars(&iter, 2);
+ gtk_text_buffer_get_end_iter(buffer, &iter_end);
+ gtk_text_buffer_apply_tag_by_name(buffer,"signature",&iter, &iter_end);
+ if (cur_pos > gtk_text_buffer_get_char_count (buffer))
+ cur_pos = gtk_text_buffer_get_char_count (buffer);
+ }
/* put the cursor where it should be
* either where the quote_fmt says, either before the signature */
if (compose->set_cursor_pos < 0)
G_CALLBACK(compose_changed_cb),
compose);
- compose->autowrap = prev_autowrap;
- if (compose->autowrap)
- compose_wrap_all(compose);
+ UNBLOCK_WRAP();
}
static gchar *compose_get_signature_str(Compose *compose)
gtk_text_iter_forward_to_line_end(&line_end);
str = gtk_text_buffer_get_text(buffer, &iter, &line_end, FALSE);
len = g_utf8_strlen(str, -1);
+
+ if (len == 0) {
+ g_free(str);
+ g_warning("compose_get_line_break_pos: len = 0!\n");
+ return FALSE;
+ }
+
/* g_print("breaking line: %d: %s (len = %d)\n",
gtk_text_iter_get_line(&iter), str, len); */
+
attrs = g_new(PangoLogAttr, len + 1);
pango_default_break(str, -1, NULL, attrs, len + 1);
g_warning("alloc error scanning URIs\n"); \
}
-static gboolean automatic_break = FALSE;
-static void compose_beautify_paragraph(Compose *compose, GtkTextIter *par_iter, gboolean force)
+static gboolean compose_beautify_paragraph(Compose *compose, GtkTextIter *par_iter, gboolean force)
{
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
GtkTextBuffer *buffer;
gint nouri_start = -1, nouri_stop = -1;
gint num_blocks = 0;
gint quotelevel = -1;
+ gboolean modified = force;
+ gboolean removed = FALSE;
+ gboolean modified_before_remove = FALSE;
+ gint lines = 0;
+ gboolean start = TRUE;
+
+ if (force) {
+ modified = TRUE;
+ }
+ if (compose->draft_timeout_tag == -2) {
+ modified = TRUE;
+ }
compose->autowrap = FALSE;
gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
}
- /* move to paragraph start */
- gtk_text_iter_set_line_offset(&iter, 0);
- if (gtk_text_iter_ends_line(&iter)) {
- while (gtk_text_iter_ends_line(&iter) &&
- gtk_text_iter_forward_line(&iter))
- ;
- } else {
- while (gtk_text_iter_backward_line(&iter)) {
- if (gtk_text_iter_ends_line(&iter)) {
- gtk_text_iter_forward_line(&iter);
- break;
+
+ if (compose->draft_timeout_tag == -2) {
+ if (gtk_text_iter_ends_line(&iter)) {
+ while (gtk_text_iter_ends_line(&iter) &&
+ gtk_text_iter_forward_line(&iter))
+ ;
+ } else {
+ while (gtk_text_iter_backward_line(&iter)) {
+ if (gtk_text_iter_ends_line(&iter)) {
+ gtk_text_iter_forward_line(&iter);
+ break;
+ }
}
}
+ } else {
+ /* move to line start */
+ gtk_text_iter_set_line_offset(&iter, 0);
}
-
/* go until paragraph end (empty line) */
-
- while (!gtk_text_iter_ends_line(&iter)) {
+ while (start || !gtk_text_iter_ends_line(&iter)) {
gchar *scanpos = NULL;
/* parse table - in order of priority */
struct table {
gchar *o_walk = NULL, *walk = NULL, *bp = NULL, *ep = NULL;
gint walk_pos;
+ start = FALSE;
if (!prev_autowrap && num_blocks == 0) {
num_blocks++;
g_signal_handlers_block_by_func(G_OBJECT(buffer),
if (prev_autowrap == FALSE && !force && !wrap_quote) {
goto colorize;
}
- if (compose_get_line_break_pos(buffer, &iter, &break_pos,
+ if (gtk_text_iter_ends_line(&iter)) {
+ goto colorize;
+ } else if (compose_get_line_break_pos(buffer, &iter, &break_pos,
prefs_common.linewrap_len,
quote_len)) {
GtkTextIter prev, next, cur;
-
+
if (prev_autowrap != FALSE || force) {
- automatic_break = TRUE;
+ compose->automatic_break = TRUE;
+ modified = TRUE;
gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
- automatic_break = FALSE;
+ compose->automatic_break = FALSE;
} else if (quote_str && wrap_quote) {
- automatic_break = TRUE;
+ compose->automatic_break = TRUE;
+ modified = TRUE;
gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
- automatic_break = FALSE;
+ compose->automatic_break = FALSE;
} else
goto colorize;
/* remove trailing spaces */
quote_str, -1);
iter = break_pos;
- compose_join_next_line(compose, buffer, &iter, quote_str);
+ modified |= compose_join_next_line(compose, buffer, &iter, quote_str);
/* move iter to current line start */
gtk_text_iter_set_line_offset(&iter, 0);
g_free(quote_str);
quote_str = NULL;
}
- continue;
+ continue;
} else {
/* move iter to next line start */
iter = break_pos;
+ lines++;
}
colorize:
endquote = iter;
switch (quotelevel) {
- case 0: gtk_text_buffer_apply_tag_by_name(
- buffer, "quote0", &startquote, &endquote);
+ case 0:
+ if (!gtk_text_iter_has_tag(&startquote, compose->quote0_tag) ||
+ !gtk_text_iter_has_tag(&end_of_line, compose->quote0_tag)) {
+ gtk_text_buffer_apply_tag_by_name(
+ buffer, "quote0", &startquote, &endquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote1", &startquote, &endquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote2", &startquote, &endquote);
+ modified = TRUE;
+ }
break;
- case 1: gtk_text_buffer_apply_tag_by_name(
- buffer, "quote1", &startquote, &endquote);
+ case 1:
+ if (!gtk_text_iter_has_tag(&startquote, compose->quote1_tag) ||
+ !gtk_text_iter_has_tag(&end_of_line, compose->quote1_tag)) {
+ gtk_text_buffer_apply_tag_by_name(
+ buffer, "quote1", &startquote, &endquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote0", &startquote, &endquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote2", &startquote, &endquote);
+ modified = TRUE;
+ }
break;
- case 2: gtk_text_buffer_apply_tag_by_name(
- buffer, "quote2", &startquote, &endquote);
+ case 2:
+ if (!gtk_text_iter_has_tag(&startquote, compose->quote2_tag) ||
+ !gtk_text_iter_has_tag(&end_of_line, compose->quote2_tag)) {
+ gtk_text_buffer_apply_tag_by_name(
+ buffer, "quote2", &startquote, &endquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote0", &startquote, &endquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote1", &startquote, &endquote);
+ modified = TRUE;
+ }
break;
}
startq_offset = -1;
gtk_text_buffer_get_iter_at_offset(
buffer, &startnoquote, noq_offset);
endnoquote = iter;
- gtk_text_buffer_remove_tag_by_name(
- buffer, "quote0", &startnoquote, &endnoquote);
- gtk_text_buffer_remove_tag_by_name(
- buffer, "quote1", &startnoquote, &endnoquote);
- gtk_text_buffer_remove_tag_by_name(
- buffer, "quote2", &startnoquote, &endnoquote);
+
+ if ((gtk_text_iter_has_tag(&startnoquote, compose->quote0_tag)
+ && gtk_text_iter_has_tag(&end_of_line, compose->quote0_tag)) ||
+ (gtk_text_iter_has_tag(&startnoquote, compose->quote1_tag)
+ && gtk_text_iter_has_tag(&end_of_line, compose->quote1_tag)) ||
+ (gtk_text_iter_has_tag(&startnoquote, compose->quote2_tag)
+ && gtk_text_iter_has_tag(&end_of_line, compose->quote2_tag))) {
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote0", &startnoquote, &endnoquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote1", &startnoquote, &endnoquote);
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "quote2", &startnoquote, &endnoquote);
+ modified = TRUE;
+ }
noq_offset = -1;
}
- /* always */ {
+ if (uri_start != nouri_start && uri_stop != nouri_stop) {
GtkTextIter nouri_start_iter, nouri_end_iter;
gtk_text_buffer_get_iter_at_offset(
buffer, &nouri_start_iter, nouri_start);
gtk_text_buffer_get_iter_at_offset(
buffer, &nouri_end_iter, nouri_stop);
- gtk_text_buffer_remove_tag_by_name(
- buffer, "link", &nouri_start_iter, &nouri_end_iter);
+ if (gtk_text_iter_has_tag(&nouri_start_iter, compose->uri_tag) &&
+ gtk_text_iter_has_tag(&nouri_end_iter, compose->uri_tag)) {
+ gtk_text_buffer_remove_tag_by_name(
+ buffer, "link", &nouri_start_iter, &nouri_end_iter);
+ modified_before_remove = modified;
+ modified = TRUE;
+ removed = TRUE;
+ }
}
if (uri_start > 0 && uri_stop > 0) {
- GtkTextIter uri_start_iter, uri_end_iter;
+ GtkTextIter uri_start_iter, uri_end_iter, back;
gtk_text_buffer_get_iter_at_offset(
buffer, &uri_start_iter, uri_start);
gtk_text_buffer_get_iter_at_offset(
buffer, &uri_end_iter, uri_stop);
- gtk_text_buffer_apply_tag_by_name(
- buffer, "link", &uri_start_iter, &uri_end_iter);
+ back = uri_end_iter;
+ gtk_text_iter_backward_char(&back);
+ if (!gtk_text_iter_has_tag(&uri_start_iter, compose->uri_tag) ||
+ !gtk_text_iter_has_tag(&back, compose->uri_tag)) {
+ gtk_text_buffer_apply_tag_by_name(
+ buffer, "link", &uri_start_iter, &uri_end_iter);
+ modified = TRUE;
+ if (removed && !modified_before_remove) {
+ modified = FALSE;
+ }
+ }
+ }
+ if (!modified) {
+ debug_print("not modified, out after %d lines\n", lines);
+ goto end;
}
}
+ debug_print("modified, out after %d lines\n", lines);
+end:
if (par_iter)
*par_iter = iter;
undo_wrapping(compose->undostruct, FALSE);
compose->autowrap = prev_autowrap;
+
+ return modified;
}
void compose_action_cb(void *data)
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
GtkTextBuffer *buffer;
GtkTextIter iter;
+ gboolean modified = TRUE;
buffer = gtk_text_view_get_buffer(text);
gtk_text_buffer_get_start_iter(buffer, &iter);
- while (!gtk_text_iter_is_end(&iter))
- compose_beautify_paragraph(compose, &iter, force);
+ while (!gtk_text_iter_is_end(&iter) && modified)
+ modified = compose_beautify_paragraph(compose, &iter, force);
}
if (*str == '\0' && check_everything == TRUE &&
compose->mode != COMPOSE_REDIRECT) {
AlertValue aval;
+ gchar *button_label;
+ gchar *message;
- aval = alertpanel(_("Send"),
- _("Subject is empty. Send it anyway?"),
- GTK_STOCK_CANCEL, _("+_Send"), NULL);
+ if (compose->sending)
+ button_label = _("+_Send");
+ else
+ button_label = _("+_Queue");
+ message = g_strdup_printf(_("Subject is empty. %s it anyway?"),
+ compose->sending?_("Send"):_("Queue"));
+
+ aval = alertpanel(compose->sending?_("Send"):_("Send later"), message,
+ GTK_STOCK_CANCEL, button_label, NULL);
+ g_free(message);
if (aval != G_ALERTALTERNATE)
return FALSE;
}
MainWindow *mainwin = mainwindow_get_mainwindow();
gboolean queued_removed = FALSE;
- if (prefs_common.send_dialog_mode != SEND_DIALOG_ALWAYS
+ if (prefs_common.send_dialog_invisible
|| compose->batch == TRUE)
discard_window = TRUE;
}
} else {
if (errstr) {
- gchar *tmp = g_strdup_printf(_("%s\nUse \"Send queued messages\" from "
+ alertpanel_error_log(_("%s\nUse \"Send queued messages\" from "
"the main window to retry."), errstr);
g_free(errstr);
- alertpanel_error_log(tmp);
- g_free(tmp);
} else {
alertpanel_error_log(_("The message was queued but could not be "
"sent.\nUse \"Send queued messages\" from "
}
/* Resent-Message-ID */
- if (compose->account->gen_msgid) {
- generate_msgid(buf, sizeof(buf));
- fprintf(fp, "Resent-Message-ID: <%s>\n", buf);
- compose->msgid = g_strdup(buf);
+ if (compose->account->set_domain && compose->account->domain) {
+ g_snprintf(buf, sizeof(buf), "%s", compose->account->domain);
+ } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
+ g_snprintf(buf, sizeof(buf), "%s",
+ strchr(compose->account->address, '@') ?
+ strchr(compose->account->address, '@')+1 :
+ compose->account->address);
+ } else {
+ g_snprintf(buf, sizeof(buf), "%s", "");
}
+ generate_msgid(buf, sizeof(buf));
+ fprintf(fp, "Resent-Message-ID: <%s>\n", buf);
+ compose->msgid = g_strdup(buf);
compose_redirect_write_headers_from_headerlist(compose, fp);
if (folder_item_remove_msg(item, msginfo->msgnum) < 0) {
g_warning("can't remove the old message\n");
return -1;
+ } else {
+ debug_print("removed reedit target %d\n", msginfo->msgnum);
}
}
g_free(str);
/* Message-ID */
- if (compose->account->gen_msgid) {
- generate_msgid(buf, sizeof(buf));
- g_string_append_printf(header, "Message-ID: <%s>\n", buf);
- compose->msgid = g_strdup(buf);
+ if (compose->account->set_domain && compose->account->domain) {
+ g_snprintf(buf, sizeof(buf), "%s", compose->account->domain);
+ } else if (!strncmp(get_domain_name(), "localhost", strlen("localhost"))) {
+ g_snprintf(buf, sizeof(buf), "%s",
+ strchr(compose->account->address, '@') ?
+ strchr(compose->account->address, '@')+1 :
+ compose->account->address);
+ } else {
+ g_snprintf(buf, sizeof(buf), "%s", "");
}
+ generate_msgid(buf, sizeof(buf));
+ g_string_append_printf(header, "Message-ID: <%s>\n", buf);
+ compose->msgid = g_strdup(buf);
if (compose->remove_references == FALSE) {
/* In-Reply-To */
static void entry_paste_clipboard(Compose *compose, GtkWidget *entry, gboolean wrap,
GdkAtom clip, GtkTextIter *insert_place);
-#define BLOCK_WRAP() { \
- prev_autowrap = compose->autowrap; \
- buffer = gtk_text_view_get_buffer( \
- GTK_TEXT_VIEW(compose->text)); \
- compose->autowrap = FALSE; \
- \
- g_signal_handlers_block_by_func(G_OBJECT(buffer), \
- G_CALLBACK(compose_changed_cb), \
- compose); \
- g_signal_handlers_block_by_func(G_OBJECT(buffer), \
- G_CALLBACK(text_inserted), \
- compose); \
-}
-#define UNBLOCK_WRAP() { \
- compose->autowrap = prev_autowrap; \
- if (compose->autowrap) \
- compose_wrap_all(compose); \
- \
- g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
- G_CALLBACK(compose_changed_cb), \
- compose); \
- g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
- G_CALLBACK(text_inserted), \
- compose); \
-}
-
static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
Compose *compose)
gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
gtk_widget_realize(handlebox);
+#ifdef MAEMO
+ compose->toolbar = toolbar_create(TOOLBAR_COMPOSE, window,
+ (gpointer)compose);
+#else
compose->toolbar = toolbar_create(TOOLBAR_COMPOSE, handlebox,
(gpointer)compose);
+#endif
vbox2 = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
if (warn && !found && strlen(compose->privacy_system)) {
- gchar *tmp = g_strdup_printf(
- _("The privacy system '%s' cannot be loaded. You "
+ alertpanel_warning(_("The privacy system '%s' cannot be loaded. You "
"will not be able to sign or encrypt this message."),
compose->privacy_system);
- alertpanel_warning(tmp);
- g_free(tmp);
}
}
folder_item_scan(draft);
if ((msgnum = folder_item_add_msg(draft, tmp, &flag, TRUE)) < 0) {
+ MsgInfo *tmpinfo = NULL;
+ debug_print("didn't get msgnum after adding draft [%s]\n", compose->msgid?compose->msgid:"no msgid");
+ if (compose->msgid) {
+ tmpinfo = folder_item_get_msginfo_by_msgid(draft, compose->msgid);
+ }
+ if (tmpinfo) {
+ msgnum = tmpinfo->msgnum;
+ procmsg_msginfo_free(tmpinfo);
+ debug_print("got draft msgnum %d from scanning\n", msgnum);
+ } else {
+ debug_print("didn't get draft msgnum after scanning\n");
+ }
+ } else {
+ debug_print("got draft msgnum %d from adding\n", msgnum);
+ }
+ if (msgnum < 0) {
g_unlink(tmp);
g_free(tmp);
if (action != COMPOSE_AUTO_SAVE) {
}
newmsginfo = folder_item_get_msginfo(draft, msgnum);
+
if (newmsginfo) {
procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
if (target_locked)
path = folder_item_fetch_msg(draft, msgnum);
if (path == NULL) {
- debug_print("can't fetch %s:%d\n",draft->path, msgnum);
+ debug_print("can't fetch %s:%d\n", draft->path, msgnum);
goto unlock;
}
if (g_stat(path, &s) < 0) {
vadj = gtk_viewport_get_vadjustment(GTK_VIEWPORT(compose->header_table->parent));
gtk_adjustment_set_value(vadj, (show_first ? vadj->lower : vadj->upper));
+ gtk_adjustment_changed(vadj);
}
static void text_inserted(GtkTextBuffer *buffer, GtkTextIter *iter,
if (paste_as_quotation) {
gchar *new_text;
const gchar *qmark;
+ guint pos = 0;
+ GtkTextIter start_iter;
if (len < 0)
len = strlen(text);
mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
gtk_text_buffer_place_cursor(buffer, iter);
+ pos = gtk_text_iter_get_offset(iter);
+
compose_quote_fmt(compose, NULL, "%Q", qmark, new_text, TRUE, FALSE,
_("Quote format error at line %d."));
quote_fmt_reset_vartable();
gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
gtk_text_buffer_place_cursor(buffer, iter);
+ gtk_text_buffer_delete_mark(buffer, mark);
+
+ gtk_text_buffer_get_iter_at_offset(buffer, &start_iter, pos);
+ mark = gtk_text_buffer_create_mark(buffer, NULL, &start_iter, FALSE);
+ compose_beautify_paragraph(compose, &start_iter, FALSE);
+ gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark);
+ gtk_text_buffer_delete_mark(buffer, mark);
} else {
- if (strcmp(text, "\n") || automatic_break
+ if (strcmp(text, "\n") || compose->automatic_break
|| gtk_text_iter_starts_line(iter))
gtk_text_buffer_insert(buffer, iter, text, len);
else {
}
}
- mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
-
- compose_beautify_paragraph(compose, iter, FALSE);
-
- gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
- gtk_text_buffer_delete_mark(buffer, mark);
+ if (!paste_as_quotation) {
+ mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
+ compose_beautify_paragraph(compose, iter, FALSE);
+ gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
+ gtk_text_buffer_delete_mark(buffer, mark);
+ }
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(text_inserted),
orig_msginfo, mimeinfo);
if (tmp_msginfo != NULL) {
new_msglist = g_slist_append(NULL, tmp_msginfo);
- if (procmime_msginfo_is_encrypted(orig_msginfo)) {
- originally_enc = TRUE;
- }
+
+ originally_enc = MSG_IS_ENCRYPTED(orig_msginfo->flags);
tmp_msginfo->folder = orig_msginfo->folder;
tmp_msginfo->msgnum = orig_msginfo->msgnum;
if (orig_msginfo->tags)
} else
compose = compose_reply_mode((ComposeMode)action, msginfo_list, body);
- if (originally_enc) {
+ if (compose && originally_enc) {
compose_force_encryption(compose, compose->account, FALSE);
}