EHTMLEditor - Avoid asking for loosing the formatting if replying from a selection
Add a special header to the newly created message from the selection text and later mark the flag in EHTMLEditorView to avoid showing the dialog for loosing the formatting. Do something similar for messages from drafts to avoid searching for string inside the message's source.
This commit is contained in:
@ -131,7 +131,6 @@ e_composer_private_constructed (EMsgComposer *composer)
|
||||
|
||||
priv->charset = e_composer_get_default_charset ();
|
||||
|
||||
priv->is_from_draft = FALSE;
|
||||
priv->is_from_message = FALSE;
|
||||
priv->is_from_new_message = FALSE;
|
||||
priv->set_signature_from_message = FALSE;
|
||||
@ -824,7 +823,7 @@ composer_move_caret (EMsgComposer *composer)
|
||||
EHTMLEditorView *view;
|
||||
EHTMLEditorSelection *editor_selection;
|
||||
GSettings *settings;
|
||||
gboolean start_bottom, html_mode, top_signature;
|
||||
gboolean start_bottom, html_mode, top_signature, is_from_draft;
|
||||
gboolean has_paragraphs_in_body = TRUE;
|
||||
WebKitDOMDocument *document;
|
||||
WebKitDOMDOMWindow *window;
|
||||
@ -849,6 +848,7 @@ composer_move_caret (EMsgComposer *composer)
|
||||
view = e_html_editor_get_view (editor);
|
||||
editor_selection = e_html_editor_view_get_selection (view);
|
||||
html_mode = e_html_editor_view_get_html_mode (view);
|
||||
is_from_draft = e_html_editor_view_is_message_from_draft (view);
|
||||
|
||||
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
|
||||
window = webkit_dom_document_get_default_view (document);
|
||||
@ -860,7 +860,7 @@ composer_move_caret (EMsgComposer *composer)
|
||||
new_range = webkit_dom_document_create_range (document);
|
||||
|
||||
/* If editing message as new don't handle with caret */
|
||||
if (composer->priv->is_from_message || composer->priv->is_from_draft) {
|
||||
if (composer->priv->is_from_message || is_from_draft) {
|
||||
if (composer->priv->is_from_message)
|
||||
webkit_dom_element_set_attribute (
|
||||
WEBKIT_DOM_ELEMENT (body),
|
||||
|
||||
@ -3093,15 +3093,20 @@ handle_multipart (EMsgComposer *composer,
|
||||
}
|
||||
|
||||
} else if (depth == 0 && i == 0) {
|
||||
EHTMLEditor *editor;
|
||||
gboolean is_from_draft, is_html = FALSE;
|
||||
gchar *html;
|
||||
gssize length;
|
||||
gboolean is_html = FALSE;
|
||||
|
||||
editor = e_msg_composer_get_editor (composer);
|
||||
is_from_draft = e_html_editor_view_is_message_from_draft (
|
||||
e_html_editor_get_view (editor));
|
||||
|
||||
/* Since the first part is not multipart/alternative,
|
||||
* this must be the body. */
|
||||
|
||||
/* If we are opening message from Drafts */
|
||||
if (composer->priv->is_from_draft) {
|
||||
if (is_from_draft) {
|
||||
/* Extract the body */
|
||||
CamelDataWrapper *dw;
|
||||
|
||||
@ -3272,6 +3277,7 @@ e_msg_composer_new_with_message (EShell *shell,
|
||||
struct _camel_header_raw *xev;
|
||||
gchar *identity_uid;
|
||||
gint len, i;
|
||||
gboolean is_from_draft;
|
||||
|
||||
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
|
||||
|
||||
@ -3414,8 +3420,10 @@ e_msg_composer_new_with_message (EShell *shell,
|
||||
composer_mode = camel_medium_get_header (
|
||||
CAMEL_MEDIUM (message), "X-Evolution-Composer-Mode");
|
||||
|
||||
if (composer_mode && *composer_mode)
|
||||
composer->priv->is_from_draft = TRUE;
|
||||
if (composer_mode && *composer_mode) {
|
||||
is_from_draft = TRUE;
|
||||
e_html_editor_view_set_is_message_from_draft (view, is_from_draft);
|
||||
}
|
||||
|
||||
if (format != NULL) {
|
||||
gchar **flags;
|
||||
@ -3547,7 +3555,7 @@ e_msg_composer_new_with_message (EShell *shell,
|
||||
}
|
||||
|
||||
/* If we are opening message from Drafts */
|
||||
if (composer->priv->is_from_draft) {
|
||||
if (is_from_draft) {
|
||||
/* Extract the body */
|
||||
CamelDataWrapper *dw;
|
||||
|
||||
|
||||
@ -86,6 +86,8 @@ struct _EHTMLEditorViewPrivate {
|
||||
|
||||
gboolean convertor_insert;
|
||||
gboolean body_input_event_removed;
|
||||
gboolean is_message_from_draft;
|
||||
gboolean is_message_from_selection;
|
||||
|
||||
WebKitWebView *convertor_web_view;
|
||||
|
||||
@ -4991,6 +4993,8 @@ e_html_editor_view_init (EHTMLEditorView *view)
|
||||
g_free (comma_separated);
|
||||
|
||||
view->priv->body_input_event_removed = TRUE;
|
||||
view->priv->is_message_from_draft = FALSE;
|
||||
view->priv->is_message_from_selection = FALSE;
|
||||
view->priv->convertor_insert = FALSE;
|
||||
|
||||
view->priv->convertor_web_view =
|
||||
@ -7166,8 +7170,19 @@ e_html_editor_view_set_text_html (EHTMLEditorView *view,
|
||||
{
|
||||
view->priv->reload_in_progress = TRUE;
|
||||
|
||||
if (view->priv->is_message_from_draft) {
|
||||
webkit_web_view_load_string (
|
||||
WEBKIT_WEB_VIEW (view), text, NULL, NULL, "file://");
|
||||
return;
|
||||
}
|
||||
|
||||
if (view->priv->is_message_from_selection && !view->priv->html_mode) {
|
||||
convert_and_load_html_to_plain_text (view, text);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Only convert messages that are in HTML */
|
||||
if (!view->priv->html_mode && *text && !strstr (text, "data-evo-draft")) {
|
||||
if (!view->priv->html_mode) {
|
||||
if (strstr (text, "<!-- text/html -->")) {
|
||||
if (!show_lose_formatting_dialog (view)) {
|
||||
e_html_editor_view_set_html_mode (view, TRUE);
|
||||
@ -7177,10 +7192,9 @@ e_html_editor_view_set_text_html (EHTMLEditorView *view,
|
||||
}
|
||||
}
|
||||
convert_and_load_html_to_plain_text (view, text);
|
||||
} else {
|
||||
} else
|
||||
webkit_web_view_load_string (
|
||||
WEBKIT_WEB_VIEW (view), text, NULL, NULL, "file://");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7953,3 +7967,29 @@ e_html_editor_view_add_inline_image_from_mime_part (EHTMLEditorView *view,
|
||||
g_free (mime_type);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
void
|
||||
e_html_editor_view_set_is_message_from_draft (EHTMLEditorView *view,
|
||||
gboolean value)
|
||||
{
|
||||
g_return_if_fail (E_IS_HTML_EDITOR_VIEW (view));
|
||||
|
||||
view->priv->is_message_from_draft = value;
|
||||
}
|
||||
|
||||
gboolean
|
||||
e_html_editor_view_is_message_from_draft (EHTMLEditorView *view)
|
||||
{
|
||||
g_return_val_if_fail (E_IS_HTML_EDITOR_VIEW (view), FALSE);
|
||||
|
||||
return view->priv->is_message_from_draft;
|
||||
}
|
||||
|
||||
void
|
||||
e_html_editor_view_set_is_message_from_selection (EHTMLEditorView *view,
|
||||
gboolean value)
|
||||
{
|
||||
g_return_if_fail (E_IS_HTML_EDITOR_VIEW (view));
|
||||
|
||||
view->priv->is_message_from_selection = value;
|
||||
}
|
||||
|
||||
@ -167,6 +167,14 @@ GList * e_html_editor_view_get_parts_for_inline_images
|
||||
const gchar *uid_domain);
|
||||
void remove_image_attributes_from_element
|
||||
(WebKitDOMElement *element);
|
||||
gboolean e_html_editor_view_is_message_from_draft
|
||||
(EHTMLEditorView *view);
|
||||
void e_html_editor_view_set_is_message_from_draft
|
||||
(EHTMLEditorView *view,
|
||||
gboolean value);
|
||||
void e_html_editor_view_set_is_message_from_selection
|
||||
(EHTMLEditorView *view,
|
||||
gboolean value);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* E_HTML_EDITOR_VIEW_H */
|
||||
|
||||
@ -1866,6 +1866,10 @@ e_mail_reader_reply_to_message (EMailReader *reader,
|
||||
header = header->next;
|
||||
}
|
||||
|
||||
camel_medium_add_header (
|
||||
CAMEL_MEDIUM (new_message),
|
||||
"X-Evolution-Content-Source", "selection");
|
||||
|
||||
camel_mime_part_set_encoding (
|
||||
CAMEL_MIME_PART (new_message),
|
||||
CAMEL_TRANSFER_ENCODING_8BIT);
|
||||
|
||||
@ -2932,6 +2932,7 @@ em_utils_reply_to_message (EShell *shell,
|
||||
EMsgComposer *composer;
|
||||
ESource *source;
|
||||
gchar *identity_uid = NULL;
|
||||
const gchar *evo_source_header;
|
||||
guint32 flags;
|
||||
|
||||
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
|
||||
@ -3000,6 +3001,18 @@ em_utils_reply_to_message (EShell *shell,
|
||||
g_object_unref (to);
|
||||
g_object_unref (cc);
|
||||
|
||||
evo_source_header = camel_medium_get_header (
|
||||
CAMEL_MEDIUM (message), "X-Evolution-Content-Source");
|
||||
if (g_strcmp0 (evo_source_header, "selection") == 0) {
|
||||
EHTMLEditor *editor;
|
||||
EHTMLEditorView *view;
|
||||
|
||||
editor = e_msg_composer_get_editor (composer);
|
||||
view = e_html_editor_get_view (editor);
|
||||
|
||||
e_html_editor_view_set_is_message_from_selection (view, TRUE);
|
||||
}
|
||||
|
||||
composer_set_body (composer, message, style, parts_list);
|
||||
|
||||
if (folder != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user