diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala index 9f156f6d..515f663a 100644 --- a/src/client/application/geary-controller.vala +++ b/src/client/application/geary-controller.vala @@ -213,8 +213,6 @@ public class GearyController : Geary.BaseObject { main_window.conversation_viewer.mark_messages.connect(on_conversation_viewer_mark_messages); main_window.conversation_viewer.save_attachments.connect(on_save_attachments); main_window.conversation_viewer.save_buffer_to_file.connect(on_save_buffer_to_file); - main_window.conversation_viewer.edit_draft.connect(on_edit_draft); - new_messages_monitor = new NewMessagesMonitor(should_notify_new_messages); main_window.folder_list.set_new_messages_monitor(new_messages_monitor); @@ -294,8 +292,6 @@ public class GearyController : Geary.BaseObject { main_window.conversation_viewer.mark_messages.disconnect(on_conversation_viewer_mark_messages); main_window.conversation_viewer.save_attachments.disconnect(on_save_attachments); main_window.conversation_viewer.save_buffer_to_file.disconnect(on_save_buffer_to_file); - main_window.conversation_viewer.edit_draft.disconnect(on_edit_draft); - // hide window while shutting down, as this can take a few seconds under certain conditions main_window.hide(); @@ -1495,10 +1491,6 @@ public class GearyController : Geary.BaseObject { on_edit_draft(activated.get_latest_recv_email(Geary.App.Conversation.Location.IN_FOLDER)); } - private void on_edit_draft(Geary.Email draft) { - 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); @@ -2589,11 +2581,13 @@ public class GearyController : Geary.BaseObject { private void on_message_added(ConversationMessage message) { message.link_activated.connect(on_link_activated); message.attachment_activated.connect(on_attachment_activated); + message.edit_draft.connect(on_edit_draft); } private void on_message_removed(ConversationMessage message) { message.link_activated.disconnect(on_link_activated); message.attachment_activated.disconnect(on_attachment_activated); + message.edit_draft.disconnect(on_edit_draft); } private void on_link_activated(string link) { @@ -2604,6 +2598,10 @@ public class GearyController : Geary.BaseObject { } } + private void on_edit_draft(Geary.Email draft) { + create_compose_widget(ComposerWidget.ComposeType.NEW_MESSAGE, draft, null, null, true); + } + // Disables all single-message buttons and enables all multi-message buttons. public void enable_multiple_message_buttons() { update_tooltips(); diff --git a/src/client/conversation-viewer/conversation-message.vala b/src/client/conversation-viewer/conversation-message.vala index 38c54173..5fcae62d 100644 --- a/src/client/conversation-viewer/conversation-message.vala +++ b/src/client/conversation-viewer/conversation-message.vala @@ -121,6 +121,9 @@ public class ConversationMessage : Gtk.Box { // The folder containing the message private Geary.Folder containing_folder = null; // XXX weak?? + [GtkChild] + private Gtk.InfoBar draft_infobar; + // Contains the current mouse-over'ed link URL, if any private string? hover_url = null; @@ -136,8 +139,13 @@ public class ConversationMessage : Gtk.Box { // Fired on attachment activation public signal void attachment_activated(Geary.Attachment attachment); + // Fired the edit draft button is clicked. + public signal void edit_draft(Geary.Email message); - public ConversationMessage(Geary.Email email, Geary.Folder containing_folder) { + + public ConversationMessage(Geary.Email email, + Geary.Folder containing_folder, + bool is_draft) { this.email = email; this.containing_folder = containing_folder; @@ -226,19 +234,10 @@ public class ConversationMessage : Gtk.Box { // debug("Error adding attached message: %s", error.message); // } // } - - // // Edit draft button for drafts folder. - // if (in_drafts_folder() && is_in_folder) { - // WebKit.DOM.HTMLElement draft_edit_container = Util.DOM.select(div_message, ".draft_edit"); - // WebKit.DOM.HTMLElement draft_edit_button = - // Util.DOM.select(div_message, ".draft_edit_button"); - // try { - // draft_edit_container.set_attribute("style", "display:block"); - // draft_edit_button.set_inner_html(_("Edit Draft")); - // } catch (Error e) { - // warning("Error setting draft button: %s", e.message); - // } - // } + + if (is_draft) { + draft_infobar.show(); + } update_message_state(false); } @@ -1105,10 +1104,6 @@ public class ConversationMessage : Gtk.Box { } } - // private bool in_drafts_folder() { - // return containing_folder.special_folder_type == Geary.SpecialFolderType.DRAFTS; - // } - private static bool is_content_type_supported_inline(Geary.Mime.ContentType content_type) { foreach (string mime_type in INLINE_MIME_TYPES) { try { @@ -1118,7 +1113,7 @@ public class ConversationMessage : Gtk.Box { debug("Unable to compare MIME type %s: %s", mime_type, err.message); } } - + return false; } @@ -1348,10 +1343,9 @@ public class ConversationMessage : Gtk.Box { body_box.trigger_tooltip_query(); } - + [GtkCallback] - private void on_remote_images_response(Gtk.InfoBar info_bar, - int response_id) { + private void on_remote_images_response(Gtk.InfoBar info_bar, int response_id) { switch (response_id) { case 1: show_images(true); @@ -1362,10 +1356,17 @@ public class ConversationMessage : Gtk.Box { default: break; // pass } - + remote_images_infobar.hide(); } - + + [GtkCallback] + private void on_draft_response(Gtk.InfoBar info_bar, int response_id) { + if (response_id == 1) { + edit_draft(email); + } + } + // private void on_copy_text() { // web_view.copy_clipboard(); // } diff --git a/src/client/conversation-viewer/conversation-viewer.vala b/src/client/conversation-viewer/conversation-viewer.vala index 3345f130..ae52f80f 100644 --- a/src/client/conversation-viewer/conversation-viewer.vala +++ b/src/client/conversation-viewer/conversation-viewer.vala @@ -80,9 +80,6 @@ public class ConversationViewer : Gtk.Stack { // Fired when the user wants to save an image buffer to disk public signal void save_buffer_to_file(string? filename, Geary.Memory.Buffer buffer); - // Fired when the user clicks the edit draft button. - public signal void edit_draft(Geary.Email message); - // Fired when the viewer has been cleared. public signal void cleared(); @@ -636,8 +633,16 @@ public class ConversationViewer : Gtk.Stack { } messages.add(email); + // XXX Should be able to edit draft messages from any + // conversation. This test should be more like "is in drafts + // folder" + bool is_draft = ( + current_folder.special_folder_type == Geary.SpecialFolderType.DRAFTS && + is_in_folder + ); + ConversationMessage message = - new ConversationMessage(email, current_folder); + new ConversationMessage(email, current_folder, is_draft); 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 diff --git a/ui/conversation-message.ui b/ui/conversation-message.ui index c710aa3f..69890c2d 100644 --- a/ui/conversation-message.ui +++ b/ui/conversation-message.ui @@ -609,6 +609,89 @@ 1 + + + True + False + True + warning + + + + False + 6 + end + + + Edit Draft + True + True + True + + + True + True + 1 + + + + + True + False + 0 + + + + + False + vertical + 2 + + + True + False + Draft message + 0 + + + + + + True + True + 0 + + + + + True + False + This message has not yet been sent. + 0 + + + True + True + 1 + + + + + True + True + 0 + + + + button3 + + + + True + True + 2 + +