[geary/wip/765516-gtk-widget-conversation-viewer: 158/207] Tidy up conversation viewer widget signal handling a bit.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer: 158/207] Tidy up conversation viewer widget signal handling a bit.
- Date: Tue, 4 Oct 2016 00:09:42 +0000 (UTC)
commit 1fab9ad273cdf62b6d858b92d608b277ebf81ba9
Author: Michael James Gratton <mike vee net>
Date: Mon Aug 22 23:15:20 2016 +1000
Tidy up conversation viewer widget signal handling a bit.
* src/client/application/geary-controller.vala: Remove unneeded manual
conversation list and email signal disconnects - let the object's
finalisers do it. Replace one- or two-line, single-use signal handlers
with lambdas.
* src/client/conversation-viewer/conversation-email.vala
(ConversationEmail): Removed signal handlers that were simply proxying
through from ConversationMessage, update call sites to connect to the
message's signals directly.
* src/client/conversation-viewer/conversation-message.vala: Replace one-
or two-line, single-use signal handlers with lambdas.
src/client/application/geary-controller.vala | 81 ++++++++------------
.../conversation-viewer/conversation-email.vala | 12 ---
.../conversation-viewer/conversation-message.vala | 18 ++---
3 files changed, 38 insertions(+), 73 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index db1dedd..bf05fbb 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -224,9 +224,6 @@ public class GearyController : Geary.BaseObject {
main_window.conversation_viewer.conversation_added.connect(
on_conversation_view_added
);
- main_window.conversation_viewer.conversation_removed.connect(
- on_conversation_view_removed
- );
new_messages_monitor = new NewMessagesMonitor(should_notify_new_messages);
main_window.folder_list.set_new_messages_monitor(new_messages_monitor);
@@ -301,9 +298,6 @@ public class GearyController : Geary.BaseObject {
main_window.conversation_viewer.conversation_added.disconnect(
on_conversation_view_added
);
- main_window.conversation_viewer.conversation_removed.disconnect(
- on_conversation_view_removed
- );
// hide window while shutting down, as this can take a few seconds under certain conditions
main_window.hide();
@@ -526,7 +520,10 @@ public class GearyController : Geary.BaseObject {
entries += zoom_normal;
add_accelerator("0", ACTION_ZOOM_NORMAL);
- Gtk.ActionEntry search = { ACTION_SEARCH, null, null, "<Ctrl>S", null, on_search };
+ Gtk.ActionEntry search = {
+ ACTION_SEARCH, null, null, "<Ctrl>S", null,
+ () => { show_search_bar(); }
+ };
entries += search;
Gtk.ActionEntry conversation_list = { ACTION_CONVERSATION_LIST, null, null, "<Ctrl>B", null,
on_conversation_list };
@@ -2699,10 +2696,6 @@ public class GearyController : Geary.BaseObject {
}
}
- private void on_search() {
- main_window.search_bar.give_search_focus();
- }
-
private void on_conversation_list() {
main_window.conversation_list_view.grab_focus();
}
@@ -2713,55 +2706,36 @@ public class GearyController : Geary.BaseObject {
private void on_conversation_view_added(ConversationListBox list) {
list.email_added.connect(on_conversation_viewer_email_added);
- list.email_removed.connect(on_conversation_viewer_email_removed);
list.mark_emails.connect(on_conversation_viewer_mark_emails);
}
- private void on_conversation_view_removed(ConversationListBox list) {
- list.email_added.disconnect(on_conversation_viewer_email_added);
- list.email_removed.disconnect(on_conversation_viewer_email_removed);
- list.mark_emails.disconnect(on_conversation_viewer_mark_emails);
- }
-
private void on_conversation_viewer_email_added(ConversationEmail view) {
+ view.attachments_activated.connect(on_attachments_activated);
view.reply_to_message.connect(on_reply_to_message);
view.reply_all_message.connect(on_reply_all_message);
view.forward_message.connect(on_forward_message);
- view.link_activated.connect(on_link_activated);
- view.attachments_activated.connect(on_attachments_activated);
+ view.edit_draft.connect((draft_view) => {
+ create_compose_widget(
+ ComposerWidget.ComposeType.NEW_MESSAGE,
+ draft_view.email, null, null, true
+ );
+ });
+ view.message_view_iterator().foreach((mview) => {
+ mview.link_activated.connect((link) => {
+ if (link.down().has_prefix(
+ Geary.ComposedEmail.MAILTO_SCHEME)) {
+ compose_mailto(link);
+ } else {
+ open_uri(link);
+ }
+ });
+ mview.save_image.connect(on_save_buffer_to_file);
+ return true;
+ });
view.save_attachments.connect(on_save_attachments);
- view.edit_draft.connect(on_edit_draft);
view.view_source.connect(on_view_source);
- view.save_image.connect(on_save_buffer_to_file);
- }
-
- private void on_conversation_viewer_email_removed(ConversationEmail view) {
- view.reply_to_message.disconnect(on_reply_to_message);
- view.reply_all_message.disconnect(on_reply_all_message);
- view.forward_message.disconnect(on_forward_message);
- view.link_activated.disconnect(on_link_activated);
- view.attachments_activated.disconnect(on_attachments_activated);
- view.save_attachments.disconnect(on_save_attachments);
- view.edit_draft.disconnect(on_edit_draft);
- view.view_source.disconnect(on_view_source);
- view.save_image.disconnect(on_save_buffer_to_file);
}
- private void on_link_activated(string link) {
- if (link.down().has_prefix(Geary.ComposedEmail.MAILTO_SCHEME)) {
- compose_mailto(link);
- } else {
- open_uri(link);
- }
- }
-
- 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(ConversationEmail email_view) {
string source = (email_view.email.header.buffer.to_string() +
email_view.email.body.buffer.to_string());
@@ -2892,7 +2866,14 @@ public class GearyController : Geary.BaseObject {
return ret.size >= 1 ? ret : null;
}
-
+
+ private void show_search_bar(string? text = null) {
+ main_window.search_bar.give_search_focus();
+ if (text != null) {
+ main_window.search_bar.set_search_text(text);
+ }
+ }
+
private void do_search(string search_text) {
Geary.SearchFolder? folder = null;
try {
diff --git a/src/client/conversation-viewer/conversation-email.vala
b/src/client/conversation-viewer/conversation-email.vala
index 463a075..d7934b3 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -332,12 +332,6 @@ public class ConversationEmail : Gtk.Box {
Geary.NamedFlag? to_add, Geary.NamedFlag? to_remove
);
- /** Fired when the user saves an inline displayed image. */
- public signal void save_image(string? filename, Geary.Memory.Buffer buffer);
-
- /** Fired when the user clicks a link in the email. */
- public signal void link_activated(string link);
-
/** Fired when the user activates an attachment. */
public signal void attachments_activated(
Gee.Collection<Geary.Attachment> attachments
@@ -602,12 +596,6 @@ public class ConversationEmail : Gtk.Box {
view.attachment_displayed_inline.connect((id) => {
inlined_content_ids.add(id);
});
- view.link_activated.connect((link) => {
- link_activated(link);
- });
- view.save_image.connect((filename, buffer) => {
- save_image(filename, buffer);
- });
view.web_view.selection_changed.connect(() => {
on_message_selection_changed(view);
});
diff --git a/src/client/conversation-viewer/conversation-message.vala
b/src/client/conversation-viewer/conversation-message.vala
index 9e847d8..250a9e7 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -224,11 +224,16 @@ public class ConversationMessage : Gtk.Grid {
this.context_menu_element = null;
});
add_action(ACTION_OPEN_LINK, true, VariantType.STRING)
- .activate.connect(on_open_link);
+ .activate.connect((param) => {
+ link_activated(param.get_string());
+ });
+ add_action(ACTION_SAVE_IMAGE, true).activate.connect((param) => {
+ ReplacedImage? replaced_image = get_replaced_image();
+ save_image(replaced_image.filename, replaced_image.buffer);
+ });
add_action(ACTION_SELECT_ALL, true).activate.connect(() => {
web_view.select_all();
});
- add_action(ACTION_SAVE_IMAGE, true).activate.connect(on_save_image);
insert_action_group("msg", message_actions);
@@ -1322,13 +1327,4 @@ public class ConversationMessage : Gtk.Grid {
clipboard.store();
}
- private void on_open_link(Variant? param) {
- link_activated(param.get_string());
- }
-
- private void on_save_image() {
- ReplacedImage? replaced_image = get_replaced_image();
- save_image(replaced_image.filename, replaced_image.buffer);
- }
-
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]