[geary/wip/765516-gtk-widget-conversation-viewer: 31/78] Don't require duplicating conversation message signals on the viewer.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer: 31/78] Don't require duplicating conversation message signals on the viewer.
- Date: Fri, 8 Jul 2016 08:05:44 +0000 (UTC)
commit 7bb516ca7e3784c9b9a412421391b3e2dbef8a33
Author: Michael James Gratton <mike vee net>
Date: Mon Apr 18 10:17:21 2016 +1000
Don't require duplicating conversation message signals on the viewer.
Since we want GearyController to handle the effects of most user actions,
we've had to duplicate ConversationMessage's signals on
ConversationViewer and chain them down.
Instead, add a message_added & message_removed signal to
ConversationViewer and emit them as appropriate, then have
GearyController connect to those and manually manage hooking/unhooking
itself to ConversationMessage signals as instances are added/removed.
Do this to the link clicked signal to start.
* src/client/application/geary-controller.vala: Add on_message_added and
on_message_removed handlers, connect them to the main window's
ConversationViewer instance and added/remove the message's link click
hander there.
* src/client/conversation-viewer/conversation-viewer.vala: Add
message_added and message_removed signals, hook them up as messages are
added and removed. Remove link_selected signal and plumbing.
* src/client/conversation-viewer/conversation-message.vala: Rename
link_selected to link_activated to match GTK nomenclature better.
src/client/application/geary-controller.vala | 18 ++++++++++++++----
.../conversation-viewer/conversation-message.vala | 10 +++++-----
.../conversation-viewer/conversation-viewer.vala | 17 ++++++++++++-----
3 files changed, 31 insertions(+), 14 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 9613d5a..8215f2a 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -210,7 +210,8 @@ public class GearyController : Geary.BaseObject {
main_window.main_toolbar.copy_folder_menu.folder_selected.connect(on_copy_conversation);
main_window.main_toolbar.move_folder_menu.folder_selected.connect(on_move_conversation);
main_window.search_bar.search_text_changed.connect(on_search_text_changed);
- main_window.conversation_viewer.link_selected.connect(on_link_selected);
+ main_window.conversation_viewer.message_added.connect(on_message_added);
+ main_window.conversation_viewer.message_removed.connect(on_message_removed);
main_window.conversation_viewer.reply_to_message.connect(on_reply_to_message);
main_window.conversation_viewer.reply_all_message.connect(on_reply_all_message);
main_window.conversation_viewer.forward_message.connect(on_forward_message);
@@ -279,7 +280,8 @@ public class GearyController : Geary.BaseObject {
main_window.main_toolbar.copy_folder_menu.folder_selected.disconnect(on_copy_conversation);
main_window.main_toolbar.move_folder_menu.folder_selected.disconnect(on_move_conversation);
main_window.search_bar.search_text_changed.disconnect(on_search_text_changed);
- main_window.conversation_viewer.link_selected.disconnect(on_link_selected);
+ main_window.conversation_viewer.message_added.disconnect(on_message_added);
+ main_window.conversation_viewer.message_removed.disconnect(on_message_removed);
main_window.conversation_viewer.reply_to_message.disconnect(on_reply_to_message);
main_window.conversation_viewer.reply_all_message.disconnect(on_reply_all_message);
main_window.conversation_viewer.forward_message.disconnect(on_forward_message);
@@ -2637,8 +2639,16 @@ public class GearyController : Geary.BaseObject {
private void on_sent(Geary.RFC822.Message rfc822) {
Libnotify.play_sound("message-sent-email");
}
-
- private void on_link_selected(string link) {
+
+ private void on_message_added(ConversationMessage message) {
+ message.link_activated.connect(on_link_activated);
+ }
+
+ private void on_message_removed(ConversationMessage message) {
+ message.link_activated.disconnect(on_link_activated);
+ }
+
+ private void on_link_activated(string link) {
if (link.down().has_prefix(Geary.ComposedEmail.MAILTO_SCHEME)) {
compose_mailto(link);
} else {
diff --git a/src/client/conversation-viewer/conversation-message.vala
b/src/client/conversation-viewer/conversation-message.vala
index 036595a..5cbe1f0 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -117,15 +117,15 @@ public class ConversationMessage : Gtk.Box {
// Contains the current mouse-over'ed link URL, if any
private string? hover_url = null;
-
+
private Gee.HashSet<string> inlined_content_ids = new Gee.HashSet<string>();
private int next_replaced_buffer_number = 0;
private Gee.HashMap<string, ReplacedImage> replaced_images = new Gee.HashMap<string, ReplacedImage>();
private Gee.HashSet<string> replaced_content_ids = new Gee.HashSet<string>();
- // Fired when the user clicks a link.
- public signal void link_selected(string link);
+ // Fired on link activation in the web_view
+ public signal void link_activated(string link);
public ConversationMessage(Geary.Email email, Geary.Folder containing_folder) {
@@ -195,8 +195,8 @@ public class ConversationMessage : Gtk.Box {
body_box.set_has_tooltip(true);
web_view.hovering_over_link.connect(on_hovering_over_link);
- web_view.link_selected.connect((link) => { link_selected(link); });
-
+ web_view.link_selected.connect((link) => { link_activated(link); });
+
// if (email.from != null && email.from.contains_normalized(current_account_information.email)) {
// // XXX set a RO property?
// get_style_context().add_class("sent");
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index 6c68744..9fa2452 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -52,8 +52,11 @@ public class ConversationViewer : Gtk.Stack {
COUNT;
}
- // Fired when the user clicks a link.
- public signal void link_selected(string link);
+ // Fired a message is added to the view
+ public signal void message_added(ConversationMessage message);
+
+ // Fired a message is removed from the view
+ public signal void message_removed(ConversationMessage message);
// Fired when the user clicks "reply" in the message menu.
public signal void reply_to_message(Geary.Email message);
@@ -632,8 +635,8 @@ public class ConversationViewer : Gtk.Stack {
}
messages.add(email);
- ConversationMessage message = new ConversationMessage(email, current_folder);
- message.link_selected.connect((link) => { link_selected(link); });
+ ConversationMessage message =
+ new ConversationMessage(email, current_folder);
message.body_box.button_release_event.connect_after((event) => {
// Consume all non-consumed clicks so the row is not
// inadvertently activated after clicking on the
@@ -651,6 +654,8 @@ public class ConversationViewer : Gtk.Stack {
if (email.is_unread() == Geary.Trillian.TRUE) {
show_message(row, false);
}
+
+ message_added(message);
// Update the search results
//if (conversation_find_bar.visible)
@@ -658,7 +663,9 @@ public class ConversationViewer : Gtk.Stack {
}
private void remove_message(Geary.Email email) {
- conversation_listbox.remove(email_to_row.get(email.id));
+ Gtk.ListBoxRow row = email_to_row.get(email.id);
+ message_removed((ConversationMessage) row.get_child());
+ conversation_listbox.remove(row);
email_to_row.get(email.id);
messages.remove(email);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]