[geary/wip/712912-select-quote: 3/7] Use bottom-posting when replying with selection
- From: Robert Schroll <rschroll src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/712912-select-quote: 3/7] Use bottom-posting when replying with selection
- Date: Fri, 19 Sep 2014 19:54:03 +0000 (UTC)
commit bef95e22b14031216a9f25d991244713c45ad8e3
Author: Robert Schroll <rschroll gmail com>
Date: Sun Aug 24 21:27:43 2014 -0400
Use bottom-posting when replying with selection
Forwarding always uses top-posting, since it makes it hard to
distinguish between the original mail and a bottom-posted reply.
https://bugzilla.gnome.org/show_bug.cgi?id=712912
src/client/composer/composer-widget.vala | 20 ++++++++++++++++++--
src/engine/rfc822/rfc822-utils.vala | 5 ++++-
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index b3c8f88..2f86885 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -215,6 +215,7 @@ public class ComposerWidget : Gtk.EventBox {
private string reply_subject = "";
private string forward_subject = "";
private string reply_message_id = "";
+ private bool top_posting = true;
private Geary.FolderSupport.Create? drafts_folder = null;
private Geary.EmailIdentifier? draft_id = null;
@@ -430,6 +431,8 @@ public class ComposerWidget : Gtk.EventBox {
references = Geary.RFC822.Utils.reply_references(referred);
body_html = "\n\n" + Geary.RFC822.Utils.quote_email_for_reply(referred, quote, true);
pending_attachments = referred.attachments;
+ if (quote != null)
+ top_posting = false;
break;
case ComposeType.FORWARD:
@@ -587,8 +590,8 @@ public class ComposerWidget : Gtk.EventBox {
}
private void on_load_finished(WebKit.WebFrame frame) {
- WebKit.DOM.HTMLElement? body = editor.get_dom_document().get_element_by_id(
- BODY_ID) as WebKit.DOM.HTMLElement;
+ WebKit.DOM.Document document = editor.get_dom_document();
+ WebKit.DOM.HTMLElement? body = document.get_element_by_id(BODY_ID) as WebKit.DOM.HTMLElement;
assert(body != null);
if (!Geary.String.is_empty(body_html)) {
@@ -600,6 +603,19 @@ public class ComposerWidget : Gtk.EventBox {
}
body.focus(); // Focus within the HTML document
+ if (!top_posting) {
+ try {
+ WebKit.DOM.Range range = document.create_range();
+ range.select_node_contents(body);
+ range.collapse(false);
+ WebKit.DOM.DOMSelection selection = document.default_view.get_selection();
+ selection.remove_all_ranges();
+ selection.add_range(range);
+ } catch (Error error) {
+ debug("Error setting cursor at end of text: %s", error.message);
+ }
+ }
+
protect_blockquote_styles();
set_focus(); // Focus in the GTK widget hierarchy
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 208bb10..9048ee1 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -158,7 +158,7 @@ public string quote_email_for_reply(Geary.Email email, string? quote, bool html_
if (email.body == null && quote == null)
return "";
- string quoted = "<br /><br />";
+ string quoted = (quote == null) ? "<br /><br />" : "";
/// Format for the datetime that a message being replied to was received
/// See http://developer.gnome.org/glib/2.32/glib-GDateTime.html#g-date-time-format
@@ -189,6 +189,9 @@ public string quote_email_for_reply(Geary.Email email, string? quote, bool html_
quoted += "\n" + quote_body(email, quote, true, html_format);
+ if (quote != null)
+ quoted += "<br /><br />\n";
+
return quoted;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]