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>"},
NULL);
}
- gtk_text_buffer_create_tag(buffer, "signature",
+ compose->signature_tag = gtk_text_buffer_create_tag(buffer, "signature",
"foreground-gdk", &signature_color,
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;
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;
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);
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);
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)
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);
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 (*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 */
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 && compose->msgid) {
- newmsginfo = folder_item_get_msginfo_by_msgid(draft, compose->msgid);
- if (newmsginfo)
- msgnum = newmsginfo->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") || compose->automatic_break
|| gtk_text_iter_starts_line(iter))
}
}
- 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),
} else
compose = compose_reply_mode((ComposeMode)action, msginfo_list, body);
- if (originally_enc) {
+ if (compose && originally_enc) {
compose_force_encryption(compose, compose->account, FALSE);
}