[evolution] Bug 785127 - Change in composer body doesn't trigger autosave timeout



commit 610bb91546375c324a085c7d4c2e20a7af64ebd7
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jul 20 10:55:00 2017 +0200

    Bug 785127 - Change in composer body doesn't trigger autosave timeout

 src/e-util/e-content-editor.c                      |   28 ++++++++++++++++++++
 src/e-util/e-content-editor.h                      |    3 ++
 .../composer-autosave/e-composer-autosave.c        |    4 +++
 src/modules/webkit-editor/e-webkit-editor.c        |    3 ++
 4 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/e-util/e-content-editor.c b/src/e-util/e-content-editor.c
index ca5f416..7627aaa 100644
--- a/src/e-util/e-content-editor.c
+++ b/src/e-util/e-content-editor.c
@@ -35,6 +35,7 @@ enum {
        FIND_DONE,
        REPLACE_ALL_DONE,
        DROP_HANDLED,
+       CONTENT_CHANGED,
        LAST_SIGNAL
 };
 
@@ -560,6 +561,25 @@ e_content_editor_default_init (EContentEditorInterface *iface)
                NULL, NULL,
                NULL,
                G_TYPE_NONE, 0);
+
+       /**
+        * EContentEditor:content-changed
+        *
+        * Emitted when the content of the editor changes. It can be used in connection
+        * to the #EContentEditor::changed property, except this signal is emitted
+        * whenever the inner content changes, which the 'changed' property notifies
+        * about its change only when the value truly changes.
+        *
+        * Since: 3.26
+        */
+       signals[CONTENT_CHANGED] = g_signal_new (
+               "content-changed",
+               E_TYPE_CONTENT_EDITOR,
+               G_SIGNAL_RUN_LAST,
+               G_STRUCT_OFFSET (EContentEditorInterface, content_changed),
+               NULL, NULL,
+               NULL,
+               G_TYPE_NONE, 0);
 }
 
 ESpellChecker *
@@ -3718,3 +3738,11 @@ e_content_editor_emit_drop_handled (EContentEditor *editor)
 
        g_signal_emit (editor, signals[DROP_HANDLED], 0);
 }
+
+void
+e_content_editor_emit_content_changed (EContentEditor *editor)
+{
+       g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
+
+       g_signal_emit (editor, signals[CONTENT_CHANGED], 0);
+}
diff --git a/src/e-util/e-content-editor.h b/src/e-util/e-content-editor.h
index 4497570..e641190 100644
--- a/src/e-util/e-content-editor.h
+++ b/src/e-util/e-content-editor.h
@@ -439,6 +439,7 @@ struct _EContentEditorInterface {
        void            (*replace_all_done)             (EContentEditor *editor,
                                                         guint replaced_count);
        void            (*drop_handled)                 (EContentEditor *editor);
+       void            (*content_changed)              (EContentEditor *editor);
 };
 
 /* Properties */
@@ -1029,6 +1030,8 @@ void              e_content_editor_emit_replace_all_done
                                                 guint replaced_count);
 void           e_content_editor_emit_drop_handled
                                                (EContentEditor *editor);
+void           e_content_editor_emit_content_changed
+                                               (EContentEditor *editor);
 
 G_END_DECLS
 
diff --git a/src/modules/composer-autosave/e-composer-autosave.c 
b/src/modules/composer-autosave/e-composer-autosave.c
index efab816..0e5705f 100644
--- a/src/modules/composer-autosave/e-composer-autosave.c
+++ b/src/modules/composer-autosave/e-composer-autosave.c
@@ -173,6 +173,10 @@ composer_autosave_constructed (GObject *object)
        g_signal_connect_swapped (
                cnt_editor, "notify::changed",
                G_CALLBACK (composer_autosave_changed_cb), object);
+
+       g_signal_connect_swapped (
+               cnt_editor, "content-changed",
+               G_CALLBACK (composer_autosave_changed_cb), object);
 }
 
 static void
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 4b165da..7e9959a 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -274,6 +274,9 @@ webkit_editor_set_changed (EWebKitEditor *wk_editor,
 {
        g_return_if_fail (E_IS_WEBKIT_EDITOR (wk_editor));
 
+       if (changed)
+               e_content_editor_emit_content_changed (E_CONTENT_EDITOR (wk_editor));
+
        if (wk_editor->priv->changed == changed)
                return;
 


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