[geary/wip/765516-gtk-widget-conversation-viewer: 147/187] Tidy up the ConversationListBox API for accessing reply target email.



commit 78928403d51869be6c93f5044255bf4d9f6c9ab1
Author: Michael James Gratton <mike vee net>
Date:   Mon Aug 22 11:31:06 2016 +1000

    Tidy up the ConversationListBox API for accessing reply target email.
    
    * src/client/conversation-viewer/conversation-listbox.vala
      (ConversationListBox): Convert RO ::reply_target prop into a method,
      reimplement to use new ::get_selection_view method. Fix call sites.
    
    * src/client/conversation-viewer/conversation-email.vala
      (ConversationEmail): Rename ::get_body_selection to
      ::get_selection_for_quoting to make it clear that what the returned
      selection is to be used for. Fix call sites.

 src/client/application/geary-controller.vala       |    4 +-
 .../conversation-viewer/conversation-email.vala    |    2 +-
 .../conversation-viewer/conversation-listbox.vala  |   46 ++++++++++++--------
 3 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index a12dacc..35d685f 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2200,12 +2200,12 @@ public class GearyController : Geary.BaseObject {
             ConversationListBox? list_view =
                 main_window.conversation_viewer.current_list;
             if (list_view != null) {
-                email_view = list_view.reply_target;
+                email_view = list_view.get_reply_target();
             }
         }
         string? quote = null;
         if (email_view != null) {
-            quote = email_view.get_body_selection();
+            quote = email_view.get_selection_for_quoting();
         }
         create_compose_widget(compose_type, email_view.email, quote);
     }
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index fd39aec..60930a0 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -544,7 +544,7 @@ public class ConversationEmail : Gtk.Box {
     /**
      * Returns user-selected body HTML from a message, if any.
      */
-    public string? get_body_selection() {
+    public string? get_selection_for_quoting() {
         return (this.body_selection_message != null)
             ? this.body_selection_message.get_selection_for_quoting()
             : null;
diff --git a/src/client/conversation-viewer/conversation-listbox.vala 
b/src/client/conversation-viewer/conversation-listbox.vala
index 05eae5f..de129c6 100644
--- a/src/client/conversation-viewer/conversation-listbox.vala
+++ b/src/client/conversation-viewer/conversation-listbox.vala
@@ -118,24 +118,6 @@ public class ConversationListBox : Gtk.ListBox {
     }
 
 
-    /**
-     * Returns the view for the email to be replied to, if any.
-     *
-     * If an email view has selected body text that view will be
-     * returned. Else the last message by sort order will be returned,
-     * if any.
-     */
-    public ConversationEmail? reply_target {
-        get {
-            unowned ConversationEmail? view = this.body_selected_view;
-            if (view == null && this.last_email_row != null) {
-                view = this.last_email_row.view;
-            }
-            return view;
-        }
-    }
-
-
     /** Conversation being displayed. */
     public Geary.App.Conversation conversation { get; private set; }
 
@@ -281,6 +263,34 @@ public class ConversationListBox : Gtk.ListBox {
     }
 
     /**
+     * Returns the email view to be replied to, if any.
+     *
+     * If an email view has a visible body and selected text, that
+     * view will be returned. Else the last message by sort order will
+     * be returned, if any.
+     */
+    public ConversationEmail? get_reply_target() {
+        ConversationEmail? view = get_selection_view();
+        if (view == null && this.last_email_row != null) {
+            view = this.last_email_row.view;
+        }
+        return view;
+    }
+
+    /**
+     * Returns the email view with a visible user selection, if any.
+     *
+     * If an email view has selected body text.
+     */
+    public ConversationEmail? get_selection_view() {
+        ConversationEmail? view = this.body_selected_view;
+        if (view != null) {
+            // XXX actually check the selected text is visible
+        }
+        return view;
+    }
+
+    /**
      * Adds an an embedded composer to the view.
      */
     public void add_embedded_composer(ComposerEmbed embed) {


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