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,
static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
FolderItem *folder_item);
#endif
+static void compose_attach_update_label(Compose *compose);
+
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data);
static GtkItemFactoryEntry compose_popup_entries[] =
{
NULL, compose_set_encoding_cb, C_AUTO, "<RadioItem>"},
{N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Options/Character _encoding/7bit ascii (US-ASC_II)"),
+ {N_("/_Options/Character _encoding/7bit ASCII (US-ASC_II)"),
ENC_ACTION(C_US_ASCII)},
{N_("/_Options/Character _encoding/Unicode (_UTF-8)"),
ENC_ACTION(C_UTF_8)},
GtkItemFactory *ifactory;
const gchar *subject_format = NULL;
const gchar *body_format = NULL;
-
- if (item && item->prefs && item->prefs->enable_default_account)
+ gchar *mailto_from = NULL;
+ PrefsAccount *mailto_account = NULL;
+
+ /* 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);
+ }
+
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);
}
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();
alertpanel_error(_("New message subject format error."));
else
gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
g_free(subject);
body_format,
NULL, tmp, FALSE, TRUE,
_("New message body format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
g_free(tmp);
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;
+ }
textview = (GTK_TEXT_VIEW(compose->text));
textbuf = gtk_text_view_get_buffer(textview);
compose_quote_fmt(compose, compose->replyinfo,
body_fmt, qmark, body, FALSE, TRUE,
_("Message reply format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
}
compose_quote_fmt(compose, full_msginfo,
body_fmt, qmark, body, FALSE, TRUE,
_("Message forward format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
compose_attach_parts(compose, msginfo);
}
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 *bcc = NULL;
gchar *subject = NULL;
gchar *body = NULL;
gchar *temp = NULL;
gsize len = 0;
- gchar *attach = NULL;
-
- scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body, &attach);
+ gchar **attach = NULL;
+
+ /* 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)
+ compose_entry_append(compose, bcc, COMPOSE_BCC);
if (subject) {
if (!g_utf8_validate (subject, -1, NULL)) {
temp = g_locale_to_utf8 (subject, -1, NULL, &len, NULL);
}
if (attach) {
- gchar *utf8_filename = conv_filename_to_utf8(attach);
- if (utf8_filename) {
- if (compose_attach_append(compose, attach, utf8_filename, NULL)) {
- alertpanel_notice(_("The file '%s' has been attached."), attach);
- }
- g_free(utf8_filename);
- } else {
- alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+ 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)) {
+ 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);
+ g_free(bcc);
g_free(subject);
g_free(body);
- g_free(attach);
+ g_strfreev(attach);
}
static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
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,
-1);
g_auto_pointer_free(auto_ainfo);
+ compose_attach_update_label(compose);
return TRUE;
}
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);
goto bail;
}
- tmsgid = g_strdup(compose->msgid);
+ tmsgid = compose->msgid ? g_strdup(compose->msgid) : NULL;
if (discard_window) {
compose->sending = FALSE;
compose_close(compose);
} else {
g_snprintf(buf, sizeof(buf), "%s", "");
}
- generate_msgid(buf, sizeof(buf));
- err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
- compose->msgid = g_strdup(buf);
+
+ if (compose->account->gen_msgid) {
+ generate_msgid(buf, sizeof(buf));
+ err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+ compose->msgid = g_strdup(buf);
+ } else {
+ compose->msgid = NULL;
+ }
if (compose_redirect_write_headers_from_headerlist(compose, fp))
return -1;
} 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->account->gen_msgid) {
+ generate_msgid(buf, sizeof(buf));
+ g_string_append_printf(header, "Message-ID: <%s>\n", buf);
+ compose->msgid = g_strdup(buf);
+ } else {
+ compose->msgid = NULL;
+ }
if (compose->remove_references == FALSE) {
/* In-Reply-To */
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;
}
if (*address != '\0') {
gchar *name = procheader_get_fromname(address);
extract_address(address);
- addressbook_add_contact(name, address, NULL);
+ addressbook_add_contact(name, address, NULL, NULL);
}
g_free(address);
}
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);
/* process the other fields */
compose_template_apply_fields(compose, tmpl);
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
compose_changed_cb(NULL, compose);
}
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_draft(data, action);
}
-static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data)
{
- Compose *compose = (Compose *)data;
- GList *file_list;
-
- if (compose->redirect_filename != NULL)
- return;
-
- file_list = filesel_select_multiple_files_open(_("Select file"));
-
- if (file_list) {
+ if (compose && file_list) {
GList *tmp;
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *utf8_filename = conv_filename_to_utf8(file);
compose_attach_append(compose, file, utf8_filename, NULL);
compose_changed_cb(NULL, compose);
+ if (free_data) {
g_free(file);
+ tmp->data = NULL;
+ }
g_free(utf8_filename);
}
+ }
+}
+
+static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+ GList *file_list;
+
+ if (compose->redirect_filename != NULL)
+ return;
+
+ file_list = filesel_select_multiple_files_open(_("Select file"));
+
+ if (file_list) {
+ compose_attach_from_list(compose, file_list, TRUE);
g_list_free(file_list);
}
-
- compose_attach_update_label(compose);
}
static void compose_insert_file_cb(gpointer data, guint action,
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);
+ g_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);
}
|| 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);
}
}