[geary/wip/728002-webkit2: 74/96] Add is_rich_text property to ComposerWebView, use it.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2: 74/96] Add is_rich_text property to ComposerWebView, use it.
- Date: Sat, 14 Jan 2017 12:18:02 +0000 (UTC)
commit aff2726b72af9c9caef54738744283da0be6b35e
Author: Michael James Gratton <mike vee net>
Date: Wed Jan 4 13:46:37 2017 +1100
Add is_rich_text property to ComposerWebView, use it.
* src/client/composer/composer-web-view.vala (ComposerWebView): Add
is_rich_text pop, keep it updated.
* src/client/composer/composer-widget.vala (ComposerWidget): Use
is_rich_text property rather than consulting the action's state.
src/client/composer/composer-web-view.vala | 4 ++++
src/client/composer/composer-widget.vala | 10 ++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala
index 2b1e3ae..09fa718 100644
--- a/src/client/composer/composer-web-view.vala
+++ b/src/client/composer/composer-web-view.vala
@@ -68,6 +68,9 @@ public class ComposerWebView : ClientWebView {
);
}
+ /** Determines if the view is in rich text mode */
+ public bool is_rich_text { get; private set; default = true; }
+
private bool is_shift_down = false;
@@ -167,6 +170,7 @@ public class ComposerWebView : ClientWebView {
* Sets whether the editor is in rich text or plain text mode.
*/
public void set_rich_text(bool enabled) {
+ this.is_rich_text = enabled;
this.run_javascript.begin(
"geary.setRichText(%s);".printf(enabled ? "true" : "false"), null
);
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index b5fc3a1..9d3c208 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -898,7 +898,7 @@ public class ComposerWidget : Gtk.EventBox {
email.img_src_prefix = this.editor.allow_prefix;
try {
- if (actions.get_action_state(ACTION_COMPOSE_AS_HTML).get_boolean() || only_html)
+ if (this.editor.is_rich_text || only_html)
email.body_html = yield this.editor.get_html();
if (!only_html)
email.body_text = yield this.editor.get_text();
@@ -1958,8 +1958,10 @@ public class ComposerWidget : Gtk.EventBox {
get_action(ACTION_CUT).set_enabled(this.editor.can_cut_clipboard());
get_action(ACTION_COPY).set_enabled(this.editor.can_copy_clipboard());
get_action(ACTION_PASTE).set_enabled(this.editor.can_paste_clipboard());
- get_action(ACTION_PASTE_WITH_FORMATTING).set_enabled(this.editor.can_paste_clipboard()
- && get_action(ACTION_COMPOSE_AS_HTML).state.get_boolean());
+ get_action(ACTION_PASTE_WITH_FORMATTING).set_enabled(
+ this.editor.can_paste_clipboard() &&
+ this.editor.is_rich_text
+ );
// // Style formatting actions.
// WebKit.DOM.Document document = this.editor.get_dom_document();
@@ -1969,7 +1971,7 @@ public class ComposerWidget : Gtk.EventBox {
// return;
// get_action(ACTION_REMOVE_FORMAT).set_enabled(!selection.is_collapsed
- // && get_action(ACTION_COMPOSE_AS_HTML).state.get_boolean());
+ // && this.editor.is_rich_text);
// WebKit.DOM.Element? active = selection.focus_node as WebKit.DOM.Element;
// if (active == null && selection.focus_node != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]