[geary/bug/728002-webkit2: 116/140] Disable ComposerWebView UI and signals while it is being modified tosend.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/bug/728002-webkit2: 116/140] Disable ComposerWebView UI and signals while it is being modified tosend.
- Date: Tue, 31 Jan 2017 23:08:18 +0000 (UTC)
commit c2ebfa1e397255d54a8db64efc8023cb646b0761
Author: Michael James Gratton <mike vee net>
Date: Thu Jan 26 16:31:53 2017 +1100
Disable ComposerWebView UI and signals while it is being modified tosend.
src/client/composer/composer-web-view.vala | 35 ++++++++++++++++++++++-----
src/client/composer/composer-widget.vala | 1 +
2 files changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala
index 8cc1c30..96dc7ae 100644
--- a/src/client/composer/composer-web-view.vala
+++ b/src/client/composer/composer-web-view.vala
@@ -147,6 +147,11 @@ public class ComposerWebView : ClientWebView {
/** Determines if the view is in rich text mode. */
public bool is_rich_text { get; private set; default = true; }
+ // Determines if signals should be sent, useful for e.g. stopping
+ // document_modified being sent when the editor content is being
+ // updated before sending.
+ private bool signals_enabled = true;
+
/** Emitted when the web view's content has changed. */
public signal void document_modified();
@@ -218,6 +223,14 @@ public class ComposerWebView : ClientWebView {
}
/**
+ * Makes the view uneditable and stops signals from being sent.
+ */
+ public void disable() {
+ set_sensitive(false);
+ this.signals_enabled = false;
+ }
+
+ /**
* Sets whether the editor is in rich text or plain text mode.
*/
public void set_rich_text(bool enabled) {
@@ -503,14 +516,18 @@ public class ComposerWebView : ClientWebView {
// to show a link popopver after the view has processed one,
// we need to emit our own.
bool ret = base.button_release_event(event);
- button_release_event_done(event);
+ if (this.signals_enabled) {
+ button_release_event_done(event);
+ }
return ret;
}
private void on_command_stack_changed(WebKit.JavascriptResult result) {
try {
- string[] values = WebKitUtil.to_string(result).split(",");
- command_stack_changed(values[0] == "true", values[1] == "true");
+ if (this.signals_enabled) {
+ string[] values = WebKitUtil.to_string(result).split(",");
+ command_stack_changed(values[0] == "true", values[1] == "true");
+ }
} catch (Geary.JS.Error err) {
debug("Could not get command stack state: %s", err.message);
}
@@ -518,7 +535,9 @@ public class ComposerWebView : ClientWebView {
private void on_cursor_context_changed(WebKit.JavascriptResult result) {
try {
- cursor_context_changed(new EditContext(WebKitUtil.to_string(result)));
+ if (this.signals_enabled) {
+ cursor_context_changed(new EditContext(WebKitUtil.to_string(result)));
+ }
} catch (Geary.JS.Error err) {
debug("Could not get text cursor style: %s", err.message);
}
@@ -527,9 +546,11 @@ public class ComposerWebView : ClientWebView {
private void on_document_modified(WebKit.JavascriptResult result) {
// Only modify actually changed to avoid excessive notify
// signals being fired.
- if (this.is_empty) {
- this.is_empty = false;
+ if (this.signals_enabled) {
+ if (this.is_empty) {
+ this.is_empty = false;
+ }
+ document_modified();
}
- document_modified();
}
}
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 0cb3e94..826d316 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -1258,6 +1258,7 @@ public class ComposerWidget : Gtk.EventBox {
// Used internally by on_send()
private async void on_send_async() {
+ this.editor.disable();
this.container.vanish();
this.is_closing = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]