MsgInfo *msginfo,
const gchar *fmt,
const gchar *qmark,
- const gchar *body);
+ const gchar *body,
+ gboolean rewrap);
static void compose_reply_set_entry (Compose *compose,
MsgInfo *msginfo,
if (prefs_common.auto_exteditor)
compose_exec_ext_editor(compose);
+ compose->modified = FALSE;
compose_set_title(compose);
return compose;
}
compose_quote_fmt(compose, compose->replyinfo,
prefs_common.quotefmt,
- qmark, body);
+ qmark, body, FALSE);
}
if (procmime_msginfo_is_encrypted(compose->replyinfo)) {
compose_force_encryption(compose, account, FALSE);
if (prefs_common.auto_exteditor)
compose_exec_ext_editor(compose);
+ compose->modified = FALSE;
compose_set_title(compose);
return compose;
}
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
compose_create_tags(textview, compose);
-
+
+ undo_block(compose->undostruct);
if (as_attach) {
gchar *msgfile;
compose_quote_fmt(compose, full_msginfo,
prefs_common.fw_quotefmt,
- qmark, body);
+ qmark, body, FALSE);
compose_attach_parts(compose, msginfo);
procmsg_msginfo_free(full_msginfo);
g_free(folderidentifier);
}
+ undo_unblock(compose->undostruct);
+
+ compose->modified = FALSE;
compose_set_title(compose);
return compose;
}
textview = GTK_TEXT_VIEW(compose->text);
textbuf = gtk_text_view_get_buffer(textview);
compose_create_tags(textview, compose);
-
+
+ undo_block(compose->undostruct);
for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
msgfile = procmsg_get_message_file_path((MsgInfo *)msginfo->data);
if (!is_file_exist(msgfile))
gtk_text_buffer_place_cursor(textbuf, &iter);
gtk_widget_grab_focus(compose->header_last->entry);
-
+ undo_unblock(compose->undostruct);
+ compose->modified = FALSE;
compose_set_title(compose);
return compose;
}
if (prefs_common.auto_exteditor)
compose_exec_ext_editor(compose);
+ compose->modified = FALSE;
compose_set_title(compose);
}
msginfo->subject);
gtk_editable_set_editable(GTK_EDITABLE(compose->subject_entry), FALSE);
- compose_quote_fmt(compose, msginfo, "%M", NULL, NULL);
+ compose_quote_fmt(compose, msginfo, "%M", NULL, NULL, FALSE);
gtk_text_view_set_editable(GTK_TEXT_VIEW(compose->text), FALSE);
compose_colorize_signature(compose);
gtk_widget_set_sensitive(compose->toolbar->linewrap_current_btn, FALSE);
gtk_widget_set_sensitive(compose->toolbar->linewrap_all_btn, FALSE);
+ compose->modified = FALSE;
compose_set_title(compose);
return compose;
}
static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
const gchar *fmt, const gchar *qmark,
- const gchar *body)
+ const gchar *body, gboolean rewrap)
{
static MsgInfo dummyinfo;
gchar *quote_str = NULL;
gchar *buf;
- gchar *p, *lastp;
- gint len;
gboolean prev_autowrap;
const gchar *trimmed_body = body;
- gint cursor_pos = 0;
+ gint cursor_pos = -1;
GtkTextView *text = GTK_TEXT_VIEW(compose->text);
GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
GtkTextIter iter;
+ GtkTextMark *mark;
if (!msginfo)
msginfo = &dummyinfo;
g_signal_handlers_block_by_func(G_OBJECT(buffer),
G_CALLBACK(text_inserted),
compose);
- for (p = buf; *p != '\0'; ) {
- GtkTextMark *mark;
-
- mark = gtk_text_buffer_get_insert(buffer);
- gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
- lastp = strchr(p, '\n');
- len = lastp ? lastp - p + 1 : -1;
-
- if (g_utf8_validate(p, -1, NULL)) {
- gtk_text_buffer_insert(buffer, &iter, p, len);
- } else {
- gchar *tmpin = g_strdup(p);
- gchar *tmpout = NULL;
- tmpin[len] = '\0';
- tmpout = conv_codeset_strdup
- (tmpin, conv_get_locale_charset_str(),
- CS_INTERNAL);
- gtk_text_buffer_insert(buffer, &iter, tmpout, -1);
- g_free(tmpin);
+ mark = gtk_text_buffer_get_insert(buffer);
+ gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+ if (g_utf8_validate(buf, -1, NULL)) {
+ gtk_text_buffer_insert(buffer, &iter, buf, -1);
+ } else {
+ gchar *tmpout = NULL;
+ tmpout = conv_codeset_strdup
+ (buf, conv_get_locale_charset_str(),
+ CS_INTERNAL);
+ if (!tmpout || !g_utf8_validate(tmpout, -1, NULL)) {
g_free(tmpout);
+ tmpout = g_malloc(strlen(buf)*2+1);
+ conv_localetodisp(tmpout, strlen(buf)*2+1, buf);
}
-
- if (lastp)
- p = lastp + 1;
- else
- break;
+ gtk_text_buffer_insert(buffer, &iter, tmpout, -1);
+ g_free(tmpout);
}
cursor_pos = quote_fmt_get_cursor_pos();
+ compose->set_cursor_pos = cursor_pos;
+ if (cursor_pos == -1) {
+ cursor_pos = 0;
+ }
gtk_text_buffer_get_start_iter(buffer, &iter);
gtk_text_buffer_get_iter_at_offset(buffer, &iter, cursor_pos);
gtk_text_buffer_place_cursor(buffer, &iter);
- compose->set_cursor_pos = cursor_pos;
compose->autowrap = prev_autowrap;
- if (compose->autowrap)
+ if (compose->autowrap && rewrap)
compose_wrap_all(compose);
g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
/* put the cursor where it should be
* either where the quote_fmt says, either before the signature */
- if (compose->set_cursor_pos <= 0)
+ if (compose->set_cursor_pos < 0)
gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
else
gtk_text_buffer_get_iter_at_offset(buffer, &iter,
compose->autowrap = FALSE;
buffer = gtk_text_view_get_buffer(text);
-
- undo_block(compose->undostruct);
-
+ undo_wrapping(compose->undostruct, TRUE);
if (par_iter) {
iter = *par_iter;
} else {
if (par_iter)
*par_iter = iter;
-
- undo_unblock(compose->undostruct);
+ undo_wrapping(compose->undostruct, FALSE);
compose->autowrap = prev_autowrap;
}
+void compose_action_cb(void *data)
+{
+ Compose *compose = (Compose *)data;
+ compose_wrap_all(compose);
+}
+
static void compose_wrap_all(Compose *compose)
{
compose_wrap_all_full(compose, FALSE);
buffer = gtk_text_view_get_buffer(text);
- undo_block(compose->undostruct);
-
gtk_text_buffer_get_start_iter(buffer, &iter);
while (!gtk_text_iter_is_end(&iter))
compose_beautify_paragraph(compose, &iter, force);
- undo_unblock(compose->undostruct);
}
static void compose_set_title(Compose *compose)
if ((compose->replyinfo == NULL) && (compose->fwdinfo == NULL)) {
parsed_str = compose_quote_fmt(compose, NULL, tmpl->value,
- NULL, NULL);
+ NULL, NULL, FALSE);
} else {
if (prefs_common.quotemark && *prefs_common.quotemark)
qmark = prefs_common.quotemark;
if (compose->replyinfo != NULL)
parsed_str = compose_quote_fmt(compose, compose->replyinfo,
- tmpl->value, qmark, NULL);
+ tmpl->value, qmark, NULL, FALSE);
else if (compose->fwdinfo != NULL)
parsed_str = compose_quote_fmt(compose, compose->fwdinfo,
- tmpl->value, qmark, NULL);
+ tmpl->value, qmark, NULL, FALSE);
else
parsed_str = NULL;
}
if (parsed_str) {
cursor_pos = quote_fmt_get_cursor_pos();
+ compose->set_cursor_pos = cursor_pos;
+ if (cursor_pos == -1)
+ cursor_pos = 0;
gtk_text_buffer_get_start_iter(buffer, &iter);
gtk_text_buffer_get_iter_at_offset(buffer, &iter, cursor_pos);
gtk_text_buffer_place_cursor(buffer, &iter);
- compose->set_cursor_pos = cursor_pos;
}
if (parsed_str)
strlist = NULL;
for (; mime_type_list != NULL; mime_type_list = mime_type_list->next) {
MimeType *type = (MimeType *) mime_type_list->data;
- strlist = g_list_append(strlist,
- g_strdup_printf("%s/%s",
- type->type, type->sub_type));
+ gchar *tmp;
+
+ tmp = g_strdup_printf("%s/%s", type->type, type->sub_type);
+
+ if (g_list_find_custom(strlist, tmp, (GCompareFunc)strcmp2))
+ g_free(tmp);
+ else
+ strlist = g_list_insert_sorted(strlist, (gpointer)tmp,
+ (GCompareFunc)strcmp2);
}
-
+
gtk_combo_set_popdown_strings(GTK_COMBO(mimetype_entry), strlist);
for (mime_type_list = strlist; mime_type_list != NULL;
mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
gtk_text_buffer_place_cursor(buffer, iter);
- compose_quote_fmt(compose, NULL, "%Q", qmark, new_text);
+ compose_quote_fmt(compose, NULL, "%Q", qmark, new_text, TRUE);
g_free(new_text);
g_object_set_data(G_OBJECT(compose->text), "paste_as_quotation",
GINT_TO_POINTER(paste_as_quotation - 1));
gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
+ gtk_text_buffer_place_cursor(buffer, iter);
} else
gtk_text_buffer_insert(buffer, iter, text, len);