[geary/wip/712912-select-quote: 4/7] Add selected text as quote in existing reply



commit be1abf8c19bea33155f84cd44907cc0b01d2ed5d
Author: Robert Schroll <rschroll gmail com>
Date:   Sun Aug 24 22:29:25 2014 -0400

    Add selected text as quote in existing reply
    
    This happens only if it's not changing the reply type.  This helps in
    the case where you are switching the reply and haven't de-selected text
    that was previously quoted.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712912

 src/client/application/geary-controller.vala |    8 ++++----
 src/client/composer/composer-widget.vala     |    8 +++++++-
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 38795af..c53fb67 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2074,7 +2074,7 @@ public class GearyController : Geary.BaseObject {
             return;
         
         bool inline;
-        if (!should_create_new_composer(compose_type, referred, out inline))
+        if (!should_create_new_composer(compose_type, referred, quote, out inline))
             return;
         
         ComposerWidget widget;
@@ -2111,7 +2111,7 @@ public class GearyController : Geary.BaseObject {
     }
     
     private bool should_create_new_composer(ComposerWidget.ComposeType? compose_type,
-        Geary.Email? referred, out bool inline) {
+        Geary.Email? referred, string? quote, out bool inline) {
         inline = true;
         
         // In we're replying, see whether we already have a reply for that message.
@@ -2119,7 +2119,7 @@ public class GearyController : Geary.BaseObject {
             foreach (ComposerWidget cw in composer_widgets) {
                 if (cw.state != ComposerWidget.ComposerState.DETACHED &&
                     referred != null && referred.id.equal_to(cw.referred_id)) {
-                    cw.change_compose_type(compose_type);
+                    cw.change_compose_type(compose_type, referred, quote);
                     return false;
                 }
             }
@@ -2166,7 +2166,7 @@ public class GearyController : Geary.BaseObject {
     
     public bool can_switch_conversation_view() {
         bool inline;
-        return should_create_new_composer(null, null, out inline);
+        return should_create_new_composer(null, null, null, out inline);
     }
     
     public bool any_inline_composers() {
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 2f86885..dc4ef80 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -757,7 +757,8 @@ public class ComposerWidget : Gtk.EventBox {
         show_attachments();
     }
     
-    public void change_compose_type(ComposeType new_type) {
+    public void change_compose_type(ComposeType new_type, Geary.Email? referred = null,
+        string? quote = null) {
         if (new_type != compose_type) {
             bool recipients_modified = to_entry.modified || cc_entry.modified || bcc_entry.modified;
             switch (new_type) {
@@ -791,6 +792,11 @@ public class ComposerWidget : Gtk.EventBox {
                     assert_not_reached();
             }
             compose_type = new_type;
+        } else if (referred != null && quote != null) {
+            WebKit.DOM.Document document = editor.get_dom_document();
+            // Always use reply styling, since forward styling doesn't work for inline quotes
+            document.exec_command("insertHTML", false,
+                Geary.RFC822.Utils.quote_email_for_reply(referred, quote, true));
         }
         
         container.present();


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