[geary/wip/765516-gtk-widget-conversation-viewer: 83/117] Remove redundant Geary.Email arg from ConversationEmail signals.



commit bea67116ed1b9e236c0518e8d1272836cdf7b9e3
Author: Michael James Gratton <mike vee net>
Date:   Tue Jun 21 14:48:24 2016 +1000

    Remove redundant Geary.Email arg from ConversationEmail signals.
    
    Since the ConversationEmail instance is also passed to signal handlers
    and the view's email instance can be obtained from that, also passing the
    email instance is redundant. Don't do that.
    
    * src/client/conversation-viewer/conversation-email.vala
      (ConversationEmail): Remove Geary.Email from signals where
      present. Also rename ::mark_email_from to ::mark_email_from_here to
      make its operation a bit more obvious. Update call sites and handler
      implementations.

 src/client/application/geary-controller.vala       |   61 +++++++++++--------
 .../conversation-viewer/conversation-email.vala    |   40 +++++++-------
 .../conversation-viewer/conversation-viewer.vala   |   16 +++---
 3 files changed, 63 insertions(+), 54 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 7157483..c1306a5 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1523,17 +1523,22 @@ public class GearyController : Geary.BaseObject {
             conversations_selected(selected_conversations, current_folder);
         }
     }
-    
+
     private void on_conversation_activated(Geary.App.Conversation activated) {
         // Currently activating a conversation is only available for drafts folders.
         if (current_folder == null || current_folder.special_folder_type !=
             Geary.SpecialFolderType.DRAFTS)
             return;
-        
+
         // TODO: Determine how to map between conversations and drafts correctly.
-        on_edit_draft(activated.get_latest_recv_email(Geary.App.Conversation.Location.IN_FOLDER));
+        Geary.Email draft = activated.get_latest_recv_email(
+            Geary.App.Conversation.Location.IN_FOLDER
+        );
+        create_compose_widget(
+            ComposerWidget.ComposeType.NEW_MESSAGE, draft, null, null, true
+        );
     }
