[evolution/449-support-markdown-in-composer] Let mail notes and signature editor read/write markdown format



commit 2cb08752d9f63776843c926c5fdb94a94f7cf1ed
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 9 13:38:20 2022 +0100

    Let mail notes and signature editor read/write markdown format

 src/e-util/e-html-editor-actions.c   |   4 +-
 src/e-util/e-html-editor-private.h   |   1 +
 src/e-util/e-html-editor.c           |  50 +++++++++--
 src/e-util/e-mail-signature-editor.c |  46 +++++++++--
 src/e-util/e-markdown-editor.c       |   4 +-
 src/mail/e-mail-notes.c              | 156 ++++++++++++++++++++---------------
 6 files changed, 177 insertions(+), 84 deletions(-)
---
diff --git a/src/e-util/e-html-editor-actions.c b/src/e-util/e-html-editor-actions.c
index 226e85edba..657340d5f7 100644
--- a/src/e-util/e-html-editor-actions.c
+++ b/src/e-util/e-html-editor-actions.c
@@ -2471,8 +2471,8 @@ e_html_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 (editor, "notify::mode",
-               G_CALLBACK (html_editor_actions_notify_mode_cb), editor, 0);
+       g_signal_connect (editor, "notify::mode",
+               G_CALLBACK (html_editor_actions_notify_mode_cb), NULL);
 
        /* 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 8c95c57f95..45f44e69bd 100644
--- a/src/e-util/e-html-editor-private.h
+++ b/src/e-util/e-html-editor-private.h
@@ -98,6 +98,7 @@ struct _EHTMLEditorPrivate {
        GHashTable *content_editors; /* gchar *name ~> EContentEditor * */
        GHashTable *content_editors_for_mode; /* EContentEditorMode ~> EContentEditor *; pointers borrowed 
from content_editors */
        EContentEditor *use_content_editor;
+       GCancellable *mode_change_content_cancellable;
 
        gchar *filename;
 
diff --git a/src/e-util/e-html-editor.c b/src/e-util/e-html-editor.c
index fa10bc9eba..019a66ee5b 100644
--- a/src/e-util/e-html-editor.c
+++ b/src/e-util/e-html-editor.c
@@ -1042,6 +1042,9 @@ html_editor_dispose (GObject *object)
 
        priv = E_HTML_EDITOR_GET_PRIVATE (object);
 
+       if (priv->mode_change_content_cancellable)
+               g_cancellable_cancel (priv->mode_change_content_cancellable);
+
        g_clear_object (&priv->manager);
        g_clear_object (&priv->core_actions);
        g_clear_object (&priv->core_editor_actions);
@@ -1069,6 +1072,8 @@ html_editor_dispose (GObject *object)
        g_clear_object (&priv->font_name_combo_box);
        g_clear_object (&priv->style_combo_box);
 
+       g_clear_object (&priv->mode_change_content_cancellable);
+
        /* Chain up to parent's dispose() method. */
        G_OBJECT_CLASS (e_html_editor_parent_class)->dispose (object);
 }
@@ -1598,6 +1603,25 @@ e_html_editor_get_content_editor_name (EHTMLEditor *editor)
        return NULL;
 }
 
