[evolution/449-support-markdown-in-composer] EHTMLEditor: Properly update sensitivity of HTML actions & bindings after open
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/449-support-markdown-in-composer] EHTMLEditor: Properly update sensitivity of HTML actions & bindings after open
- Date: Wed, 9 Feb 2022 16:54:09 +0000 (UTC)
commit 068b3197304e81cf6f9bd01657bd2dbd3002f396
Author: Milan Crha <mcrha redhat com>
Date: Wed Feb 9 17:53:19 2022 +0100
EHTMLEditor: Properly update sensitivity of HTML actions & bindings after open
src/e-util/e-html-editor-actions.c | 25 +++++++++++++++++++++++--
src/e-util/e-html-editor.c | 4 ++++
2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/e-util/e-html-editor-actions.c b/src/e-util/e-html-editor-actions.c
index 797ad6ee44..aa6f664597 100644
--- a/src/e-util/e-html-editor-actions.c
+++ b/src/e-util/e-html-editor-actions.c
@@ -2339,6 +2339,25 @@ e_html_editor_indent_level_to_bool_unindent_cb (GBinding *binding,
return TRUE;
}
+static gboolean
+e_html_editor_sensitize_html_actions_cb (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ /* It should be editable... */
+ if (g_value_get_boolean (from_value)) {
+ EHTMLEditor *editor = user_data;
+
+ /* ... and in the HTML mode */
+ g_value_set_boolean (to_value, e_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML);
+ } else {
+ g_value_set_boolean (to_value, FALSE);
+ }
+
+ return TRUE;
+}
+
/**
* e_html_editor_util_new_mode_combobox:
*
@@ -2492,10 +2511,12 @@ e_html_editor_actions_bind (EHTMLEditor *editor)
cnt_editor, "editable",
editor->priv->core_editor_actions, "sensitive",
G_BINDING_SYNC_CREATE));
- rb (e_binding_bind_property (
+ rb (e_binding_bind_property_full (
cnt_editor, "editable",
editor->priv->html_actions, "sensitive",
- G_BINDING_SYNC_CREATE));
+ G_BINDING_SYNC_CREATE,
+ e_html_editor_sensitize_html_actions_cb,
+ NULL, editor, NULL));
rb (e_binding_bind_property (
cnt_editor, "editable",
editor->priv->spell_check_actions, "sensitive",
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index 07767f54e9..91fca9b100 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -1240,6 +1240,10 @@ e_html_editor_content_editor_initialized (EContentEditor *content_editor,
/* Synchronize widget mode with the buttons */
e_html_editor_set_mode (html_editor, E_CONTENT_EDITOR_MODE_HTML);
+ /* Make sure the actions did bind, even when the content editor did not change */
+ e_html_editor_actions_unbind (html_editor);
+ e_html_editor_actions_bind (html_editor);
+
g_object_set (G_OBJECT (content_editor),
"halign", GTK_ALIGN_FILL,
"hexpand", TRUE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]