[evolution/449-support-markdown-in-composer: 9/15] EHTMLEditor: Switch editor mode from boolean to enum value
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/449-support-markdown-in-composer: 9/15] EHTMLEditor: Switch editor mode from boolean to enum value
- Date: Tue, 8 Feb 2022 09:51:57 +0000 (UTC)
commit 83e4c7a99b3ebfb60a3325a4ac85d1356cf8b1c5
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 3 14:49:44 2022 +0100
EHTMLEditor: Switch editor mode from boolean to enum value
This helps to have different editor mode than just Plain Text and HTML.
Also prefer the mode on the EHTMLEditor, rather than the EContentEditor.
src/composer/e-composer-actions.c | 19 ++++-
src/composer/e-composer-private.c | 6 +-
src/composer/e-msg-composer.c | 37 ++++-----
src/e-util/e-content-editor.c | 38 +++------
src/e-util/e-content-editor.h | 3 -
src/e-util/e-html-editor-actions.c | 35 ++++----
src/e-util/e-html-editor-private.h | 2 +
src/e-util/e-html-editor.c | 95 ++++++++++++++++++++++
src/e-util/e-html-editor.h | 4 +
src/e-util/e-mail-signature-editor.c | 7 +-
src/e-util/e-mail-signature-manager.c | 4 +-
src/e-util/e-util-enums.h | 14 ++++
src/e-util/test-html-editor.c | 4 +-
src/mail/e-mail-notes.c | 22 +++--
src/mail/em-composer-utils.c | 15 ++--
.../composer-to-meeting/e-meeting-to-composer.c | 2 +-
src/modules/mail/e-mail-shell-backend.c | 11 ++-
src/modules/webkit-editor/e-webkit-editor.c | 81 +++++++++---------
18 files changed, 252 insertions(+), 147 deletions(-)
---
diff --git a/src/composer/e-composer-actions.c b/src/composer/e-composer-actions.c
index 5cb03cab94..9e59844936 100644
--- a/src/composer/e-composer-actions.c
+++ b/src/composer/e-composer-actions.c
@@ -558,6 +558,17 @@ static GtkToggleActionEntry toggle_entries[] = {
FALSE }
};
+static gboolean
+eca_transform_mode_html_to_boolean_cb (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer not_used)
+{
+ g_value_set_boolean (target_value, g_value_get_enum (source_value) == E_CONTENT_EDITOR_MODE_HTML);
+
+ return TRUE;
+}
+
void
e_composer_actions_init (EMsgComposer *composer)
{
@@ -676,10 +687,12 @@ e_composer_actions_init (EMsgComposer *composer)
g_object_unref (gcr_gnupg_icon);
}
- e_binding_bind_property (
- cnt_editor, "html-mode",
+ e_binding_bind_property_full (
+ editor, "mode",
ACTION (PICTURE_GALLERY), "sensitive",
- G_BINDING_SYNC_CREATE);
+ G_BINDING_SYNC_CREATE,
+ eca_transform_mode_html_to_boolean_cb,
+ NULL, NULL, NULL);
e_binding_bind_property (
cnt_editor, "editable",
diff --git a/src/composer/e-composer-private.c b/src/composer/e-composer-private.c
index f23b1d9b8f..23055d561f 100644
--- a/src/composer/e-composer-private.c
+++ b/src/composer/e-composer-private.c
@@ -62,14 +62,12 @@ static void
composer_update_gallery_visibility (EMsgComposer *composer)
{
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
GtkToggleAction *toggle_action;
gboolean gallery_active;
gboolean is_html;
editor = e_msg_composer_get_editor (composer);
- cnt_editor = e_html_editor_get_content_editor (editor);
- is_html = e_content_editor_get_html_mode (cnt_editor);
+ is_html = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML;
toggle_action = GTK_TOGGLE_ACTION (ACTION (PICTURE_GALLERY));
gallery_active = gtk_toggle_action_get_active (toggle_action);
@@ -372,7 +370,7 @@ e_composer_private_constructed (EMsgComposer *composer)
g_free (gallery_path);
e_signal_connect_notify_swapped (
- cnt_editor, "notify::html-mode",
+ editor, "notify::mode",
G_CALLBACK (composer_update_gallery_visibility), composer);
g_signal_connect_swapped (
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index aaa35c4652..5f22ed0bc4 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1207,18 +1207,20 @@ static void
composer_add_evolution_composer_mode_header (CamelMedium *medium,
EMsgComposer *composer)
{
- gboolean html_mode;
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
+ const gchar *mode = "text/plain";
editor = e_msg_composer_get_editor (composer);
- cnt_editor = e_html_editor_get_content_editor (editor);
- html_mode = e_content_editor_get_html_mode (cnt_editor);
+ switch (e_html_editor_get_mode (editor)) {
+ case E_CONTENT_EDITOR_MODE_PLAIN_TEXT:
+ mode = "text/plain";
+ break;
+ case E_CONTENT_EDITOR_MODE_HTML:
+ mode = "text/html";
+ break;
+ }
- camel_medium_add_header (
- medium,
- "X-Evolution-Composer-Mode",
- html_mode ? "text/html" : "text/plain");
+ camel_medium_add_header (medium, "X-Evolution-Composer-Mode", mode);
}
static void
@@ -1968,7 +1970,7 @@ msg_composer_paste_clipboard_targets_cb (GtkClipboard *clipboard,
editor = e_msg_composer_get_editor (composer);
cnt_editor = e_html_editor_get_content_editor (editor);
- if (!e_content_editor_get_html_mode (cnt_editor) &&
+ if (e_html_editor_get_mode (editor) != E_CONTENT_EDITOR_MODE_HTML &&
gtk_targets_include_image (targets, n_targets, TRUE)) {
e_composer_paste_image (composer, clipboard);
return;
@@ -2052,7 +2054,7 @@ msg_composer_drag_data_received_cb (GtkWidget *widget,
editor = e_msg_composer_get_editor (composer);
cnt_editor = e_html_editor_get_content_editor (editor);
- html_mode = e_content_editor_get_html_mode (cnt_editor);
+ html_mode = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML;
g_signal_handler_disconnect (cnt_editor, composer->priv->drag_data_received_handler_id);
composer->priv->drag_data_received_handler_id = 0;
@@ -3404,7 +3406,7 @@ e_msg_composer_check_inline_attachments (EMsgComposer *composer)
editor = e_msg_composer_get_editor (composer);
content_editor = e_html_editor_get_content_editor (editor);
- if (e_content_editor_get_html_mode (content_editor)) {
+ if (e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML) {
e_content_editor_get_content (content_editor, E_CONTENT_EDITOR_GET_INLINE_IMAGES,
"localhost", NULL, e_mg_composer_got_used_inline_images_cb, g_object_ref (composer));
} else {
@@ -4124,7 +4126,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
gboolean html_mode;
html_mode = composer_mode && !g_ascii_strcasecmp (composer_mode, "text/html");
- e_content_editor_set_html_mode (cnt_editor, html_mode);
+ e_html_editor_set_mode (editor, html_mode ? E_CONTENT_EDITOR_MODE_HTML :
E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
} else if (g_ascii_strcasecmp (flags[i], "pgp-sign") == 0) {
action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
gtk_toggle_action_set_active (action, TRUE);
@@ -5493,7 +5495,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
content = _("The composer contains a non-text message body, which cannot be edited.");
set_editor_text (composer, content, TRUE, FALSE);
- e_content_editor_set_html_mode (cnt_editor, FALSE);
+ e_html_editor_set_mode (editor, E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
e_content_editor_set_editable (cnt_editor, FALSE);
g_free (priv->mime_body);
@@ -5872,12 +5874,10 @@ e_msg_composer_get_message (EMsgComposer *composer,
GtkAction *action;
ComposerFlags flags = 0;
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
editor = e_msg_composer_get_editor (composer);
- cnt_editor = e_html_editor_get_content_editor (editor);
simple = g_simple_async_result_new (
G_OBJECT (composer), callback,
@@ -5885,7 +5885,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
g_simple_async_result_set_check_cancellable (simple, cancellable);
- if (e_content_editor_get_html_mode (cnt_editor))
+ if (e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML)
flags |= COMPOSER_FLAG_HTML_CONTENT;
action = ACTION (PRIORITIZE_MESSAGE);
@@ -5997,7 +5997,6 @@ e_msg_composer_get_message_draft (EMsgComposer *composer,
gpointer user_data)
{
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
GSimpleAsyncResult *simple;
ComposerFlags flags = COMPOSER_FLAG_SAVE_DRAFT;
GtkAction *action;
@@ -6011,9 +6010,9 @@ e_msg_composer_get_message_draft (EMsgComposer *composer,
g_simple_async_result_set_check_cancellable (simple, cancellable);
editor = e_msg_composer_get_editor (composer);
- cnt_editor = e_html_editor_get_content_editor (editor);
+
/* We need to remember composer mode */
- if (e_content_editor_get_html_mode (cnt_editor))
+ if (e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML)
flags |= COMPOSER_FLAG_HTML_MODE;
/* We want to save HTML content everytime when we save as draft */
flags |= COMPOSER_FLAG_SAVE_DRAFT;
diff --git a/src/e-util/e-content-editor.c b/src/e-util/e-content-editor.c
index dd01adb92a..3f2d8083a0 100644
--- a/src/e-util/e-content-editor.c
+++ b/src/e-util/e-content-editor.c
@@ -174,17 +174,20 @@ e_content_editor_default_init (EContentEditorInterface *iface)
G_PARAM_STATIC_STRINGS));
/**
- * EContentEditor:html-mode
+ * EContentEditor:mode
*
- * Determines whether HTML or plain text mode is enabled.
+ * Determines the mode of the content editor, as one of the #EContentEditorMode.
+ *
+ * Since: 3.44
**/
g_object_interface_install_property (
iface,
- g_param_spec_boolean (
- "html-mode",
- "HTML Mode",
- "Edit HTML or plain text",
- TRUE,
+ g_param_spec_enum (
+ "mode",
+ "Mode",
+ "Editor mode",
+ E_TYPE_CONTENT_EDITOR_MODE,
+ E_CONTENT_EDITOR_MODE_PLAIN_TEXT,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
@@ -809,27 +812,6 @@ e_content_editor_set_changed (EContentEditor *editor,
g_object_set (G_OBJECT (editor), "changed", changed, NULL);
}
-gboolean
-e_content_editor_get_html_mode (EContentEditor *editor)
-{
- gboolean value = FALSE;
-
- g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
-
- g_object_get (G_OBJECT (editor), "html-mode", &value, NULL);
-
- return value;
-}
-
-void
-e_content_editor_set_html_mode (EContentEditor *editor,
- gboolean html_mode)
-{
- g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
-
- g_object_set (G_OBJECT (editor), "html-mode", html_mode, NULL);
-}
-
/**
* e_content_editor_set_alignment:
* @editor: an #EContentEditor
diff --git a/src/e-util/e-content-editor.h b/src/e-util/e-content-editor.h
index a377f5f1c0..630d5c398c 100644
--- a/src/e-util/e-content-editor.h
+++ b/src/e-util/e-content-editor.h
@@ -452,9 +452,6 @@ void e_content_editor_set_editable (EContentEditor *editor,
gboolean e_content_editor_get_changed (EContentEditor *editor);
void e_content_editor_set_changed (EContentEditor *editor,
gboolean changed);
-gboolean e_content_editor_get_html_mode (EContentEditor *editor);
-void e_content_editor_set_html_mode (EContentEditor *editor,
- gboolean html_mode);
void e_content_editor_set_alignment (EContentEditor *editor,
EContentEditorAlignment value);
EContentEditorAlignment
diff --git a/src/e-util/e-html-editor-actions.c b/src/e-util/e-html-editor-actions.c
index 061baf6f9f..20061ca9a1 100644
--- a/src/e-util/e-html-editor-actions.c
+++ b/src/e-util/e-html-editor-actions.c
@@ -607,21 +607,17 @@ update_mode_combobox (gpointer data)
{
GWeakRef *weak_ref = data;
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
+ EContentEditorMode mode;
GtkAction *action;
- gboolean is_html;
editor = g_weak_ref_get (weak_ref);
if (!editor)
return FALSE;
- cnt_editor = e_html_editor_get_content_editor (editor);
- is_html = e_content_editor_get_html_mode (cnt_editor);
+ mode = e_html_editor_get_mode (editor);
- action = gtk_action_group_get_action (
- editor->priv->core_editor_actions, "mode-html");
- gtk_radio_action_set_current_value (
- GTK_RADIO_ACTION (action), (is_html ? 1 : 0));
+ action = gtk_action_group_get_action (editor->priv->core_editor_actions, "mode-html");
+ gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), mode);
g_object_unref (editor);
@@ -629,18 +625,17 @@ update_mode_combobox (gpointer data)
}
static void
-html_editor_actions_notify_html_mode_cb (EContentEditor *cnt_editor,
- GParamSpec *param,
- EHTMLEditor *editor)
+html_editor_actions_notify_mode_cb (EHTMLEditor *editor,
+ GParamSpec *param,
+ gpointer user_data)
{
GtkActionGroup *action_group;
GtkWidget *style_combo_box;
gboolean is_html;
- g_return_if_fail (E_IS_CONTENT_EDITOR (cnt_editor));
g_return_if_fail (E_IS_HTML_EDITOR (editor));
- is_html = e_content_editor_get_html_mode (cnt_editor);
+ is_html = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML;
g_object_set (G_OBJECT (editor->priv->html_actions), "sensitive", is_html, NULL);
@@ -793,7 +788,7 @@ action_paste_quote_cb (GtkAction *action,
gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
- if (e_content_editor_get_html_mode (cnt_editor)) {
+ if (e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML) {
if (e_clipboard_wait_is_html_available (clipboard))
e_clipboard_request_html (clipboard, clipboard_html_received_for_paste_quote, editor);
else if (gtk_clipboard_wait_is_text_available (clipboard))
@@ -1319,14 +1314,14 @@ static GtkRadioActionEntry core_mode_entries[] = {
N_("_HTML"),
NULL,
N_("HTML editing mode"),
- TRUE }, /* e_content_editor_set_html_mode */
+ E_CONTENT_EDITOR_MODE_HTML }, /* e_html_editor_set_mode */
{ "mode-plain",
NULL,
N_("Plain _Text"),
NULL,
N_("Plain text editing mode"),
- FALSE } /* e_content_editor_set_html_mode */
+ E_CONTENT_EDITOR_MODE_PLAIN_TEXT } /* e_html_editor_set_mode */
};
static GtkRadioActionEntry core_style_entries[] = {
@@ -2316,12 +2311,12 @@ editor_actions_bind (EHTMLEditor *editor)
action_group = editor->priv->core_editor_actions;
action = gtk_action_group_get_action (action_group, "mode-html");
e_binding_bind_property (
- cnt_editor, "html-mode",
+ editor, "mode",
action, "current-value",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
/* Synchronize widget mode with the buttons */
- e_content_editor_set_html_mode (cnt_editor, TRUE);
+ e_html_editor_set_mode (editor, E_CONTENT_EDITOR_MODE_HTML);
e_binding_bind_property (
cnt_editor, "can-redo",
@@ -2408,8 +2403,8 @@ editor_actions_bind (EHTMLEditor *editor)
g_signal_connect_object (cnt_editor, "notify::superscript",
G_CALLBACK (html_editor_actions_notify_superscript_cb), editor, 0);
- g_signal_connect_object (cnt_editor, "notify::html-mode",
- G_CALLBACK (html_editor_actions_notify_html_mode_cb), editor, 0);
+ g_signal_connect_object (editor, "notify::mode",
+ G_CALLBACK (html_editor_actions_notify_mode_cb), editor, 0);
/* Disable all actions and toolbars when editor is not editable */
e_binding_bind_property (
diff --git a/src/e-util/e-html-editor-private.h b/src/e-util/e-html-editor-private.h
index 032b77cdb3..50bbdc158d 100644
--- a/src/e-util/e-html-editor-private.h
+++ b/src/e-util/e-html-editor-private.h
@@ -47,6 +47,8 @@
G_BEGIN_DECLS
struct _EHTMLEditorPrivate {
+ EContentEditorMode mode;
+
GtkUIManager *manager;
GtkActionGroup *core_actions;
GtkActionGroup *core_editor_actions;
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 04a6434a6e..dc16262cb6 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -36,6 +36,7 @@
#include "e-content-editor.h"
#include "e-misc-utils.h"
#include "e-simple-async-result.h"
+#include "e-util-enumtypes.h"
#define E_HTML_EDITOR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -70,6 +71,7 @@
enum {
PROP_0,
+ PROP_MODE,
PROP_FILENAME,
PROP_PASTE_PLAIN_PREFER_PRE
};
@@ -767,6 +769,12 @@ html_editor_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_MODE:
+ e_html_editor_set_mode (
+ E_HTML_EDITOR (object),
+ g_value_get_enum (value));
+ return;
+
case PROP_FILENAME:
e_html_editor_set_filename (
E_HTML_EDITOR (object),
@@ -790,6 +798,12 @@ html_editor_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_MODE:
+ g_value_set_enum (
+ value, e_html_editor_get_mode (
+ E_HTML_EDITOR (object)));
+ return;
+
case PROP_FILENAME:
g_value_set_string (
value, e_html_editor_get_filename (
@@ -1049,6 +1063,19 @@ e_html_editor_class_init (EHTMLEditorClass *class)
class->update_actions = html_editor_update_actions;
class->spell_languages_changed = html_editor_spell_languages_changed;
+ g_object_class_install_property (
+ object_class,
+ PROP_MODE,
+ g_param_spec_enum (
+ "mode",
+ NULL,
+ NULL,
+ E_TYPE_CONTENT_EDITOR_MODE,
+ E_CONTENT_EDITOR_MODE_HTML,
+ G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (
object_class,
PROP_FILENAME,
@@ -1226,6 +1253,25 @@ e_html_editor_new_finish (GAsyncResult *result,
return e_simple_async_result_steal_user_data (eresult);
}
+static void
+e_html_editor_content_editor_notify_mode_cb (GObject *object,
+ GParamSpec *param,
+ gpointer user_data)
+{
+ EHTMLEditor *editor = user_data;
+
+ g_return_if_fail (E_IS_HTML_EDITOR (editor));
+ g_return_if_fail (E_IS_CONTENT_EDITOR (object));
+
+ if (E_CONTENT_EDITOR (object) == e_html_editor_get_content_editor (editor)) {
+ EContentEditorMode mode = E_CONTENT_EDITOR_MODE_PLAIN_TEXT;
+
+ g_object_get (object, "mode", &mode, NULL);
+
+ e_html_editor_set_mode (editor, mode);
+ }
+}
+
/**
* e_html_editor_get_content_editor:
* @editor: an #EHTMLEditor
@@ -1271,6 +1317,9 @@ e_html_editor_get_content_editor (EHTMLEditor *editor)
g_signal_connect_swapped (editor->priv->use_content_editor, "ref-mime-part",
G_CALLBACK (e_html_editor_ref_cid_part), editor);
+
+ e_signal_connect_notify (editor->priv->use_content_editor, "notify::mode",
+ G_CALLBACK (e_html_editor_content_editor_notify_mode_cb), editor);
}
}
@@ -1321,6 +1370,52 @@ e_html_editor_register_content_editor (EHTMLEditor *editor,
}
}
+/**
+ * e_html_editor_get_mode:
+ * @editor: an #EHTMLEditor
+ *
+ * Returns: Current editor mode, as an #EContentEditorMode
+ *
+ * Since: 3.44
+ **/
+EContentEditorMode
+e_html_editor_get_mode (EHTMLEditor *editor)
+{
+ g_return_val_if_fail (E_IS_HTML_EDITOR (editor), E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
+
+ return editor->priv->mode;
+}
+
+/**
+ * e_html_editor_set_mode:
+ * @editor: an #EHTMLEditor
+ * @mode: an #EContentEditorMode
+ *
+ * Sets the editor mode.
+ *
+ * Since: 3.44
+ **/
+void
+e_html_editor_set_mode (EHTMLEditor *editor,
+ EContentEditorMode mode)
+{
+ EContentEditor *cnt_editor;
+
+ g_return_if_fail (E_IS_HTML_EDITOR (editor));
+
+ if (editor->priv->mode == mode)
+ return;
+
+ editor->priv->mode = mode;
+
+ cnt_editor = e_html_editor_get_content_editor (editor);
+
+ if (cnt_editor)
+ g_object_set (G_OBJECT (cnt_editor), "mode", mode, NULL);
+
+ g_object_notify (G_OBJECT (editor), "mode");
+}
+
/**
* e_html_editor_get_ui_manager:
* @editor: an #EHTMLEditor
diff --git a/src/e-util/e-html-editor.h b/src/e-util/e-html-editor.h
index b96ab542f9..a2afa8c1d9 100644
--- a/src/e-util/e-html-editor.h
+++ b/src/e-util/e-html-editor.h
@@ -85,6 +85,10 @@ void e_html_editor_register_content_editor
(EHTMLEditor *editor,
const gchar *name,
EContentEditor *cnt_editor);
+EContentEditorMode
+ e_html_editor_get_mode (EHTMLEditor *editor);
+void e_html_editor_set_mode (EHTMLEditor *editor,
+ EContentEditorMode mode);
GtkBuilder * e_html_editor_get_builder (EHTMLEditor *editor);
GtkUIManager * e_html_editor_get_ui_manager (EHTMLEditor *editor);
GtkAction * e_html_editor_get_action (EHTMLEditor *editor,
diff --git a/src/e-util/e-mail-signature-editor.c b/src/e-util/e-mail-signature-editor.c
index 38d8d2a729..e3789a1999 100644
--- a/src/e-util/e-mail-signature-editor.c
+++ b/src/e-util/e-mail-signature-editor.c
@@ -151,11 +151,11 @@ mail_signature_editor_loaded_cb (GObject *object,
editor = e_mail_signature_editor_get_editor (window);
cnt_editor = e_html_editor_get_content_editor (editor);
- e_content_editor_set_html_mode (cnt_editor, is_html);
+ e_html_editor_set_mode (editor, is_html ? E_CONTENT_EDITOR_MODE_HTML :
E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
if (is_html) {
if (strstr (contents, "data-evo-signature-plain-text-mode"))
- e_content_editor_set_html_mode (cnt_editor, FALSE);
+ e_html_editor_set_mode (editor, E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
e_content_editor_insert_content (
cnt_editor,
@@ -981,7 +981,8 @@ e_mail_signature_editor_commit (EMailSignatureEditor *window,
async_context = g_slice_new0 (AsyncContext);
async_context->registry = g_object_ref (registry);
async_context->source = g_object_ref (source);
- async_context->contents_flag = e_content_editor_get_html_mode (cnt_editor) ?
E_CONTENT_EDITOR_GET_RAW_BODY_HTML : E_CONTENT_EDITOR_GET_TO_SEND_PLAIN;
+ async_context->contents_flag = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML ?
+ E_CONTENT_EDITOR_GET_RAW_BODY_HTML : E_CONTENT_EDITOR_GET_TO_SEND_PLAIN;
if (G_IS_CANCELLABLE (cancellable))
async_context->cancellable = g_object_ref (cancellable);
diff --git a/src/e-util/e-mail-signature-manager.c b/src/e-util/e-mail-signature-manager.c
index b414828d1f..97b0df43a8 100644
--- a/src/e-util/e-mail-signature-manager.c
+++ b/src/e-util/e-mail-signature-manager.c
@@ -396,7 +396,6 @@ mail_signature_manager_editor_created_add_signature_cb (GObject *source_object,
{
EMailSignatureManager *manager = user_data;
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
GtkWidget *widget;
GError *error = NULL;
@@ -411,8 +410,7 @@ mail_signature_manager_editor_created_add_signature_cb (GObject *source_object,
}
editor = e_mail_signature_editor_get_editor (E_MAIL_SIGNATURE_EDITOR (widget));
- cnt_editor = e_html_editor_get_content_editor (editor);
- e_content_editor_set_html_mode (cnt_editor, manager->priv->prefer_html);
+ e_html_editor_set_mode (editor, manager->priv->prefer_html ? E_CONTENT_EDITOR_MODE_HTML :
E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
mail_signature_manager_emit_editor_created (manager, widget);
diff --git a/src/e-util/e-util-enums.h b/src/e-util/e-util-enums.h
index 2a32dfa8bb..c30cb51a52 100644
--- a/src/e-util/e-util-enums.h
+++ b/src/e-util/e-util-enums.h
@@ -525,6 +525,20 @@ typedef enum {
E_CONTENT_EDITOR_FIND_WRAP_AROUND = 1 << 4
} EContentEditorFindFlags;
+/**
+ * EContentEditorMode:
+ * @E_CONTENT_EDITOR_MODE_PLAIN_TEXT: plain text, expects export as text/plain
+ * @E_CONTENT_EDITOR_MODE_HTML: HTML, expects export as text/html
+ *
+ * Editing mode of a content editor.
+ *
+ * Since: 3.44
+ **/
+typedef enum {
+ E_CONTENT_EDITOR_MODE_PLAIN_TEXT,
+ E_CONTENT_EDITOR_MODE_HTML
+} EContentEditorMode;
+
/**
* EUndoRedoState:
* @E_UNDO_REDO_STATE_NONE: Cannot undo, neither redo.
diff --git a/src/e-util/test-html-editor.c b/src/e-util/test-html-editor.c
index 7dd5765be4..03da2690cc 100644
--- a/src/e-util/test-html-editor.c
+++ b/src/e-util/test-html-editor.c
@@ -344,7 +344,7 @@ action_save_cb (GtkAction *action,
return;
filename = e_html_editor_get_filename (editor);
- as_html = (e_content_editor_get_html_mode (e_html_editor_get_content_editor (editor)));
+ as_html = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML;
e_html_editor_save (editor, filename, as_html, NULL, html_editor_save_done_cb, NULL);
}
@@ -360,7 +360,7 @@ action_save_as_cb (GtkAction *action,
return;
filename = e_html_editor_get_filename (editor);
- as_html = (e_content_editor_get_html_mode (e_html_editor_get_content_editor (editor)));
+ as_html = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML;
e_html_editor_save (editor, filename, as_html, NULL, html_editor_save_done_cb, NULL);
}
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index a4fe577690..e7b7a9780c 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -92,7 +92,8 @@ e_mail_notes_extract_text_content (CamelMimePart *part)
}
static void
-e_mail_notes_extract_text_from_multipart_alternative (EContentEditor *cnt_editor,
+e_mail_notes_extract_text_from_multipart_alternative (EHTMLEditor *editor,
+ EContentEditor *cnt_editor,
CamelMultipart *in_multipart)
{
guint ii, nparts;
@@ -120,7 +121,7 @@ e_mail_notes_extract_text_from_multipart_alternative (EContentEditor *cnt_editor
text = e_mail_notes_extract_text_content (part);
if (text) {
- e_content_editor_set_html_mode (cnt_editor, TRUE);
+ e_html_editor_set_mode (editor, E_CONTENT_EDITOR_MODE_HTML);
e_content_editor_insert_content (
cnt_editor,
text,
@@ -176,7 +177,7 @@ e_mail_notes_editor_extract_text_from_multipart_related (EMailNotesEditor *notes
content = camel_medium_get_content (CAMEL_MEDIUM (part));
if (CAMEL_IS_MULTIPART (content)) {
- e_mail_notes_extract_text_from_multipart_alternative (
+ e_mail_notes_extract_text_from_multipart_alternative (notes_editor->editor,
e_html_editor_get_content_editor (notes_editor->editor),
CAMEL_MULTIPART (content));
}
}
@@ -208,7 +209,7 @@ e_mail_notes_editor_extract_text_from_part (EMailNotesEditor *notes_editor,
e_mail_notes_editor_extract_text_from_multipart_related (notes_editor, CAMEL_MULTIPART
(content));
} else if (camel_content_type_is (ct, "multipart", "alternative")) {
if (CAMEL_IS_MULTIPART (content)) {
- e_mail_notes_extract_text_from_multipart_alternative (cnt_editor, CAMEL_MULTIPART
(content));
+ e_mail_notes_extract_text_from_multipart_alternative (notes_editor->editor,
cnt_editor, CAMEL_MULTIPART (content));
}
} else if (camel_content_type_is (ct, "text", "plain")) {
gchar *text;
@@ -328,7 +329,7 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
attachment_store = e_attachment_view_get_store (E_ATTACHMENT_VIEW (notes_editor->attachment_paned));
has_attachments = e_attachment_store_get_num_attachments (attachment_store) > 0;
- if (e_content_editor_get_html_mode (cnt_editor)) {
+ if (e_html_editor_get_mode (notes_editor->editor) == E_CONTENT_EDITOR_MODE_HTML) {
CamelMultipart *multipart_alternative;
CamelMultipart *multipart_body;
CamelMimePart *part;
@@ -974,9 +975,12 @@ static void
set_preformatted_block_format_on_load_finished_cb (EContentEditor *cnt_editor,
gpointer user_data)
{
+ EHTMLEditor *editor = user_data;
+
+ g_return_if_fail (E_IS_HTML_EDITOR (editor));
g_return_if_fail (E_IS_CONTENT_EDITOR (cnt_editor));
- if (!e_content_editor_get_html_mode (cnt_editor)) {
+ if (e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_PLAIN_TEXT) {
e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
e_content_editor_set_changed (cnt_editor, FALSE);
e_content_editor_clear_undo_redo_history (cnt_editor);
@@ -1138,10 +1142,10 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
gtk_widget_grab_focus (GTK_WIDGET (cnt_editor));
settings = e_util_ref_settings ("org.gnome.evolution.mail");
- e_content_editor_set_html_mode (cnt_editor, g_settings_get_boolean (settings, "composer-send-html"));
+ e_html_editor_set_mode (html_editor, g_settings_get_boolean (settings, "composer-send-html") ?
E_CONTENT_EDITOR_MODE_HTML : E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
if (g_settings_get_boolean (settings, "composer-plain-text-starts-preformatted")) {
- g_signal_connect (cnt_editor, "load-finished",
- G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), NULL);
+ g_signal_connect_object (cnt_editor, "load-finished",
+ G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), html_editor, 0);
}
g_object_unref (settings);
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index 33d29d99ef..cf55c3c955 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -552,7 +552,6 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
{
EDestination **recipients;
EHTMLEditor *editor;
- EContentEditor *cnt_editor;
EComposerHeaderTable *table;
GSettings *settings;
gboolean check_passed = TRUE;
@@ -564,8 +563,7 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
settings = e_util_ref_settings ("org.gnome.evolution.mail");
editor = e_msg_composer_get_editor (composer);
- cnt_editor = e_html_editor_get_content_editor (editor);
- html_mode = e_content_editor_get_html_mode (cnt_editor);
+ html_mode = e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML;
table = e_msg_composer_get_header_table (composer);
recipients = e_composer_header_table_get_destinations (table);
@@ -2582,7 +2580,7 @@ forward_non_attached (EMsgComposer *composer,
E_MAIL_FORMATTER_QUOTE_FLAG_KEEP_SIG;
if (style == E_MAIL_FORWARD_STYLE_QUOTED)
flags |= E_MAIL_FORMATTER_QUOTE_FLAG_CITE;
- if (!e_content_editor_get_html_mode (e_html_editor_get_content_editor (e_msg_composer_get_editor
(composer))))
+ if (e_html_editor_get_mode (e_msg_composer_get_editor (composer)) != E_CONTENT_EDITOR_MODE_HTML)
flags |= E_MAIL_FORMATTER_QUOTE_FLAG_NO_FORMATTING;
/* Setup composer's From account before calling quoting_text() and
@@ -3855,9 +3853,9 @@ alt_reply_composer_created_cb (GObject *source_object,
composer = e_msg_composer_new_finish (result, &error);
if (composer) {
- EContentEditor *cnt_editor;
+ EHTMLEditor *editor;
- cnt_editor = e_html_editor_get_content_editor (e_msg_composer_get_editor (composer));
+ editor = e_msg_composer_get_editor (composer);
if (context->new_message) {
CamelInternetAddress *to = NULL, *cc = NULL;
@@ -3873,7 +3871,7 @@ alt_reply_composer_created_cb (GObject *source_object,
}
if ((context->flags & (E_MAIL_REPLY_FLAG_FORMAT_PLAIN |
E_MAIL_REPLY_FLAG_FORMAT_HTML)) != 0) {
- e_content_editor_set_html_mode (cnt_editor, (context->flags &
E_MAIL_REPLY_FLAG_FORMAT_HTML) != 0);
+ e_html_editor_set_mode (editor, (context->flags &
E_MAIL_REPLY_FLAG_FORMAT_HTML) != 0 ? E_CONTENT_EDITOR_MODE_HTML : E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
}
em_utils_edit_message (composer, context->folder, context->new_message,
context->message_uid, TRUE, FALSE);
@@ -4598,7 +4596,8 @@ em_utils_reply_to_message (EMsgComposer *composer,
cnt_editor = e_html_editor_get_content_editor (e_msg_composer_get_editor (composer));
if ((reply_flags & (E_MAIL_REPLY_FLAG_FORMAT_PLAIN | E_MAIL_REPLY_FLAG_FORMAT_HTML)) != 0) {
- e_content_editor_set_html_mode (cnt_editor, (reply_flags & E_MAIL_REPLY_FLAG_FORMAT_HTML) !=
0);
+ e_html_editor_set_mode (e_msg_composer_get_editor (composer),
+ (reply_flags & E_MAIL_REPLY_FLAG_FORMAT_HTML) != 0 ? E_CONTENT_EDITOR_MODE_HTML :
E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
}
em_utils_update_by_reply_flags (cnt_editor, reply_flags);
diff --git a/src/modules/composer-to-meeting/e-meeting-to-composer.c
b/src/modules/composer-to-meeting/e-meeting-to-composer.c
index 0335a9cdde..4c8a1e363d 100644
--- a/src/modules/composer-to-meeting/e-meeting-to-composer.c
+++ b/src/modules/composer-to-meeting/e-meeting-to-composer.c
@@ -302,7 +302,7 @@ meeting_to_composer_composer_created_cb (GObject *source_object,
html_editor = e_msg_composer_get_editor (composer);
cnt_editor = e_html_editor_get_content_editor (html_editor);
- e_content_editor_set_html_mode (cnt_editor, FALSE);
+ e_html_editor_set_mode (html_editor, E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
e_content_editor_insert_content (cnt_editor, text,
E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_PLAIN);
}
diff --git a/src/modules/mail/e-mail-shell-backend.c b/src/modules/mail/e-mail-shell-backend.c
index 0cb48eb40e..049a6fd536 100644
--- a/src/modules/mail/e-mail-shell-backend.c
+++ b/src/modules/mail/e-mail-shell-backend.c
@@ -720,9 +720,12 @@ static void
set_preformatted_block_format_on_load_finished_cb (EContentEditor *cnt_editor,
gpointer user_data)
{
+ EHTMLEditor *editor = user_data;
+
+ g_return_if_fail (E_IS_HTML_EDITOR (editor));
g_return_if_fail (E_IS_CONTENT_EDITOR (cnt_editor));
- if (!e_content_editor_get_html_mode (cnt_editor)) {
+ if (e_html_editor_get_mode (editor) != E_CONTENT_EDITOR_MODE_HTML) {
e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
e_content_editor_set_changed (cnt_editor, FALSE);
e_content_editor_clear_undo_redo_history (cnt_editor);
@@ -768,11 +771,11 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
g_object_unref (settings);
- e_content_editor_set_html_mode (cnt_editor, use_html);
+ e_html_editor_set_mode (editor, use_html ? E_CONTENT_EDITOR_MODE_HTML :
E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
if (use_preformatted) {
- g_signal_connect (cnt_editor, "load-finished",
- G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), NULL);
+ g_signal_connect_object (cnt_editor, "load-finished",
+ G_CALLBACK (set_preformatted_block_format_on_load_finished_cb), editor, 0);
}
}
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 1042cc1bcd..314a124e37 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -44,7 +44,7 @@ enum {
PROP_CAN_UNDO,
PROP_CHANGED,
PROP_EDITABLE,
- PROP_HTML_MODE,
+ PROP_MODE,
PROP_SPELL_CHECK_ENABLED,
PROP_SPELL_CHECKER,
PROP_START_BOTTOM,
@@ -82,7 +82,7 @@ struct _EWebKitEditorPrivate {
GHashTable *scheme_handlers; /* const gchar *scheme ~> EContentRequest */
GCancellable *cancellable;
- gboolean html_mode;
+ EContentEditorMode mode;
gboolean changed;
gboolean can_copy;
gboolean can_cut;
@@ -545,7 +545,7 @@ webkit_editor_dialog_utils_get_attribute_with_unit (EWebKitEditor *wk_editor,
*out_unit = E_CONTENT_EDITOR_UNIT_AUTO;
- if (!wk_editor->priv->html_mode)
+ if (wk_editor->priv->mode != E_CONTENT_EDITOR_MODE_HTML)
return default_value;
value = webkit_editor_dialog_utils_get_attribute (wk_editor, selector, name);
@@ -838,8 +838,8 @@ formatting_changed_cb (WebKitUserContentManager *manager,
if (jsc_value && jsc_value_is_number (jsc_value)) {
gint value = jsc_value_to_int32 (jsc_value);
- if ((value ? 1 : 0) != (wk_editor->priv->html_mode ? 1 : 0)) {
- wk_editor->priv->html_mode = value;
+ if ((value ? 1 : 0) != (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML ? 1 : 0)) {
+ wk_editor->priv->mode = value ? E_CONTENT_EDITOR_MODE_HTML :
E_CONTENT_EDITOR_MODE_PLAIN_TEXT;
changed = TRUE;
}
}
@@ -850,7 +850,7 @@ formatting_changed_cb (WebKitUserContentManager *manager,
webkit_editor_update_styles (E_CONTENT_EDITOR (wk_editor));
webkit_editor_style_updated (wk_editor, FALSE);
- g_object_notify (object, "html-mode");
+ g_object_notify (object, "mode");
}
changed = FALSE;
@@ -1194,7 +1194,7 @@ webkit_editor_update_styles (EContentEditor *editor)
ms = pango_font_description_from_string ("monospace 10");
}
- if (wk_editor->priv->html_mode) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML) {
if (use_custom_font) {
font = g_settings_get_string (
wk_editor->priv->mail_settings, "variable-width-font");
@@ -1315,7 +1315,7 @@ webkit_editor_update_styles (EContentEditor *editor)
" vertical-align: top;\n"
"}\n");
- if (wk_editor->priv->html_mode) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML) {
g_string_append (
stylesheet,
"body ul > li.-x-evo-align-center,ol > li.-x-evo-align-center "
@@ -1564,7 +1564,7 @@ webkit_editor_update_styles (EContentEditor *editor)
" -webkit-margin-after: 0em; \n"
"}\n");
- if (wk_editor->priv->html_mode) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML) {
g_string_append (
stylesheet,
"a "
@@ -1715,7 +1715,7 @@ webkit_editor_page_get_text_color (EContentEditor *editor,
{
EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
- if (wk_editor->priv->html_mode &&
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML &&
wk_editor->priv->body_fg_color) {
*color = *wk_editor->priv->body_fg_color;
} else {
@@ -1736,7 +1736,7 @@ webkit_editor_page_get_background_color (EContentEditor *editor,
{
EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
- if (wk_editor->priv->html_mode &&
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML &&
wk_editor->priv->body_bg_color) {
*color = *wk_editor->priv->body_bg_color;
} else {
@@ -1757,7 +1757,7 @@ webkit_editor_page_get_link_color (EContentEditor *editor,
{
EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
- if (wk_editor->priv->html_mode &&
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML &&
wk_editor->priv->body_link_color) {
*color = *wk_editor->priv->body_link_color;
} else {
@@ -1781,7 +1781,7 @@ webkit_editor_page_get_visited_link_color (EContentEditor *editor,
{
EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
- if (wk_editor->priv->html_mode &&
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML &&
wk_editor->priv->body_vlink_color) {
*color = *wk_editor->priv->body_vlink_color;
} else {
@@ -1808,7 +1808,7 @@ webkit_editor_page_get_font_name (EContentEditor *editor)
{
EWebKitEditor *wk_editor = E_WEBKIT_EDITOR (editor);
- if (!wk_editor->priv->html_mode)
+ if (wk_editor->priv->mode != E_CONTENT_EDITOR_MODE_HTML)
return NULL;
return wk_editor->priv->body_font_name;
@@ -1871,7 +1871,7 @@ webkit_editor_style_updated (EWebKitEditor *wk_editor,
style_context = gtk_widget_get_style_context (GTK_WIDGET (wk_editor));
backdrop = (state_flags & GTK_STATE_FLAG_BACKDROP) != 0;
- if (wk_editor->priv->html_mode && !inherit_theme_colors) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML && !inherit_theme_colors) {
/* Default to white background when not inheriting theme colors */
bgcolor.red = 1.0;
bgcolor.green = 1.0;
@@ -1884,7 +1884,7 @@ webkit_editor_style_updated (EWebKitEditor *wk_editor,
gdk_rgba_parse (&bgcolor, E_UTILS_DEFAULT_THEME_BASE_COLOR);
}
- if (wk_editor->priv->html_mode && !inherit_theme_colors) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML && !inherit_theme_colors) {
/* Default to black text color when not inheriting theme colors */
fgcolor.red = 0.0;
fgcolor.green = 0.0;
@@ -1942,10 +1942,10 @@ webkit_editor_style_updated_cb (EWebKitEditor *wk_editor)
webkit_editor_style_updated (wk_editor, FALSE);
}
-static gboolean
-webkit_editor_get_html_mode (EWebKitEditor *wk_editor)
+static EContentEditorMode
+webkit_editor_get_mode (EWebKitEditor *wk_editor)
{
- return wk_editor->priv->html_mode;
+ return wk_editor->priv->mode;
}
static gboolean
@@ -1966,7 +1966,7 @@ show_lose_formatting_dialog (EWebKitEditor *wk_editor)
if (!lose) {
/* Nothing has changed, but notify anyway */
- g_object_notify (G_OBJECT (wk_editor), "html-mode");
+ g_object_notify (G_OBJECT (wk_editor), "mode");
return FALSE;
}
@@ -1974,17 +1974,18 @@ show_lose_formatting_dialog (EWebKitEditor *wk_editor)
}
static void
-webkit_editor_set_html_mode (EWebKitEditor *wk_editor,
- gboolean html_mode)
+webkit_editor_set_mode (EWebKitEditor *wk_editor,
+ EContentEditorMode mode)
{
g_return_if_fail (E_IS_WEBKIT_EDITOR (wk_editor));
+ g_return_if_fail (mode == E_CONTENT_EDITOR_MODE_PLAIN_TEXT || mode == E_CONTENT_EDITOR_MODE_HTML);
- if (html_mode == wk_editor->priv->html_mode)
+ if (mode == wk_editor->priv->mode)
return;
- wk_editor->priv->html_mode = html_mode;
+ wk_editor->priv->mode = mode;
- if (html_mode) {
+ if (mode == E_CONTENT_EDITOR_MODE_HTML) {
e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor), wk_editor->priv->cancellable,
"EvoEditor.SetMode(EvoEditor.MODE_HTML);");
} else {
@@ -2041,11 +2042,11 @@ webkit_editor_insert_content (EContentEditor *editor,
}
/* Only convert messages that are in HTML */
- if (!(wk_editor->priv->html_mode)) {
+ if (wk_editor->priv->mode != E_CONTENT_EDITOR_MODE_HTML) {
if (strstr (content, "<!-- text/html -->") &&
!strstr (content, "<!-- disable-format-prompt -->")) {
if (!show_lose_formatting_dialog (wk_editor)) {
- webkit_editor_set_html_mode (wk_editor, TRUE);
+ webkit_editor_set_mode (wk_editor, E_CONTENT_EDITOR_MODE_HTML);
e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (wk_editor),
wk_editor->priv->cancellable,
"EvoEditor.LoadHTML(%s);", content);
if (cleanup_sig_id)
@@ -3477,7 +3478,7 @@ webkit_editor_get_font_name (EWebKitEditor *wk_editor)
{
g_return_val_if_fail (E_IS_WEBKIT_EDITOR (wk_editor), NULL);
- if (!wk_editor->priv->html_mode)
+ if (wk_editor->priv->mode != E_CONTENT_EDITOR_MODE_HTML)
return NULL;
return wk_editor->priv->font_name;
@@ -3506,7 +3507,7 @@ webkit_editor_get_font_color (EWebKitEditor *wk_editor)
{
g_return_val_if_fail (E_IS_WEBKIT_EDITOR (wk_editor), NULL);
- if (!wk_editor->priv->html_mode || !wk_editor->priv->font_color)
+ if (wk_editor->priv->mode != E_CONTENT_EDITOR_MODE_HTML || !wk_editor->priv->font_color)
return &black;
return wk_editor->priv->font_color;
@@ -4474,10 +4475,10 @@ webkit_editor_set_property (GObject *object,
g_value_get_boolean (value));
return;
- case PROP_HTML_MODE:
- webkit_editor_set_html_mode (
+ case PROP_MODE:
+ webkit_editor_set_mode (
E_WEBKIT_EDITOR (object),
- g_value_get_boolean (value));
+ g_value_get_enum (value));
return;
case PROP_NORMAL_PARAGRAPH_WIDTH:
@@ -4683,9 +4684,9 @@ webkit_editor_get_property (GObject *object,
E_WEBKIT_EDITOR (object)));
return;
- case PROP_HTML_MODE:
- g_value_set_boolean (
- value, webkit_editor_get_html_mode (
+ case PROP_MODE:
+ g_value_set_enum (
+ value, webkit_editor_get_mode (
E_WEBKIT_EDITOR (object)));
return;
@@ -5081,7 +5082,7 @@ webkit_editor_paste_clipboard_targets_cb (GtkClipboard *clipboard,
* with SRCSET attribute in clipboard correctly). And if this fails the
* source application can cancel the content and we could not fallback
* to at least some content. */
- if (wk_editor->priv->html_mode) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML) {
if (e_targets_include_html (targets, n_targets)) {
content = e_clipboard_wait_for_html (clipboard);
is_html = TRUE;
@@ -5096,7 +5097,7 @@ webkit_editor_paste_clipboard_targets_cb (GtkClipboard *clipboard,
}
}
- if (wk_editor->priv->html_mode &&
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML &&
gtk_targets_include_image (targets, n_targets, TRUE) &&
(!content || !*content || !is_libreoffice_content (targets, n_targets))) {
gchar *uri;
@@ -5441,7 +5442,7 @@ paste_primary_clipboard_quoted (EContentEditor *editor)
gdk_display_get_default (),
GDK_SELECTION_PRIMARY);
- if (wk_editor->priv->html_mode) {
+ if (wk_editor->priv->mode == E_CONTENT_EDITOR_MODE_HTML) {
if (e_clipboard_wait_is_html_available (clipboard))
e_clipboard_request_html (clipboard, clipboard_html_received_for_paste_quote, editor);
else if (gtk_clipboard_wait_is_text_available (clipboard))
@@ -5608,7 +5609,7 @@ e_webkit_editor_class_init (EWebKitEditorClass *class)
g_object_class_override_property (
object_class, PROP_CHANGED, "changed");
g_object_class_override_property (
- object_class, PROP_HTML_MODE, "html-mode");
+ object_class, PROP_MODE, "mode");
g_object_class_override_property (
object_class, PROP_EDITABLE, "editable");
g_object_class_override_property (
@@ -5821,7 +5822,7 @@ e_webkit_editor_init (EWebKitEditor *wk_editor)
g_settings, "changed::composer-inherit-theme-colors",
G_CALLBACK (webkit_editor_style_settings_changed_cb), wk_editor);
- wk_editor->priv->html_mode = TRUE;
+ wk_editor->priv->mode = E_CONTENT_EDITOR_MODE_HTML;
wk_editor->priv->changed = FALSE;
wk_editor->priv->can_copy = FALSE;
wk_editor->priv->can_cut = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]