+static void
+e_html_editor_content_changed_cb (EContentEditor *cnt_editor,
+                                 gpointer user_data)
+{
+       EHTMLEditor *editor = user_data;
+
+       g_return_if_fail (E_IS_HTML_EDITOR (editor));
+
+       if (editor->priv->mode_change_content_cancellable) {
+               if (cnt_editor == editor->priv->use_content_editor) {
+                       g_cancellable_cancel (editor->priv->mode_change_content_cancellable);
+                       g_clear_object (&editor->priv->mode_change_content_cancellable);
+               }
+       }
+
+       g_signal_handlers_disconnect_by_func (cnt_editor,
+               G_CALLBACK (e_html_editor_content_changed_cb), editor);
+}
+
 void
 e_html_editor_register_content_editor (EHTMLEditor *editor,
                                       const gchar *name,
@@ -1639,6 +1663,8 @@ e_html_editor_update_content_on_mode_change_cb (GObject *source_object,
        if (!editor)
                return;
 
+       g_clear_object (&editor->priv->mode_change_content_cancellable);
+
        cnt_editor = E_CONTENT_EDITOR (source_object);
        content_hash = e_content_editor_get_content_finish (cnt_editor, result, NULL);
 
@@ -1708,6 +1734,11 @@ e_html_editor_set_mode (EHTMLEditor *editor,
        if (editor->priv->mode == mode)
                return;
 
+       if (editor->priv->mode_change_content_cancellable) {
+               g_cancellable_cancel (editor->priv->mode_change_content_cancellable);
+               g_clear_object (&editor->priv->mode_change_content_cancellable);
+       }
+
        cnt_editor = e_html_editor_get_content_editor_for_mode (editor, mode);
 
        if (cnt_editor) {
@@ -1718,14 +1749,17 @@ e_html_editor_set_mode (EHTMLEditor *editor,
                        if (editor->priv->use_content_editor) {
                                is_focused = e_content_editor_is_focus (editor->priv->use_content_editor);
 
-                               if (gtk_widget_get_realized (GTK_WIDGET (editor->priv->use_content_editor))) {
-                                       /* Transfer also the content between editors */
-                                       e_content_editor_get_content (editor->priv->use_content_editor,
-                                               E_CONTENT_EDITOR_GET_TO_SEND_HTML | 
E_CONTENT_EDITOR_GET_TO_SEND_PLAIN,
-                                               "localhost", NULL,
-                                               e_html_editor_update_content_on_mode_change_cb,
-                                               e_weak_ref_new (editor));
-                               }
+                               editor->priv->mode_change_content_cancellable = g_cancellable_new ();
+
+                               g_signal_connect_object (cnt_editor, "content-changed",
+                                       G_CALLBACK (e_html_editor_content_changed_cb), editor, 0);
+
+                               /* Transfer also the content between editors */
+                               e_content_editor_get_content (editor->priv->use_content_editor,
+                                       E_CONTENT_EDITOR_GET_TO_SEND_HTML | 
E_CONTENT_EDITOR_GET_TO_SEND_PLAIN,
+                                       "localhost", editor->priv->mode_change_content_cancellable,
+                                       e_html_editor_update_content_on_mode_change_cb,
+                                       e_weak_ref_new (editor));
 
                                gtk_widget_hide (GTK_WIDGET (editor->priv->use_content_editor));
 
diff --git a/src/e-util/e-mail-signature-editor.c b/src/e-util/e-mail-signature-editor.c
index 6f4361a05d..7d1d88342d 100644
--- a/src/e-util/e-mail-signature-editor.c
+++ b/src/e-util/e-mail-signature-editor.c
@@ -50,6 +50,7 @@ struct _AsyncContext {
        ESource *source;
        GCancellable *cancellable;
        EContentEditorGetContentFlags contents_flag;
+       EContentEditorMode editor_mode;
        gchar *contents;
        gsize length;
        GDestroyNotify destroy_contents;
@@ -108,13 +109,13 @@ mail_signature_editor_loaded_cb (GObject *object,
 {
        EHTMLEditor *editor;
        EContentEditor *cnt_editor;
+       EContentEditorMode mode;
        ESource *source;
        EMailSignatureEditor *window;
        ESourceMailSignature *extension;
        const gchar *extension_name;
        const gchar *mime_type;
        gchar *contents = NULL;
-       gboolean is_html;
        GError *error = NULL;
 
        source = E_SOURCE (object);
@@ -147,13 +148,22 @@ mail_signature_editor_loaded_cb (GObject *object,
        extension_name = E_SOURCE_EXTENSION_MAIL_SIGNATURE;
        extension = e_source_get_extension (source, extension_name);
        mime_type = e_source_mail_signature_get_mime_type (extension);
-       is_html = (g_strcmp0 (mime_type, "text/html") == 0);
+       if (g_strcmp0 (mime_type, "text/html") == 0)
+               mode = E_CONTENT_EDITOR_MODE_HTML;
+       else if (g_strcmp0 (mime_type, "text/markdown") == 0)
+               mode = E_CONTENT_EDITOR_MODE_MARKDOWN;
+       else if (g_strcmp0 (mime_type, "text/markdown-plain") == 0)
+               mode = E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT;
+       else if (g_strcmp0 (mime_type, "text/markdown-html") == 0)
+               mode = E_CONTENT_EDITOR_MODE_MARKDOWN_HTML;
+       else
+               mode = E_CONTENT_EDITOR_MODE_PLAIN_TEXT;
 
        editor = e_mail_signature_editor_get_editor (window);
+       e_html_editor_set_mode (editor, mode);
        cnt_editor = e_html_editor_get_content_editor (editor);
-       e_html_editor_set_mode (editor, is_html ? E_CONTENT_EDITOR_MODE_HTML : 
E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
 
-       if (is_html) {
+       if (mode == E_CONTENT_EDITOR_MODE_HTML) {
                if (strstr (contents, "data-evo-signature-plain-text-mode"))
                        e_html_editor_set_mode (editor, E_CONTENT_EDITOR_MODE_PLAIN_TEXT);
 
@@ -907,6 +917,7 @@ mail_signature_editor_content_hash_ready_cb (GObject *source_object,
        EContentEditorContentHash *content_hash;
        ESourceMailSignature *extension;
        AsyncContext *async_context;
+       const gchar *mime_type = "text/plain";
        GError *error = NULL;
 
        g_return_if_fail (E_IS_CONTENT_EDITOR (source_object));
@@ -936,9 +947,29 @@ mail_signature_editor_content_hash_ready_cb (GObject *source_object,
 
        async_context->length = strlen (async_context->contents);
 
+       switch (async_context->editor_mode) {
+       case E_CONTENT_EDITOR_MODE_UNKNOWN:
+               g_warn_if_reached ();
+               break;
+       case E_CONTENT_EDITOR_MODE_PLAIN_TEXT:
+               mime_type = "text/plain";
+               break;
+       case E_CONTENT_EDITOR_MODE_HTML:
+               mime_type = "text/html";
+               break;
+       case E_CONTENT_EDITOR_MODE_MARKDOWN:
+               mime_type = "text/markdown";
+               break;
+       case E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT:
+               mime_type = "text/markdown-plain";
+               break;
+       case E_CONTENT_EDITOR_MODE_MARKDOWN_HTML:
+               mime_type = "text/markdown-html";
+               break;
+       }
+
        extension = e_source_get_extension (async_context->source, E_SOURCE_EXTENSION_MAIL_SIGNATURE);
-       e_source_mail_signature_set_mime_type (extension,
-               async_context->contents_flag == E_CONTENT_EDITOR_GET_RAW_BODY_HTML ? "text/html" : 
"text/plain");
+       e_source_mail_signature_set_mime_type (extension, mime_type);
 
        e_source_registry_commit_source (
                async_context->registry, async_context->source,
@@ -971,7 +1002,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_html_editor_get_mode (editor) == E_CONTENT_EDITOR_MODE_HTML ?
+       async_context->editor_mode = e_html_editor_get_mode (editor);
+       async_context->contents_flag = async_context->editor_mode == E_CONTENT_EDITOR_MODE_HTML ?
                E_CONTENT_EDITOR_GET_RAW_BODY_HTML : E_CONTENT_EDITOR_GET_TO_SEND_PLAIN;
 
        if (G_IS_CANCELLABLE (cancellable))
diff --git a/src/e-util/e-markdown-editor.c b/src/e-util/e-markdown-editor.c
index 319b3d2d31..4771e35c37 100644
--- a/src/e-util/e-markdown-editor.c
+++ b/src/e-util/e-markdown-editor.c
@@ -1077,10 +1077,10 @@ e_markdown_editor_text_view_changed_cb (GtkTextView *text_view,
 
        g_return_if_fail (E_IS_MARKDOWN_EDITOR (self));
 
-       self->priv->changed = TRUE;
+       e_markdown_editor_set_changed (self, TRUE);
 
        g_signal_emit (self, signals[CHANGED], 0, NULL);
-       g_object_notify (G_OBJECT (self), "changed");
+       e_content_editor_emit_content_changed (E_CONTENT_EDITOR (self));
 }
 
 static void
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index fb241041c4..4bddbdd202 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -91,14 +91,59 @@ e_mail_notes_extract_text_content (CamelMimePart *part)
        return text;
 }
 
+static gboolean
+e_mail_notes_editor_extract_text_part (EHTMLEditor *editor,
+                                      CamelContentType *content_type,
+                                      CamelMimePart *part)
+{
+       EContentEditorMode mode = E_CONTENT_EDITOR_MODE_PLAIN_TEXT;
+       guint32 insert_flag = E_CONTENT_EDITOR_INSERT_TEXT_PLAIN;
+       gchar *text;
+
+       if (camel_content_type_is (content_type, "text", "plain")) {
+               const gchar *format;
+
+               format = camel_content_type_param (content_type, "x-evolution-format");
+               if (format) {
+                       if (g_ascii_strcasecmp (format, "markdown-plain") == 0)
+                               mode = E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT;
+                       else if (g_ascii_strcasecmp (format, "markdown-html") == 0)
+                               mode = E_CONTENT_EDITOR_MODE_MARKDOWN_HTML;
+               }
+       } else if (camel_content_type_is (content_type, "text", "markdown")) {
+               mode = E_CONTENT_EDITOR_MODE_MARKDOWN;
+       } else if (camel_content_type_is (content_type, "text", "html")) {
+               mode = E_CONTENT_EDITOR_MODE_HTML;
+               insert_flag = E_CONTENT_EDITOR_INSERT_TEXT_HTML;
+       } else {
+               return FALSE;
+       }
+
+       text = e_mail_notes_extract_text_content (part);
+       if (text) {
+               e_html_editor_set_mode (editor, mode);
+
+               e_content_editor_insert_content (
+                       e_html_editor_get_content_editor (editor),
+                       text,
+                       insert_flag |
+                       E_CONTENT_EDITOR_INSERT_REPLACE_ALL);
+
+               g_free (text);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 static void
 e_mail_notes_extract_text_from_multipart_alternative (EHTMLEditor *editor,
-                                                     EContentEditor *cnt_editor,
                                                      CamelMultipart *in_multipart)
 {
        guint ii, nparts;
 
-       g_return_if_fail (E_IS_CONTENT_EDITOR (cnt_editor));
+       g_return_if_fail (E_IS_HTML_EDITOR (editor));
        g_return_if_fail (CAMEL_IS_MULTIPART (in_multipart));
 
        nparts = camel_multipart_get_number (in_multipart);
@@ -116,34 +161,8 @@ e_mail_notes_extract_text_from_multipart_alternative (EHTMLEditor *editor,
                if (!ct)
                        continue;
 
-               if (camel_content_type_is (ct, "text", "html")) {
-                       gchar *text;
-
-                       text = e_mail_notes_extract_text_content (part);
-                       if (text) {
-                               e_html_editor_set_mode (editor, E_CONTENT_EDITOR_MODE_HTML);
-                               e_content_editor_insert_content (
-                                       cnt_editor,
-                                       text,
-                                       E_CONTENT_EDITOR_INSERT_TEXT_HTML |
-                                       E_CONTENT_EDITOR_INSERT_REPLACE_ALL);
-                               g_free (text);
-                               break;
-                       }
-               } else if (camel_content_type_is (ct, "text", "plain")) {
-                       gchar *text;
-
-                       text = e_mail_notes_extract_text_content (part);
-                       if (text) {
-                               e_content_editor_insert_content (
-                                       cnt_editor,
-                                       text,
-                                       E_CONTENT_EDITOR_INSERT_TEXT_PLAIN |
-                                       E_CONTENT_EDITOR_INSERT_REPLACE_ALL);
-                               g_free (text);
-                       }
+               if (e_mail_notes_editor_extract_text_part (editor, ct, part))
                        break;
-               }
        }
 }
 
@@ -178,7 +197,7 @@ e_mail_notes_editor_extract_text_from_multipart_related (EMailNotesEditor *notes
 
                        if (CAMEL_IS_MULTIPART (content)) {
                                e_mail_notes_extract_text_from_multipart_alternative (notes_editor->editor,
-                                       e_html_editor_get_content_editor (notes_editor->editor), 
CAMEL_MULTIPART (content));
+                                       CAMEL_MULTIPART (content));
                        }
                }
        }
@@ -190,7 +209,6 @@ e_mail_notes_editor_extract_text_from_part (EMailNotesEditor *notes_editor,
 {
        CamelContentType *ct;
        CamelDataWrapper *content;
-       EContentEditor *cnt_editor;
 
        g_return_if_fail (E_IS_MAIL_NOTES_EDITOR (notes_editor));
        g_return_if_fail (CAMEL_IS_MIME_PART (part));
@@ -201,28 +219,16 @@ e_mail_notes_editor_extract_text_from_part (EMailNotesEditor *notes_editor,
        g_return_if_fail (content != NULL);
        g_return_if_fail (ct != NULL);
 
-       cnt_editor = e_html_editor_get_content_editor (notes_editor->editor);
-
        if (camel_content_type_is (ct, "multipart", "related")) {
                g_return_if_fail (CAMEL_IS_MULTIPART (content));
 
                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 (notes_editor->editor, 
cnt_editor, CAMEL_MULTIPART (content));
-               }
-       } else if (camel_content_type_is (ct, "text", "plain")) {
-               gchar *text;
-
-               text = e_mail_notes_extract_text_content (part);
-               if (text) {
-                       e_content_editor_insert_content (
-                               cnt_editor,
-                               text,
-                               E_CONTENT_EDITOR_INSERT_TEXT_PLAIN |
-                               E_CONTENT_EDITOR_INSERT_REPLACE_ALL);
-                       g_free (text);
+                       e_mail_notes_extract_text_from_multipart_alternative (notes_editor->editor, 
CAMEL_MULTIPART (content));
                }
+       } else {
+               e_mail_notes_editor_extract_text_part (notes_editor->editor, ct, part);
        }
 }
 
@@ -290,11 +296,29 @@ e_mail_notes_editor_extract_text_from_message (EMailNotesEditor *notes_editor,
        e_content_editor_set_changed (cnt_editor, FALSE);
 }
 
+static void
+e_mail_notes_maybe_set_markdown_content_type_param (CamelMimePart *part,
+                                                   EContentEditorMode mode)
+{
+       if (mode == E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT ||
+           mode == E_CONTENT_EDITOR_MODE_MARKDOWN_HTML) {
+               CamelContentType *content_type;
+
+               content_type = camel_data_wrapper_get_mime_type_field (camel_medium_get_content (CAMEL_MEDIUM 
(part)));
+
+               if (mode == E_CONTENT_EDITOR_MODE_MARKDOWN_PLAIN_TEXT)
+                       camel_content_type_set_param (content_type, "x-evolution-format", "markdown-plain");
+               else
+                       camel_content_type_set_param (content_type, "x-evolution-format", "markdown-html");
+       }
+}
+
 static CamelMimeMessage *
 e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
                                            EContentEditorContentHash *content_hash)
 {
        EContentEditor *cnt_editor;
+       EContentEditorMode mode;
        EAttachmentStore *attachment_store;
        CamelMimeMessage *message = NULL;
        gchar *message_uid;
@@ -329,7 +353,10 @@ 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_html_editor_get_mode (notes_editor->editor) == E_CONTENT_EDITOR_MODE_HTML) {
+       mode = e_html_editor_get_mode (notes_editor->editor);
+
+       if (mode == E_CONTENT_EDITOR_MODE_HTML ||
+           mode == E_CONTENT_EDITOR_MODE_MARKDOWN_HTML) {
                CamelMultipart *multipart_alternative;
                CamelMultipart *multipart_body;
                CamelMimePart *part;
@@ -351,8 +378,10 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
                        }
 
                        part = camel_mime_part_new ();
-                       camel_mime_part_set_content (part, text, strlen (text), "text/plain");
+                       camel_mime_part_set_content (part, text, strlen (text), mode == 
E_CONTENT_EDITOR_MODE_MARKDOWN ?
+                               "text/markdown" : "text/plain");
                        camel_multipart_add_part (multipart_alternative, part);
+                       e_mail_notes_maybe_set_markdown_content_type_param (part, mode);
 
                        g_object_unref (part);
                        g_free (tmp);
@@ -464,8 +493,10 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
                                camel_multipart_set_boundary (multipart, NULL);
 
                                part = camel_mime_part_new ();
-                               camel_mime_part_set_content (part, text, strlen (text), "text/plain");
+                               camel_mime_part_set_content (part, text, strlen (text), mode == 
E_CONTENT_EDITOR_MODE_MARKDOWN ?
+                                       "text/markdown" : "text/plain");
                                camel_multipart_add_part (multipart, part);
+                               e_mail_notes_maybe_set_markdown_content_type_param (part, mode);
                                g_object_unref (part);
 
                                e_attachment_store_add_to_multipart (attachment_store, multipart, "UTF-8");
@@ -474,7 +505,9 @@ e_mail_notes_editor_encode_text_to_message (EMailNotesEditor *notes_editor,
 
                                g_object_unref (multipart);
                        } else {
-                               camel_mime_part_set_content (CAMEL_MIME_PART (message), text, strlen (text), 
"text/plain");
+                               camel_mime_part_set_content (CAMEL_MIME_PART (message), text, strlen (text), 
mode == E_CONTENT_EDITOR_MODE_MARKDOWN ?
+                                       "text/markdown" : "text/plain");
+                               e_mail_notes_maybe_set_markdown_content_type_param (CAMEL_MIME_PART 
(message), mode);
                        }
 
                        has_text = TRUE;
@@ -588,17 +621,18 @@ mail_notes_editor_delete_event_cb (EMailNotesEditor *notes_editor,
 }
 
 static void
-notes_editor_activity_notify_cb (EActivityBar *activity_bar,
-                                GParamSpec *param,
-                                EMailNotesEditor *notes_editor)
+notes_editor_update_editable_on_notify_cb (GObject *object,
+                                          GParamSpec *param,
+                                          EMailNotesEditor *notes_editor)
 {
+       EActivityBar *activity_bar;
        EContentEditor *cnt_editor;
        GtkAction *action;
        gboolean can_edit;
 
-       g_return_if_fail (E_IS_ACTIVITY_BAR (activity_bar));
        g_return_if_fail (E_IS_MAIL_NOTES_EDITOR (notes_editor));
 
+       activity_bar = e_html_editor_get_activity_bar (notes_editor->editor);
        cnt_editor = e_html_editor_get_content_editor (notes_editor->editor);
        can_edit = notes_editor->had_message && !e_activity_bar_get_activity (activity_bar);
 
@@ -925,15 +959,7 @@ e_mail_notes_editor_dispose (GObject *object)
 {
        EMailNotesEditor *notes_editor = E_MAIL_NOTES_EDITOR (object);
 
-       if (notes_editor->editor) {
-               EActivityBar *activity_bar;
-
-               activity_bar = e_html_editor_get_activity_bar (notes_editor->editor);
-               g_signal_handlers_disconnect_by_func (activity_bar,
-                       G_CALLBACK (notes_editor_activity_notify_cb), notes_editor);
-
-               notes_editor->editor = NULL;
-       }
+       notes_editor->editor = NULL;
 
        g_clear_object (&notes_editor->focus_tracker);
        g_clear_object (&notes_editor->action_group);
@@ -1145,8 +1171,8 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
 
        activity_bar = e_html_editor_get_activity_bar (notes_editor->editor);
 
-       g_signal_connect (activity_bar, "notify::activity",
-               G_CALLBACK (notes_editor_activity_notify_cb), notes_editor);
+       g_signal_connect_object (activity_bar, "notify::activity",
+               G_CALLBACK (notes_editor_update_editable_on_notify_cb), notes_editor, 0);
 
        notes_editor->folder = g_object_ref (folder);
        notes_editor->uid = g_strdup (uid);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]