[geary] Choose the message to reply to based on selection
- From: Robert Schroll <rschroll src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Choose the message to reply to based on selection
- Date: Wed, 8 Oct 2014 22:12:54 +0000 (UTC)
commit 4d38f66ecb3ce2971ea676d9f780e6eb5cbcb931
Author: Robert Schroll <rschroll gmail com>
Date: Sun Aug 24 18:36:20 2014 -0400
Choose the message to reply to based on selection
If part of a message is selected, that will be the replied-to message.
If parts of multiple messages are selected, or nothing is selected, the
last email will be replied to.
https://bugzilla.gnome.org/show_bug.cgi?id=712912
src/client/application/geary-controller.vala | 6 ++--
.../conversation-viewer/conversation-viewer.vala | 25 ++++++++++++++++++++
2 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index e0de0d1..bb4b73d 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2195,7 +2195,7 @@ public class GearyController : Geary.BaseObject {
}
private void on_reply_to_message_action() {
- Geary.Email? message = main_window.conversation_viewer.get_last_message();
+ Geary.Email? message = main_window.conversation_viewer.get_selected_message();
if (message != null)
on_reply_to_message(message);
}
@@ -2205,7 +2205,7 @@ public class GearyController : Geary.BaseObject {
}
private void on_reply_all_message_action() {
- Geary.Email? message = main_window.conversation_viewer.get_last_message();
+ Geary.Email? message = main_window.conversation_viewer.get_selected_message();
if (message != null)
on_reply_all_message(message);
}
@@ -2215,7 +2215,7 @@ public class GearyController : Geary.BaseObject {
}
private void on_forward_message_action() {
- Geary.Email? message = main_window.conversation_viewer.get_last_message();
+ Geary.Email? message = main_window.conversation_viewer.get_selected_message();
if (message != null)
on_forward_message(message);
}
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index 3c6d777..8146e69 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -211,6 +211,31 @@ public class ConversationViewer : Gtk.Box {
return messages.is_empty ? null : messages.last();
}
+ public Geary.Email? get_selected_message() {
+ WebKit.DOM.DOMSelection selection = web_view.get_dom_document().default_view.get_selection();
+ if (selection.is_collapsed)
+ return get_last_message();
+
+ WebKit.DOM.Element? anchor_element = selection.anchor_node as WebKit.DOM.Element;
+ Geary.Email? anchor_email = null;
+ if (anchor_element == null)
+ anchor_element = selection.anchor_node.parent_element;
+ if (anchor_element != null)
+ anchor_email = get_email_from_element(anchor_element);
+
+ WebKit.DOM.Element? focus_element = selection.focus_node as WebKit.DOM.Element;
+ Geary.Email? focus_email = null;
+ if (focus_element == null)
+ focus_element = selection.focus_node.parent_element;
+ if (focus_element != null)
+ focus_email = get_email_from_element(focus_element);
+
+ if (anchor_email != null && anchor_email == focus_email)
+ return anchor_email;
+
+ return get_last_message();
+ }
+
// Removes all displayed e-mails from the view.
private void clear(Geary.Folder? new_folder, Geary.AccountInformation? account_information) {
// Remove all messages from DOM.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]