COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
- COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END
} ComposeCallAdvancedAction;
static void compose_destroy (Compose *compose);
static void compose_entries_set (Compose *compose,
- const gchar *mailto);
+ const gchar *mailto,
+ ComposeEntryType to_type);
static gint compose_parse_header (Compose *compose,
MsgInfo *msginfo);
static gchar *compose_parse_references (const gchar *ref,
compose_advanced_action_cb,
COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
NULL},
- {N_("/_Edit/A_dvanced/Delete entire line"),
- NULL,
- compose_advanced_action_cb,
- COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
- NULL},
{N_("/_Edit/A_dvanced/Delete to end of line"),
"<control>K",
compose_advanced_action_cb,
GtkItemFactory *ifactory;
const gchar *subject_format = NULL;
const gchar *body_format = NULL;
+ gchar *mailto_from = NULL;
+ PrefsAccount *mailto_account = NULL;
+ MsgInfo* dummyinfo = NULL;
- if (item && item->prefs && item->prefs->enable_default_account)
+ /* check if mailto defines a from */
+ if (mailto && *mailto != '\0') {
+ scan_mailto_url(mailto, &mailto_from, NULL, NULL, NULL, NULL, NULL, NULL);
+ /* mailto defines a from, check if we can get account prefs from it,
+ if not, the account prefs will be guessed using other ways, but we'll keep
+ the from anyway */
+ if (mailto_from)
+ mailto_account = account_find_from_address(mailto_from, TRUE);
+ if (mailto_account)
+ account = mailto_account;
+ }
+
+ /* if no account prefs set from mailto, set if from folder prefs (if any) */
+ if (!mailto_account && item && item->prefs && item->prefs->enable_default_account)
account = account_find_from_id(item->prefs->default_account);
+ /* if no account prefs set, fallback to the current one */
if (!account) account = cur_account;
g_return_val_if_fail(account != NULL, NULL);
compose = compose_create(account, item, COMPOSE_NEW, FALSE);
+ /* override from name if mailto asked for it */
+ if (mailto_from) {
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), mailto_from);
+ g_free(mailto_from);
+ } else
+ /* override from name according to folder properties */
+ if (item && item->prefs &&
+ item->prefs->compose_with_format &&
+ item->prefs->compose_override_from_format &&
+ *item->prefs->compose_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+
+ dummyinfo = compose_msginfo_new_from_compose(compose);
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ tmp = malloc(strlen(item->prefs->compose_override_from_format)+1);
+ pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format);
+
+#ifdef USE_ASPELL
+ quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("New message From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ }
+
ifactory = gtk_item_factory_from_widget(compose->menubar);
compose->replyinfo = NULL;
if (account->protocol != A_NNTP) {
if (mailto && *mailto != '\0') {
- compose_entries_set(compose, mailto);
+ compose_entries_set(compose, mailto, COMPOSE_TO);
} else if (item && item->prefs->enable_default_to) {
compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
menu_set_active(ifactory, "/Options/Request Return Receipt", TRUE);
}
} else {
- if (mailto) {
- compose_entry_append(compose, mailto, COMPOSE_NEWSGROUPS);
+ if (mailto && *mailto != '\0') {
+ if (!strchr(mailto, '@'))
+ compose_entries_set(compose, mailto, COMPOSE_NEWSGROUPS);
+ else
+ compose_entries_set(compose, mailto, COMPOSE_TO);
} else if (item && FOLDER_CLASS(item->folder) == news_get_class()) {
compose_entry_append(compose, item->path, COMPOSE_NEWSGROUPS);
}
}
if (subject_format || body_format) {
- MsgInfo* dummyinfo = NULL;
if ( subject_format
&& *subject_format != '\0' )
gchar *tmp = NULL;
gchar *buf = NULL;
- dummyinfo = compose_msginfo_new_from_compose(compose);
+ if (!dummyinfo)
+ dummyinfo = compose_msginfo_new_from_compose(compose);
/* decode \-escape sequences in the internal representation of the quote format */
tmp = malloc(strlen(subject_format)+1);
subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
#ifdef USE_ASPELL
- quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account,
+ quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account);
+ quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmp);
quote_fmt_parse();
GtkTextIter start, end;
gchar *tmp = NULL;
- if ( dummyinfo == NULL )
+ if (!dummyinfo)
dummyinfo = compose_msginfo_new_from_compose(compose);
text = GTK_TEXT_VIEW(compose->text);
g_free(tmp);
}
- procmsg_msginfo_free( dummyinfo );
}
+ procmsg_msginfo_free( dummyinfo );
if (attach_files) {
gint i;
if (privacy != NULL) {
if (compose->privacy_system == NULL)
compose->privacy_system = g_strdup(privacy);
+ else if (*(compose->privacy_system) == '\0') {
+ g_free(compose->privacy_system);
+ compose->privacy_system = g_strdup(privacy);
+ }
compose_update_privacy_system_menu_item(compose, FALSE);
compose_use_encryption(compose, TRUE);
}
g_free(folderidentifier);
}
- if (compose_parse_header(compose, msginfo) < 0) return NULL;
+ if (compose_parse_header(compose, msginfo) < 0) {
+ compose->updating = FALSE;
+ compose_destroy(compose);
+ return NULL;
+ }
+
+ /* override from name according to folder properties */
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->reply_with_format &&
+ msginfo->folder->prefs->reply_override_from_format &&
+ *msginfo->folder->prefs->reply_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ 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
+ quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("Message reply From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ }
textview = (GTK_TEXT_VIEW(compose->text));
textbuf = gtk_text_view_get_buffer(textview);
g_free(buf2);
}
+ /* override from name according to folder properties */
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->forward_with_format &&
+ msginfo->folder->prefs->forward_override_from_format &&
+ *msginfo->folder->prefs->forward_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+ MsgInfo *full_msginfo = NULL;
+
+ if (!as_attach)
+ full_msginfo = procmsg_msginfo_get_full_info(msginfo);
+ if (!full_msginfo)
+ full_msginfo = procmsg_msginfo_copy(msginfo);
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ 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
+ quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("Message forward From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ procmsg_msginfo_free(full_msginfo);
+ }
+
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
compose_create_tags(textview, compose);
compose->updating = TRUE;
+ /* override from name according to folder properties */
+ if (msginfo_list->data) {
+ MsgInfo *msginfo = msginfo_list->data;
+
+ if (msginfo->folder && msginfo->folder->prefs &&
+ msginfo->folder->prefs->forward_with_format &&
+ msginfo->folder->prefs->forward_override_from_format &&
+ *msginfo->folder->prefs->forward_override_from_format != '\0') {
+
+ gchar *tmp = NULL;
+ gchar *buf = NULL;
+
+ /* decode \-escape sequences in the internal representation of the quote format */
+ 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
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmp);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL)
+ alertpanel_error(_("Message forward From format error."));
+ else
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ quote_fmt_reset_vartable();
+
+ g_free(tmp);
+ }
+ }
+
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
compose_create_tags(textview, compose);
}
if (!account && !procheader_get_header_from_msginfo(msginfo, queueheader_buf,
sizeof(queueheader_buf), "S:")) {
- account = account_find_from_address(queueheader_buf);
+ account = account_find_from_address(queueheader_buf, FALSE);
}
if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf,
sizeof(queueheader_buf), "X-Claws-Sign:")) {
gchar from[BUFFSIZE];
if (!procheader_get_header_from_msginfo(msginfo, from, sizeof(from), "FROM:")) {
extract_address(from);
- account = account_find_from_address(from);
+ account = account_find_from_address(from, FALSE);
}
}
if (!account) {
}
}
-static void compose_entries_set(Compose *compose, const gchar *mailto)
+static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEntryType to_type)
{
gchar *to = NULL;
gchar *cc = NULL;
gchar *temp = NULL;
gsize len = 0;
gchar **attach = NULL;
-
- scan_mailto_url(mailto, &to, &cc, &bcc, &subject, &body, &attach);
+
+ /* get mailto parts but skip from */
+ scan_mailto_url(mailto, NULL, &to, &cc, &bcc, &subject, &body, &attach);
if (to)
- compose_entry_append(compose, to, COMPOSE_TO);
+ compose_entry_append(compose, to, to_type);
if (cc)
compose_entry_append(compose, cc, COMPOSE_CC);
if (bcc)
}
if (attach) {
- gint i = 0;
+ gint i = 0, att = 0;
+ gchar *warn_files = NULL;
while (attach[i] != NULL) {
gchar *utf8_filename = conv_filename_to_utf8(attach[i]);
if (utf8_filename) {
if (compose_attach_append(compose, attach[i], utf8_filename, NULL)) {
- alertpanel_notice(_("The file '%s' has been attached."), utf8_filename);
- }
+ gchar *tmp = g_strdup_printf("%s%s\n",
+ warn_files?warn_files:"",
+ utf8_filename);
+ g_free(warn_files);
+ warn_files = tmp;
+ att++;
+ }
g_free(utf8_filename);
} else {
alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
}
i++;
}
+ if (warn_files) {
+ alertpanel_notice(ngettext(
+ "The following file has been attached: \n%s",
+ "The following files have been attached: \n%s", att), warn_files);
+ g_free(warn_files);
+ }
}
g_free(to);
g_free(cc);
extract_address(hentry[H_LIST_POST].body);
if (hentry[H_LIST_POST].body[0] != '\0') {
scan_mailto_url(hentry[H_LIST_POST].body,
- &to, NULL, NULL, NULL, NULL, NULL);
+ NULL, &to, NULL, NULL, NULL, NULL, NULL);
if (to) {
g_free(compose->ml_post);
compose->ml_post = to;
if (qmark != NULL) {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(qmark);
quote_fmt_parse();
trimmed_body++;
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account,
+ quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account);
+ quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE);
#endif
if (need_unescape) {
gchar *tmp = NULL;
Xstrdup_a(tmp1, msginfo->from, return);
extract_address(tmp1);
if (to_all || to_sender ||
- !account_find_from_address(tmp1))
+ !account_find_from_address(tmp1, FALSE))
compose_entry_append(compose,
(compose->replyto && !to_sender)
? compose->replyto :
if (!folder_has_parent_of_type(msginfo->folder, F_QUEUE) &&
!folder_has_parent_of_type(msginfo->folder, F_OUTBOX) &&
!folder_has_parent_of_type(msginfo->folder, F_DRAFT)) {
- compose_entry_append(compose,
- msginfo->from ? msginfo->from : "",
- COMPOSE_TO);
+ if (compose->replyto) {
+ compose_entry_append(compose,
+ compose->replyto,
+ COMPOSE_TO);
+ } else {
+ compose_entry_append(compose,
+ msginfo->from ? msginfo->from : "",
+ COMPOSE_TO);
+ }
} else {
/* replying to own mail, use original recp */
compose_entry_append(compose,
gboolean keep_cursor = FALSE;
if (!gtk_text_iter_forward_line(&iter_) ||
- gtk_text_iter_ends_line(&iter_))
+ gtk_text_iter_ends_line(&iter_)) {
return FALSE;
-
+ }
next_quote_str = compose_get_quote_str(buffer, &iter_, "e_len);
if ((quote_str || next_quote_str) &&
end = iter_;
if (quote_len > 0) {
gtk_text_iter_forward_chars(&end, quote_len);
- if (gtk_text_iter_ends_line(&end))
+ if (gtk_text_iter_ends_line(&end)) {
return FALSE;
+ }
}
/* don't join itemized lines */
- if (compose_is_itemized(buffer, &end))
+ if (compose_is_itemized(buffer, &end)) {
return FALSE;
+ }
/* don't join signature separator */
- if (compose_is_sig_separator(compose, buffer, &iter_))
+ if (compose_is_sig_separator(compose, buffer, &iter_)) {
return FALSE;
-
+ }
/* delete quote str */
if (quote_len > 0)
gtk_text_buffer_delete(buffer, &iter_, &end);
removed = TRUE;
}
}
- if (uri_start > 0 && uri_stop > 0) {
+ if (uri_start >= 0 && uri_stop > 0) {
GtkTextIter uri_start_iter, uri_end_iter, back;
gtk_text_buffer_get_iter_at_offset(
buffer, &uri_start_iter, uri_start);
gchar *entry;
header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
-
g_strstrip(entry);
+ g_strstrip(header);
if (entry[0] != '\0') {
for (strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
if (!strcmp(header, prefs_common_translated_header_name(*strptr))) {
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
g_strstrip(entry);
+ g_strstrip(header);
if (strcmp(entry, compose->account->auto_cc)
|| strcmp(header, prefs_common_translated_header_name("Cc:"))) {
found_other = TRUE;
entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
g_strstrip(entry);
+ g_strstrip(header);
if (strcmp(entry, compose->account->auto_bcc)
|| strcmp(header, prefs_common_translated_header_name("Bcc:"))) {
found_other = TRUE;
button_label = _("+_Send");
else
button_label = _("+_Queue");
- message = g_strdup_printf(_("Subject is empty. %s it anyway?"),
- compose->sending?_("Send"):_("Queue"));
+ message = g_strdup_printf(_("Subject is empty. %s"),
+ compose->sending?_("Send it anyway?"):
+ _("Queue it anyway?"));
aval = alertpanel(compose->sending?_("Send"):_("Send later"), message,
GTK_STOCK_CANCEL, button_label, NULL);
g_free(msgpath);
} else {
val = procmsg_send_message_queue(msgpath, &errstr, folder, msgnum, &queued_removed);
- g_unlink(msgpath);
+ claws_unlink(msgpath);
g_free(msgpath);
}
if (!discard_window) {
FILE_OP_ERROR(file, "fwrite");
g_free(chars);
fclose(fp);
- g_unlink(file);
+ claws_unlink(file);
return -1;
}
if (fclose(fp) == EOF) {
FILE_OP_ERROR(file, "fclose");
- g_unlink(file);
+ claws_unlink(file);
return -1;
}
return 0;
if (!compose_warn_encryption(compose)) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -6;
}
* key selection */
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -5;
}
if (compose_redirect_write_to_file(compose, fp) < 0) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return -2;
}
if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
lock = FALSE;
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
return result - 1; /* -2 for a generic error, -3 for signing error, -4 for encoding */
}
if (err == TRUE) {
g_warning("failed to write queue message\n");
fclose(fp);
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -2;
}
if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp, "fclose");
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -2;
}
if (!queue) {
g_warning("can't find queue folder\n");
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -1;
folder_item_scan(queue);
if ((num = folder_item_add_msg(queue, tmp, NULL, FALSE)) < 0) {
g_warning("can't queue the message\n");
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
lock = FALSE;
return -1;
}
if (msgpath == NULL) {
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
} else
*msgpath = tmp;
gboolean standard_header = FALSE;
headerentry = ((ComposeHeaderEntry *)list->data);
-
+
tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child)));
- if (strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
+ g_strstrip(tmp);
+ if (*tmp == '\0' || strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
g_free(tmp);
continue;
}
FolderItem *dest;
gchar * path;
- dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
+ dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE);
if (!dest) return;
path = folder_item_get_identifier(dest);
Compose *compose)
{
gint prev_autowrap;
- GtkTextBuffer *buffer;
+ GtkTextBuffer *buffer = GTK_TEXT_VIEW(text)->buffer;
#if USE_ASPELL
if (event->button == 3) {
GtkTextIter iter;
gint x, y;
/* move the cursor to allow GtkAspell to check the word
* under the mouse */
- gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text),
- GTK_TEXT_WINDOW_TEXT, event->x, event->y,
- &x, &y);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text),
- &iter, x, y);
+ if (event->x && event->y) {
+ gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text),
+ GTK_TEXT_WINDOW_TEXT, event->x, event->y,
+ &x, &y);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text),
+ &iter, x, y);
+ } else {
+ GtkTextMark *mark = gtk_text_buffer_get_insert(buffer);
+ gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+ }
/* get selection */
stuff_selected = gtk_text_buffer_get_selection_bounds(
- GTK_TEXT_VIEW(text)->buffer,
+ buffer,
&sel_start, &sel_end);
- gtk_text_buffer_place_cursor (GTK_TEXT_VIEW(text)->buffer, &iter);
+ gtk_text_buffer_place_cursor (buffer, &iter);
/* reselect stuff */
if (stuff_selected
&& gtk_text_iter_in_range(&iter, &sel_start, &sel_end)) {
- gtk_text_buffer_select_range(GTK_TEXT_VIEW(text)->buffer,
+ gtk_text_buffer_select_range(buffer,
&sel_start, &sel_end);
}
return FALSE; /* pass the event so that the right-click goes through */
event.button = 3;
event.time = gtk_get_current_event_time();
+ event.x = 0;
+ event.y = 0;
return text_clicked(compose->text, &event, compose);
}
if (compose->privacy_system != NULL) {
gchar *systemid;
-
menuitem = gtk_item_factory_get_widget(ifactory, branch_path);
g_return_if_fail(menuitem != NULL);
msginfo = dummyinfo;
}
+ if (tmpl->from && *tmpl->from != '\0') {
+#ifdef USE_ASPELL
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+ compose->gtkaspell);
+#else
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+ quote_fmt_scan_string(tmpl->from);
+ quote_fmt_parse();
+
+ buf = quote_fmt_get_buffer();
+ if (buf == NULL) {
+ alertpanel_error(_("Template From format error."));
+ } else {
+ gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+ }
+ }
+
if (tmpl->to && *tmpl->to != '\0') {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmpl->to);
quote_fmt_parse();
if (tmpl->cc && *tmpl->cc != '\0') {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmpl->cc);
quote_fmt_parse();
if (tmpl->bcc && *tmpl->bcc != '\0') {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmpl->bcc);
quote_fmt_parse();
/* process the subject */
if (tmpl->subject && *tmpl->subject != '\0') {
#ifdef USE_ASPELL
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
compose->gtkaspell);
#else
- quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+ quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
#endif
quote_fmt_scan_string(tmpl->subject);
quote_fmt_parse();
if (setpgid(0, getppid()))
perror("setpgid");
- if (prefs_common.ext_editor_cmd &&
- (p = strchr(prefs_common.ext_editor_cmd, '%')) &&
+ if (prefs_common_get_ext_editor_cmd() &&
+ (p = strchr(prefs_common_get_ext_editor_cmd(), '%')) &&
*(p + 1) == 's' && !strchr(p + 2, '%')) {
- g_snprintf(buf, sizeof(buf), prefs_common.ext_editor_cmd, file);
+ g_snprintf(buf, sizeof(buf), prefs_common_get_ext_editor_cmd(), file);
} else {
- if (prefs_common.ext_editor_cmd)
+ if (prefs_common_get_ext_editor_cmd())
g_warning("External editor command line is invalid: '%s'\n",
- prefs_common.ext_editor_cmd);
+ prefs_common_get_ext_editor_cmd());
g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, file);
}
compose_insert_file(compose, compose->exteditor_file);
compose_changed_cb(NULL, compose);
- if (g_unlink(compose->exteditor_file) < 0)
+ if (claws_unlink(compose->exteditor_file) < 0)
FILE_OP_ERROR(compose->exteditor_file, "unlink");
} else if (buf[0] == '1') { /* failed */
g_warning("Couldn't exec external editor\n");
- if (g_unlink(compose->exteditor_file) < 0)
+ if (claws_unlink(compose->exteditor_file) < 0)
FILE_OP_ERROR(compose->exteditor_file, "unlink");
} else if (buf[0] == '2') {
g_warning("Couldn't write to file\n");
}
if (msgnum < 0) {
warn_err:
- g_unlink(tmp);
+ claws_unlink(tmp);
g_free(tmp);
if (action != COMPOSE_AUTO_SAVE) {
if (action != COMPOSE_DRAFT_FOR_EXIT)
gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
DRAFTED_AT_EXIT, NULL);
if (is_file_exist(filepath))
- g_unlink(filepath);
+ claws_unlink(filepath);
g_free(filepath);
}
#endif
if (compose->modified) {
+ 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
+ * it is compose_close - which means once unlocked,
+ * the compose struct will be freed */
+ debug_print("couldn't lock mutex, probably sending\n");
+ return;
+ }
val = alertpanel(_("Discard message"),
_("This message has been modified. Discard it?"),
_("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL);
-
+ g_mutex_unlock(compose->mutex);
switch (val) {
case G_ALERTDEFAULT:
if (prefs_common.autosave)
}
} else if (GTK_IS_EDITABLE(entry))
gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
-
+
+ compose->modified = TRUE;
}
static void entry_allsel(GtkWidget *entry)
GtkTextBuffer *buffer;
GtkTextMark *mark;
GtkTextIter ins, start_iter, end_iter;
- gboolean found;
g_return_if_fail(GTK_IS_TEXT_VIEW(text));
gtk_text_iter_set_line_offset(&start_iter, 0);
end_iter = ins;
- if (gtk_text_iter_ends_line(&end_iter))
- found = gtk_text_iter_forward_char(&end_iter);
- else
- found = gtk_text_iter_forward_to_line_end(&end_iter);
-
- if (found)
- gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
+ if (gtk_text_iter_ends_line(&end_iter)){
+ if (!gtk_text_iter_forward_char(&end_iter))
+ gtk_text_iter_backward_char(&start_iter);
+ }
+ else
+ gtk_text_iter_forward_to_line_end(&end_iter);
+ gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
}
static void textview_delete_to_line_end (GtkTextView *text)
GtkTextBuffer *buffer;
GtkTextMark *mark;
GtkTextIter ins, end_iter;
- gboolean found;
g_return_if_fail(GTK_IS_TEXT_VIEW(text));
gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
end_iter = ins;
if (gtk_text_iter_ends_line(&end_iter))
- found = gtk_text_iter_forward_char(&end_iter);
+ gtk_text_iter_forward_char(&end_iter);
else
- found = gtk_text_iter_forward_to_line_end(&end_iter);
- if (found)
- gtk_text_buffer_delete(buffer, &ins, &end_iter);
+ gtk_text_iter_forward_to_line_end(&end_iter);
+ gtk_text_buffer_delete(buffer, &ins, &end_iter);
}
static void compose_advanced_action_cb(Compose *compose,
{textview_delete_forward_word},
{textview_delete_backward_word},
{textview_delete_line},
- {NULL}, /* gtk_stext_delete_line_n */
{textview_delete_to_line_end}
};
if (gdk_atom_name(data->type) && !strcmp(gdk_atom_name(data->type), "text/uri-list")) {
AlertValue val = G_ALERTDEFAULT;
+ list = uri_list_extract_filenames((const gchar *)data->data);
+
+ if (list == NULL && strstr((gchar *)(data->data), "://")) {
+ /* Assume a list of no files, and data has ://, is a remote link */
+ gchar *tmpdata = g_strstrip(g_strdup((const gchar *)data->data));
+ gchar *tmpfile = get_tmp_file();
+ str_write_to_file(tmpdata, tmpfile);
+ g_free(tmpdata);
+ compose_insert_file(compose, tmpfile);
+ claws_unlink(tmpfile);
+ g_free(tmpfile);
+ gtk_drag_finish(drag_context, TRUE, FALSE, time);
+ compose_beautify_paragraph(compose, NULL, TRUE);
+ return;
+ }
switch (prefs_common.compose_dnd_mode) {
case COMPOSE_DND_ASK:
val = alertpanel_full(_("Insert or attach?"),
if (val == G_ALERTDEFAULT || val == G_ALERTCANCEL) {
gtk_drag_finish(drag_context, FALSE, FALSE, time);
+ list_free_strings(list);
+ g_list_free(list);
return;
} else if (val == G_ALERTOTHER) {
compose_attach_drag_received_cb(widget, drag_context, x, y, data, info, time, user_data);
+ list_free_strings(list);
+ g_list_free(list);
return;
}
- list = uri_list_extract_filenames((const gchar *)data->data);
+
for (tmp = list; tmp != NULL; tmp = tmp->next) {
compose_insert_file(compose, (const gchar *)tmp->data);
}
gchar *tmpfile = get_tmp_file();
str_write_to_file((const gchar *)data->data, tmpfile);
compose_insert_file(compose, tmpfile);
- g_unlink(tmpfile);
+ claws_unlink(tmpfile);
g_free(tmpfile);
gtk_drag_finish(drag_context, TRUE, FALSE, time);
#endif
|| gtk_text_iter_starts_line(iter))
gtk_text_buffer_insert(buffer, iter, text, len);
else {
- debug_print("insert nowrap \\n\n");
- gtk_text_buffer_insert_with_tags_by_name(buffer,
- iter, text, len, "no_join", NULL);
+ /* check if the preceding is just whitespace or quote */
+ GtkTextIter start_line;
+ gchar *tmp = NULL, *quote = NULL;
+ gint quote_len = 0, is_normal = 0;
+ start_line = *iter;
+ gtk_text_iter_set_line_offset(&start_line, 0);
+ tmp = gtk_text_buffer_get_text(buffer, &start_line, iter, FALSE);
+ g_strstrip(tmp);
+ if (*tmp == '\0') {
+ is_normal = 1;
+ } else {
+ quote = compose_get_quote_str(buffer, &start_line, "e_len);
+ if (quote)
+ is_normal = 1;
+ g_free(quote);
+ }
+ g_free(tmp);
+
+ if (is_normal) {
+ gtk_text_buffer_insert(buffer, iter, text, len);
+ } else {
+ gtk_text_buffer_insert_with_tags_by_name(buffer,
+ iter, text, len, "no_join", NULL);
+ }
}
}
gchar *to;
Xstrdup_a(to, msginfo->to, return NULL);
extract_address(to);
- account = account_find_from_address(to);
+ account = account_find_from_address(to, FALSE);
}
if (!account && prefs_common.forward_account_autosel) {
(msginfo, cc,sizeof cc , "Cc:")) {
gchar *buf = cc + strlen("Cc:");
extract_address(buf);
- account = account_find_from_address(buf);
+ account = account_find_from_address(buf, FALSE);
}
}
(msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) {
gchar *buf = deliveredto + strlen("Delivered-To:");
extract_address(buf);
- account = account_find_from_address(buf);
+ account = account_find_from_address(buf, FALSE);
}
}