Do not delete text lines on signature set in composer

** Fix for bug #553535

	* e-msg-composer.c: (is_top_signature), (get_signature_html),
	(set_editor_text), (e_msg_composer_show_sig_file): Do not eat
	lines of text when changing signature at top of the message.
	Add one extra empty line between the signature and the body
	of the mail when placing signature to the bottom.
This commit is contained in:
Milan Crha
2009-04-27 11:52:30 +02:00
committed by Matthew Barnes
parent 3e2ea94186
commit e887df9a55
2 changed files with 28 additions and 5 deletions

View File

@ -1,3 +1,13 @@
2009-04-27 Milan Crha <mcrha@redhat.com>
** Fix for bug #553535
* e-msg-composer.c: (is_top_signature), (get_signature_html),
(set_editor_text), (e_msg_composer_show_sig_file): Do not eat
lines of text when changing signature at top of the message.
Add one extra empty line between the signature and the body
of the mail when placing signature to the bottom.
2009-03-19 Milan Crha <mcrha@redhat.com>
** Fix for bug #574680

View File

@ -1034,6 +1034,9 @@ decode_signature_name (const gchar *name)
}
#define CONVERT_SPACES CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES
#define NO_SIGNATURE_TEXT \
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->" \
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature_name\" value=\"uid:Noname\">--><BR>"
static gchar *
get_signature_html (EMsgComposer *composer)
@ -1105,14 +1108,15 @@ get_signature_html (EMsgComposer *composer)
*/
html = g_strdup_printf ("<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->"
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature_name\" value=\"uid:%s\">-->"
"<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD>"
"<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD><BR>"
"%s%s%s%s"
"</TD></TR></TABLE>",
"%s</TD></TR></TABLE>",
encoded_uid ? encoded_uid : "",
format_html ? "" : "<PRE>\n",
format_html || (!strncmp ("-- \n", text, 4) || strstr (text, "\n-- \n")) ? "" : "-- \n",
text,
format_html ? "" : "</PRE>\n");
format_html ? "" : "</PRE>\n",
is_top_signature () ? "<BR>" : "");
g_free (text);
g_free (encoded_uid);
text = html;
@ -1176,12 +1180,13 @@ set_editor_text (EMsgComposer *composer,
"<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD> </TD></TR></TABLE>%s", text);
}
} else {
body = g_strdup (text);
/* no marker => to the bottom */
body = g_strdup_printf ("%s<BR>", text);
}
gtkhtml_editor_set_text_html (GTKHTML_EDITOR (composer), body, -1);
if (set_signature && !reply_signature_on_top)
if (set_signature)
e_msg_composer_show_sig_file (composer);
}
@ -3969,6 +3974,7 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
GtkhtmlEditor *editor;
GtkHTML *html;
gchar *html_text;
gboolean top_signature;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@ -3995,6 +4001,8 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
}
gtkhtml_editor_run_command (editor, "unblock-selection");
top_signature = is_top_signature ();
html_text = get_signature_html (composer);
if (html_text) {
gtkhtml_editor_run_command (editor, "insert-paragraph");
@ -4002,11 +4010,16 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
gtkhtml_editor_run_command (editor, "insert-paragraph");
else
gtkhtml_editor_run_command (editor, "cursor-forward");
gtkhtml_editor_set_paragraph_data (editor, "orig", "0");
gtkhtml_editor_run_command (editor, "indent-zero");
gtkhtml_editor_run_command (editor, "style-normal");
gtkhtml_editor_insert_html (editor, html_text);
g_free (html_text);
} else if (top_signature) {
/* insert paragraph after the signature ClueFlow things */
gtkhtml_editor_run_command (editor, "cursor-forward");
gtkhtml_editor_run_command (editor, "insert-paragraph");
}
gtkhtml_editor_undo_end (editor);