/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2008 Hiroyuki Yamamoto and the Claws Mail team
*
* 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
static void compose_insert_sig (Compose *compose,
gboolean replace);
-static gchar *compose_get_signature_str (Compose *compose);
static ComposeInsertResult compose_insert_file (Compose *compose,
const gchar *file);
static void compose_remove_header_entries(Compose *compose);
static void compose_update_priority_menu_item(Compose * compose);
-#if USE_ASPELL
+#if USE_ENCHANT
static void compose_spell_menu_changed (void *data);
#endif
static void compose_add_field_list ( Compose *compose,
}
-#if USE_ASPELL
+#if USE_ENCHANT
static void compose_check_all (GtkAction *action, gpointer data);
static void compose_highlight_all (GtkAction *action, gpointer data);
static void compose_check_backwards (GtkAction *action, gpointer data);
static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
FolderItem *folder_item);
#endif
/* menus */
{"Message", NULL, N_("_Message") },
{"Edit", NULL, N_("_Edit") },
-#if USE_ASPELL
+#if USE_ENCHANT
{"Spelling", NULL, N_("_Spelling") },
#endif
{"Options", NULL, N_("_Options") },
{"Edit/WrapAllLines", NULL, N_("Wrap all long _lines"), "<control><alt>L", NULL, G_CALLBACK(compose_wrap_all_cb) }, /* 1 */
/* {"Edit/---", NULL, "---" }, */
{"Edit/ExtEditor", NULL, N_("Edit with e_xternal editor"), "<shift><control>X", NULL, G_CALLBACK(compose_ext_editor_cb) },
-#if USE_ASPELL
+#if USE_ENCHANT
/* Spelling menu */
{"Spelling/CheckAllSel", NULL, N_("_Check all or check selection"), NULL, NULL, G_CALLBACK(compose_check_all) },
{"Spelling/HighlightAll", NULL, N_("_Highlight all misspelled words"), NULL, NULL, G_CALLBACK(compose_highlight_all) },
static GtkToggleActionEntry compose_toggle_entries[] =
{
{"Edit/AutoWrap", NULL, N_("Aut_o wrapping"), "<shift><control>L", NULL, G_CALLBACK(compose_toggle_autowrap_cb) }, /* TOGGLE */
- {"Edit/AutoIndent", NULL, N_("Follow _indentation"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_cb) }, /* TOGGLE */
+ {"Edit/AutoIndent", NULL, N_("Auto _indent"), NULL, NULL, G_CALLBACK(compose_toggle_autoindent_cb) }, /* TOGGLE */
{"Options/Sign", NULL, N_("Si_gn"), NULL, NULL, G_CALLBACK(compose_toggle_sign_cb) }, /* Toggle */
{"Options/Encrypt", NULL, N_("_Encrypt"), NULL, NULL, G_CALLBACK(compose_toggle_encrypt_cb) }, /* Toggle */
{"Options/RequestRetRcpt", NULL, N_("_Request Return Receipt"), NULL, NULL, G_CALLBACK(compose_toggle_return_receipt_cb) }, /* TOGGLE */
static GtkRadioActionEntry compose_radio_enc_entries[] =
{
- ENC_ACTION(CS_AUTO, C_AUTO, "_Automatic"), /* RADIO compose_set_encoding_cb */
- ENC_ACTION(CS_US_ASCII, C_US_ASCII, "7bit ASCII (US-ASC_II)"), /* RADIO compose_set_encoding_cb */
- ENC_ACTION(CS_UTF_8, C_UTF_8, "Unicode (_UTF-8)"), /* RADIO compose_set_encoding_cb */
+ ENC_ACTION(CS_AUTO, C_AUTO, N_("_Automatic")), /* RADIO compose_set_encoding_cb */
+ ENC_ACTION(CS_US_ASCII, C_US_ASCII, N_("7bit ASCII (US-ASC_II)")), /* RADIO compose_set_encoding_cb */
+ ENC_ACTION(CS_UTF_8, C_UTF_8, N_("Unicode (_UTF-8)")), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Western/"CS_ISO_8859_1, C_ISO_8859_1, "ISO-8859-_1"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Western/"CS_ISO_8859_15, C_ISO_8859_15, "ISO-8859-15"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Western/"CS_WINDOWS_1252, C_WINDOWS_1252, "Windows-1252"), /* RADIO compose_set_encoding_cb */
- ENC_ACTION(CS_ISO_8859_2, C_ISO_8859_2, "Central European (ISO-8859-_2)"), /* RADIO compose_set_encoding_cb */
+ ENC_ACTION(CS_ISO_8859_2, C_ISO_8859_2, N_("Central European (ISO-8859-_2)")), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Baltic/"CS_ISO_8859_13, C_ISO_8859_13, "ISO-8859-13"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Baltic/"CS_ISO_8859_4, C_ISO_8859_14, "ISO-8859-_4"), /* RADIO compose_set_encoding_cb */
- ENC_ACTION(CS_ISO_8859_7, C_ISO_8859_7, "Greek (ISO-8859-_7)"), /* RADIO compose_set_encoding_cb */
+ ENC_ACTION(CS_ISO_8859_7, C_ISO_8859_7, N_("Greek (ISO-8859-_7)")), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Hebrew/"CS_ISO_8859_8, C_ISO_8859_8, "ISO-8859-_8"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Hebrew/"CS_WINDOWS_1255, C_WINDOWS_1255, "Windows-1255"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Arabic/"CS_ISO_8859_6, C_ISO_8859_6, "ISO-8859-_6"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Arabic/"CS_WINDOWS_1256, C_WINDOWS_1256, "Windows-1256"), /* RADIO compose_set_encoding_cb */
- ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, "Turkish (ISO-8859-_9)"), /* RADIO compose_set_encoding_cb */
+ ENC_ACTION(CS_ISO_8859_9, C_ISO_8859_9, N_("Turkish (ISO-8859-_9)")), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Cyrillic/"CS_ISO_8859_5, C_ISO_8859_5, "ISO-8859-_5"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Cyrillic/"CS_KOI8_R, C_KOI8_R, "KOI8-_R"), /* RADIO compose_set_encoding_cb */
ENC_ACTION("Cyrillic/"CS_KOI8_U, C_KOI8_U, "KOI8-_U"), /* RADIO compose_set_encoding_cb */
tmp = malloc(strlen(item->prefs->compose_override_from_format)+1);
pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
compose_create_tags(textview, compose);
undo_block(compose->undostruct);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
compose_set_dictionaries_from_folder_prefs(compose, item);
#endif
pref_get_unescaped_pref(tmp, subject_format);
subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
tmp = malloc(strlen(msginfo->folder->prefs->reply_override_from_format)+1);
pref_get_unescaped_pref(tmp, msginfo->folder->prefs->reply_override_from_format);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
compose_create_tags(textview, compose);
undo_block(compose->undostruct);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
compose_set_dictionaries_from_folder_prefs(compose, msginfo->folder);
#endif
compose_force_encryption(compose, account, FALSE);
}
+ privacy_msginfo_get_signed_state(compose->replyinfo);
+ if (MSG_IS_SIGNED(compose->replyinfo->flags) && account->default_sign_reply) {
+ compose_force_signing(compose, account);
+ }
+
SIGNAL_BLOCK(textbuf);
if (account->auto_sig)
tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
return NULL;
}
- compose->sig_str = compose_get_signature_str(compose);
+ compose->sig_str = account_get_signature_str(compose->account);
return compose;
}
case A_ADDRBOOK:
compose_address_cb(NULL, compose);
break;
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
case A_CHECK_SPELLING:
compose_check_all(NULL, compose);
break;
}
if (qmark != NULL) {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
while (*trimmed_body == '\n')
trimmed_body++;
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
}
g_free(compose->sig_str);
- compose->sig_str = compose_get_signature_str(compose);
+ compose->sig_str = account_get_signature_str(compose->account);
cur_pos = gtk_text_iter_get_offset(&iter);
else
gtk_text_buffer_get_iter_at_offset(buffer, &iter,
compose->set_cursor_pos);
-
+
+ compose->set_cursor_pos = -1;
gtk_text_buffer_place_cursor(buffer, &iter);
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
G_CALLBACK(compose_changed_cb),
UNBLOCK_WRAP();
}
-static gchar *compose_get_signature_str(Compose *compose)
-{
- gchar *sig_body = NULL;
- gchar *sig_str = NULL;
- gchar *utf8_sig_str = NULL;
-
- g_return_val_if_fail(compose->account != NULL, NULL);
-
- if (!compose->account->sig_path)
- return NULL;
-
- if (compose->account->sig_type == SIG_FILE) {
- if (!is_file_or_fifo_exist(compose->account->sig_path)) {
- g_warning("can't open signature file: %s\n",
- compose->account->sig_path);
- return NULL;
- }
- }
-
- if (compose->account->sig_type == SIG_COMMAND)
- sig_body = get_command_output(compose->account->sig_path);
- else {
- gchar *tmp;
-
- tmp = file_read_to_str(compose->account->sig_path);
- if (!tmp)
- return NULL;
- sig_body = normalize_newlines(tmp);
- g_free(tmp);
- }
-
- if (compose->account->sig_sep) {
- sig_str = g_strconcat("\n", compose->account->sig_sep, "\n", sig_body,
- NULL);
- g_free(sig_body);
- } else
- sig_str = g_strconcat("\n", sig_body, NULL);
-
- if (sig_str) {
- if (g_utf8_validate(sig_str, -1, NULL) == TRUE)
- utf8_sig_str = sig_str;
- else {
- utf8_sig_str = conv_codeset_strdup
- (sig_str, conv_get_locale_charset_str_no_utf8(),
- CS_INTERNAL);
- g_free(sig_str);
- }
- }
-
- return utf8_sig_str;
-}
-
static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *file)
{
GtkTextView *text;
undo_unblock(compose->undostruct);
}
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
/* use account's dict info if set */
if (compose->gtkaspell) {
if (account->enable_default_dictionary)
mimepart->tmp = FALSE; /* or we destroy our attachment */
mimepart->offset = 0;
- stat(ainfo->file, &statbuf);
+ g_stat(ainfo->file, &statbuf);
mimepart->length = statbuf.st_size;
type = g_strdup(ainfo->content_type);
{
gint prev_autowrap;
GtkTextBuffer *buffer = GTK_TEXT_VIEW(text)->buffer;
-#if USE_ASPELL
+#if USE_ENCHANT
if (event->button == 3) {
GtkTextIter iter;
GtkTextIter sel_start, sel_end;
return FALSE;
}
-#if USE_ASPELL
+#if USE_ENCHANT
static void compose_spell_menu_changed(void *data)
{
Compose *compose = (Compose *)data;
GtkWidget *tmpl_menu;
GtkActionGroup *action_group = NULL;
-#if USE_ASPELL
+#if USE_ENCHANT
GtkAspell * gtkaspell = NULL;
#endif
#ifndef MAEMO
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_MENUBAR)
#else
- MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_MENU)
+ MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/", "Menu", NULL, GTK_UI_MANAGER_POPUP)
#endif
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Message", "Message", GTK_UI_MANAGER_MENU)
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU)
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Spelling", "Spelling", GTK_UI_MANAGER_MENU)
#endif
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu", "Options", "Options", GTK_UI_MANAGER_MENU)
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Edit", "ExtEditor", "Edit/ExtEditor", GTK_UI_MANAGER_MENUITEM)
-#if USE_ASPELL
+#if USE_ENCHANT
/* Spelling menu */
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "CheckAllSel", "Spelling/CheckAllSel", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(compose->ui_manager, "/Menu/Spelling", "HighlightAll", "Spelling/HighlightAll", GTK_UI_MANAGER_MENUITEM)
compose->exteditor_tag = -1;
compose->draft_timeout_tag = -2; /* inhibit auto-drafting while loading */
-#if USE_ASPELL
+#if USE_ENCHANT
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE);
if (mode != COMPOSE_REDIRECT) {
if (prefs_common.enable_aspell && prefs_common.dictionary &&
strcmp(prefs_common.dictionary, "")) {
- gtkaspell = gtkaspell_new(prefs_common.aspell_path,
- prefs_common.dictionary,
+ gtkaspell = gtkaspell_new(prefs_common.dictionary,
prefs_common.alt_dictionary,
conv_get_locale_charset_str(),
prefs_common.misspelled_col,
gtkaspell_checkers_strerror());
gtkaspell_checkers_reset_error();
} else {
- if (!gtkaspell_set_sug_mode(gtkaspell,
- prefs_common.aspell_sugmode)) {
- debug_print("Aspell: could not set "
- "suggestion mode %s\n",
- gtkaspell_checkers_strerror());
- gtkaspell_checkers_reset_error();
- }
-
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", TRUE);
}
}
}
if (tmpl->from && *tmpl->from != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
}
if (tmpl->to && *tmpl->to != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
}
if (tmpl->cc && *tmpl->cc != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
}
if (tmpl->bcc && *tmpl->bcc != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
/* process the subject */
if (tmpl->subject && *tmpl->subject != '\0') {
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
if (addressbook_get_target_compose() == compose)
addressbook_set_target_compose(NULL);
-#if USE_ASPELL
+#if USE_ENCHANT
if (compose->gtkaspell) {
gtkaspell_delete(compose->gtkaspell);
compose->gtkaspell = NULL;
}
#endif
- prefs_common.compose_width = compose->scrolledwin->allocation.width;
- prefs_common.compose_height = compose->window->allocation.height;
+ if (!compose->batch) {
+ prefs_common.compose_width = compose->scrolledwin->allocation.width;
+ prefs_common.compose_height = compose->window->allocation.height;
+ }
if (!gtk_widget_get_parent(compose->paned))
gtk_widget_destroy(compose->paned);
compose_set_ext_editor_sensitive(compose, FALSE);
+#ifndef G_OS_WIN32
compose->exteditor_ch = g_io_channel_unix_new(pipe_fds[0]);
+#else
+ compose->exteditor_ch = g_io_channel_win32_new_fd(pipe_fds[0]);
+#endif
compose->exteditor_tag = g_io_add_watch(compose->exteditor_ch,
G_IO_IN,
compose_input_cb,
gtk_text_buffer_set_text(buffer, "", -1);
compose_insert_file(compose, compose->exteditor_file);
compose_changed_cb(NULL, compose);
+ compose_draft((gpointer)compose, COMPOSE_AUTO_SAVE);
if (claws_unlink(compose->exteditor_file) < 0)
FILE_OP_ERROR(compose->exteditor_file, "unlink");
toolbar_comp_set_sensitive(compose, allow);
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Message", allow);
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Edit", allow);
-#if USE_ASPELL
+#if USE_ENCHANT
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", allow);
#endif
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options", allow);
{
gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DRAFTED_AT_EXIT, NULL);
- FILE *fp = fopen(filepath, "ab");
+ FILE *fp = g_fopen(filepath, "ab");
if (fp) {
fprintf(fp, "%s\t%d\n", folder_item_get_identifier(info->folder),
{
gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DRAFTED_AT_EXIT, NULL);
- FILE *fp = fopen(filepath, "rb");
+ FILE *fp = g_fopen(filepath, "rb");
gchar buf[1024];
if (fp) {
Compose *compose = (Compose *)data;
gtkut_widget_get_uposition(widget, &x, &y);
- prefs_common.compose_x = x;
- prefs_common.compose_y = y;
-
+ if (!compose->batch) {
+ prefs_common.compose_x = x;
+ prefs_common.compose_y = y;
+ }
if (compose->sending || compose->updating)
return TRUE;
compose_close_cb(NULL, compose);
#endif
if (compose->modified) {
+ gboolean reedit = (compose->rmode == COMPOSE_REEDIT);
if (!g_mutex_trylock(compose->mutex)) {
/* we don't want to lock the mutex once it's available,
* because as the only other part of compose.c locking
debug_print("couldn't lock mutex, probably sending\n");
return;
}
- val = alertpanel(_("Discard message"),
+ if (!reedit) {
+ val = alertpanel(_("Discard message"),
_("This message has been modified. Discard it?"),
_("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL);
+ } else {
+ val = alertpanel(_("Save changes"),
+ _("This message has been modified. Save the latest changes?"),
+ _("_Don't save"), _("+_Save to Drafts"), GTK_STOCK_CANCEL);
+ }
g_mutex_unlock(compose->mutex);
switch (val) {
case G_ALERTDEFAULT:
- if (prefs_common.autosave)
+ if (prefs_common.autosave && !reedit)
compose_remove_draft(compose);
break;
case G_ALERTALTERNATE:
return FALSE;
}
-#if USE_ASPELL
+#if USE_ENCHANT
static void compose_check_all(GtkAction *action, gpointer data)
{
Compose *compose = (Compose *)data;
}
g_return_val_if_fail(compose, FALSE);
gtkut_widget_get_uposition(compose->window, &x, &y);
- prefs_common.compose_x = x;
- prefs_common.compose_y = y;
+ if (!compose->batch) {
+ prefs_common.compose_x = x;
+ prefs_common.compose_y = y;
+ }
g_mutex_unlock(compose->mutex);
compose_destroy(compose);
return FALSE;
GSList *new_msglist = NULL;
MsgInfo *tmp_msginfo = NULL;
gboolean originally_enc = FALSE;
+ gboolean originally_sig = FALSE;
Compose *compose = NULL;
g_return_if_fail(msgview != NULL);
new_msglist = g_slist_append(NULL, tmp_msginfo);
originally_enc = MSG_IS_ENCRYPTED(orig_msginfo->flags);
+ privacy_msginfo_get_signed_state(orig_msginfo);
+ originally_sig = MSG_IS_SIGNED(orig_msginfo->flags);
+
tmp_msginfo->folder = orig_msginfo->folder;
tmp_msginfo->msgnum = orig_msginfo->msgnum;
if (orig_msginfo->tags)
compose_force_encryption(compose, compose->account, FALSE);
}
+ if (compose && originally_sig && compose->account->default_sign_reply) {
+ compose_force_signing(compose, compose->account);
+ }
+
g_free(body);
}
return newmsginfo;
}
-#ifdef USE_ASPELL
+#ifdef USE_ENCHANT
/* update compose's dictionaries from folder dict settings */
static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
FolderItem *folder_item)