[evolution/gnome-3-20] EHTMLEditorView - Correct the situations when the 'Lose formatting' dialog is showed
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-20] EHTMLEditorView - Correct the situations when the 'Lose formatting' dialog is showed
- Date: Tue, 28 Jun 2016 14:38:27 +0000 (UTC)
commit 65a209a8da493aa3e5f69ff37d2e0e6ff6cc7484
Author: Tomas Popela <tpopela redhat com>
Date: Tue Jun 28 11:12:52 2016 +0200
EHTMLEditorView - Correct the situations when the 'Lose formatting' dialog is showed
Don't show it when the message is a draft and show it when there are some of the
HTML elements that does not belong to plain text mode.
e-util/e-html-editor-view.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 105efce..8b29e40 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -11252,6 +11252,20 @@ toggle_unordered_lists (EHTMLEditorView *view)
g_object_unref (list);
}
+static gboolean
+needs_conversion (WebKitDOMDocument *document)
+{
+ WebKitDOMElement *element;
+
+ element = webkit_dom_document_query_selector (
+ document,
+ "b, i , u, table, hr, tt, font, sub, sup, h1, h2, h3, h4, h5, h6, "
+ "address, img:not([data-inline])",
+ NULL);
+
+ return element ? TRUE : FALSE;
+}
+
/**
* e_html_editor_view_set_html_mode:
* @view: an #EHTMLEditorView
@@ -11275,6 +11289,9 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
g_return_if_fail (E_IS_HTML_EDITOR_VIEW (view));
+ if (html_mode == view->priv->html_mode)
+ return;
+
selection = e_html_editor_view_get_selection (view);
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
@@ -11296,7 +11313,8 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
convert = convert && !is_from_new_message;
/* If toggling from HTML to plain text mode, ask user first */
- if (convert && view->priv->html_mode && !html_mode) {
+ if (!html_mode && (needs_conversion (document) ||
+ (convert && !view->priv->is_message_from_draft))) {
if (!show_lose_formatting_dialog (view))
return;
@@ -11309,9 +11327,6 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
goto out;
}
- if (html_mode == view->priv->html_mode)
- return;
-
view->priv->html_mode = html_mode;
/* Update fonts - in plain text we only want monospace */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]