-    
+
     private void on_special_folder_type_changed(Geary.Folder folder, Geary.SpecialFolderType old_type,
         Geary.SpecialFolderType new_type) {
         main_window.folder_list.remove_folder(folder);
@@ -2218,11 +2223,11 @@ public class GearyController : Geary.BaseObject {
         // If we deleted all composer windows without the user cancelling, we can exit.
         return true;
     }
-    
-    // message is the email from whose menu this reply or forward was triggered.  If null,
-    // this was triggered from the headerbar or shortcut.
+
+    // View contains the email from whose menu this reply or forward
+    // was triggered.  If null, this was triggered from the headerbar
+    // or shortcut.
     private void create_reply_forward_widget(ComposerWidget.ComposeType compose_type,
-        Geary.Email? message) {
         string? quote;
         Geary.Email? quote_message = main_window.conversation_viewer.get_selected_email(out quote);
         if (message == null)
@@ -2230,8 +2235,10 @@ public class GearyController : Geary.BaseObject {
         if (quote_message != message)
             quote = null;
         create_compose_widget(compose_type, message, quote);
+                                             owned ConversationEmail? view) {
+        Geary.Email message = (view != null) ? view.email : null;
     }
-    
+
     private void create_compose_widget(ComposerWidget.ComposeType compose_type,
         Geary.Email? referred = null, string? quote = null, string? mailto = null,
         bool is_draft = false) {
@@ -2379,27 +2386,27 @@ public class GearyController : Geary.BaseObject {
     private void on_new_message() {
         create_compose_widget(ComposerWidget.ComposeType.NEW_MESSAGE);
     }
-    
-    private void on_reply_to_message(Geary.Email message) {
-        create_reply_forward_widget(ComposerWidget.ComposeType.REPLY, message);
+
+    private void on_reply_to_message(ConversationEmail target_view) {
+        create_reply_forward_widget(ComposerWidget.ComposeType.REPLY, target_view);
     }
-    
+
     private void on_reply_to_message_action() {
         create_reply_forward_widget(ComposerWidget.ComposeType.REPLY, null);
     }
-    
-    private void on_reply_all_message(Geary.Email message) {
-        create_reply_forward_widget(ComposerWidget.ComposeType.REPLY_ALL, message);
+
+    private void on_reply_all_message(ConversationEmail target_view) {
+        create_reply_forward_widget(ComposerWidget.ComposeType.REPLY_ALL, target_view);
     }
-    
+
     private void on_reply_all_message_action() {
         create_reply_forward_widget(ComposerWidget.ComposeType.REPLY_ALL, null);
     }
-    
-    private void on_forward_message(Geary.Email message) {
-        create_reply_forward_widget(ComposerWidget.ComposeType.FORWARD, message);
+
+    private void on_forward_message(ConversationEmail target_view) {
+        create_reply_forward_widget(ComposerWidget.ComposeType.FORWARD, target_view);
     }
-    
+
     private void on_forward_message_action() {
         create_reply_forward_widget(ComposerWidget.ComposeType.FORWARD, null);
     }
@@ -2718,14 +2725,16 @@ public class GearyController : Geary.BaseObject {
         }
     }
 
-    private void on_edit_draft(Geary.Email draft) {
-        create_compose_widget(ComposerWidget.ComposeType.NEW_MESSAGE, draft, null, null, true);
+    private void on_edit_draft(ConversationEmail draft_view) {
+        create_compose_widget(
+            ComposerWidget.ComposeType.NEW_MESSAGE, draft_view.email, null, null, true
+        );
     }
 
 
-    private void on_view_source(Geary.Email message) {
-        string source = (message.header.buffer.to_string() +
-                         message.body.buffer.to_string());
+    private void on_view_source(ConversationEmail email_view) {
+        string source = (email_view.email.header.buffer.to_string() +
+                         email_view.email.body.buffer.to_string());
         string temporary_filename;
         try {
             int temporary_handle = FileUtils.open_tmp("geary-message-XXXXXX.txt",
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index 7570b37..4a3446b 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -126,22 +126,22 @@ public class ConversationEmail : Gtk.Box {
     private Gtk.Menu attachments_menu;
 
     /** Fired when the user clicks "reply" in the message menu. */
-    public signal void reply_to_message(Geary.Email message);
+    public signal void reply_to_message();
 
     /** Fired when the user clicks "reply all" in the message menu. */
-    public signal void reply_all_message(Geary.Email message);
+    public signal void reply_all_message();
 
     /** Fired when the user clicks "forward" in the message menu. */
-    public signal void forward_message(Geary.Email message);
+    public signal void forward_message();
 
     /** Fired when the user updates the email's flags. */
     public signal void mark_email(
-        Geary.Email email, Geary.NamedFlag? to_add, Geary.NamedFlag? to_remove
+        Geary.NamedFlag? to_add, Geary.NamedFlag? to_remove
     );
 
-    /** Fired when the user updates flags for this email and all emails down. */
-    public signal void mark_email_from(
-        Geary.Email email, Geary.NamedFlag? to_add, Geary.NamedFlag? to_remove
+    /** Fired when the user updates flags for this email and all others down. */
+    public signal void mark_email_from_here(
+        Geary.NamedFlag? to_add, Geary.NamedFlag? to_remove
     );
 
     /** Fired when the user saves an inline displayed image. */
@@ -157,10 +157,10 @@ public class ConversationEmail : Gtk.Box {
     public signal void save_attachments(Gee.Collection<AttachmentInfo> attachments);
 
     /** Fired the edit draft button is clicked. */
-    public signal void edit_draft(Geary.Email email);
+    public signal void edit_draft();
 
     /** Fired when the view source action is activated. */
-    public signal void view_source(Geary.Email email);
+    public signal void view_source();
 
 
     /**
@@ -177,28 +177,28 @@ public class ConversationEmail : Gtk.Box {
         this.contact_store = contact_store;
 
         add_action(ACTION_FORWARD).activate.connect(() => {
-                forward_message(this.email);
+                forward_message();
             });
         add_action(ACTION_PRINT).activate.connect(() => {
                 print();
             });
         add_action(ACTION_MARK_READ).activate.connect(() => {
-                mark_email(this.email, null, Geary.EmailFlags.UNREAD);
+                mark_email(null, Geary.EmailFlags.UNREAD);
             });
         add_action(ACTION_MARK_UNREAD).activate.connect(() => {
-                mark_email(this.email, Geary.EmailFlags.UNREAD, null);
+                mark_email(Geary.EmailFlags.UNREAD, null);
             });
         add_action(ACTION_MARK_UNREAD_DOWN).activate.connect(() => {
-                mark_email_from(this.email, Geary.EmailFlags.UNREAD, null);
+                mark_email_from_here(Geary.EmailFlags.UNREAD, null);
             });
         add_action(ACTION_OPEN_ATTACHMENTS).activate.connect(() => {
                 attachments_activated(selected_attachments);
             });
         add_action(ACTION_REPLY_ALL).activate.connect(() => {
-                reply_all_message(this.email);
+                reply_all_message();
             });
         add_action(ACTION_REPLY_SENDER).activate.connect(() => {
-                reply_to_message(this.email);
+                reply_to_message();
             });
         add_action(ACTION_SAVE_ATTACHMENTS).activate.connect(() => {
                 save_attachments(selected_attachments);
@@ -207,13 +207,13 @@ public class ConversationEmail : Gtk.Box {
                 save_attachments(displayed_attachments);
             });
         add_action(ACTION_STAR).activate.connect(() => {
-                mark_email(this.email, Geary.EmailFlags.FLAGGED, null);
+                mark_email(Geary.EmailFlags.FLAGGED, null);
             });
         add_action(ACTION_UNSTAR).activate.connect(() => {
-                mark_email(this.email, null, Geary.EmailFlags.FLAGGED);
+                mark_email(null, Geary.EmailFlags.FLAGGED);
             });
         add_action(ACTION_VIEW_SOURCE).activate.connect(() => {
-                view_source(this.email);
+                view_source();
             });
         insert_action_group("eml", message_actions);
 
@@ -258,7 +258,7 @@ public class ConversationEmail : Gtk.Box {
         if (is_draft) {
             draft_infobar.show();
             draft_infobar.response.connect((infobar, response_id) => {
-                    if (response_id == 1) { edit_draft(email); }
+                    if (response_id == 1) { edit_draft(); }
                 });
         }
 
@@ -407,7 +407,7 @@ public class ConversationEmail : Gtk.Box {
 
     private void on_flag_remote_images(ConversationMessage view) {
         // XXX check we aren't already auto loading the image
-        mark_email(email, Geary.EmailFlags.LOAD_REMOTE_IMAGES, null);
+        mark_email(Geary.EmailFlags.LOAD_REMOTE_IMAGES, null);
     }
 
 
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index 518b6cd..84be0ce 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -695,7 +695,7 @@ public class ConversationViewer : Gtk.Stack {
             is_draft
         );
         conversation_email.mark_email.connect(on_mark_email);
-        conversation_email.mark_email_from.connect(on_mark_email_from);
+        conversation_email.mark_email_from_here.connect(on_mark_email_from_here);
 
         ConversationMessage conversation_message = conversation_email.primary_message;
         conversation_message.body_box.button_release_event.connect_after((event) => {
@@ -783,23 +783,23 @@ public class ConversationViewer : Gtk.Stack {
         return SearchState.NONE;
     }
 
-    private void on_mark_email(Geary.Email email,
+    private void on_mark_email(ConversationEmail view,
                                Geary.NamedFlag? to_add,
                                Geary.NamedFlag? to_remove) {
         Gee.Collection<Geary.EmailIdentifier> ids =
             new Gee.LinkedList<Geary.EmailIdentifier>();
-        ids.add(email.id);
+        ids.add(view.email.id);
         mark_emails(ids, flag_to_flags(to_add), flag_to_flags(to_remove));
     }
 
-    private void on_mark_email_from(Geary.Email email,
-                                    Geary.NamedFlag? to_add,
-                                    Geary.NamedFlag? to_remove) {
+    private void on_mark_email_from_here(ConversationEmail view,
+                                         Geary.NamedFlag? to_add,
+                                         Geary.NamedFlag? to_remove) {
         Gee.Collection<Geary.EmailIdentifier> ids =
             new Gee.LinkedList<Geary.EmailIdentifier>();
-        ids.add(email.id);
+        ids.add(view.email.id);
         foreach (Geary.Email other in this.emails) {
-            if (Geary.Email.compare_sent_date_ascending(email, other) < 0) {
+            if (Geary.Email.compare_sent_date_ascending(view.email, other) < 0) {
                 ids.add(other.id);
             }
         }


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