diff --git a/src/actions/toggle_action.cc b/src/actions/toggle_action.cc index d13eae468..426f63cb7 100644 --- a/src/actions/toggle_action.cc +++ b/src/actions/toggle_action.cc @@ -72,4 +72,13 @@ namespace Astroid { MuteAction::MuteAction (vector> nmts) : ToggleAction (nmts, "muted") { } + + TrashAction::TrashAction (refptr nmt) + : ToggleAction (nmt, "trash") { + } + + TrashAction::TrashAction (vector> nmts) + : ToggleAction (nmts, "trash") { + } + } diff --git a/src/actions/toggle_action.hh b/src/actions/toggle_action.hh index 50e6fa014..eb420b383 100644 --- a/src/actions/toggle_action.hh +++ b/src/actions/toggle_action.hh @@ -29,5 +29,11 @@ namespace Astroid { MuteAction (std::vector>); }; + class TrashAction : public ToggleAction { + public: + TrashAction (refptr); + TrashAction (std::vector>); + }; + } diff --git a/src/modes/thread_index/thread_index_list_view.cc b/src/modes/thread_index/thread_index_list_view.cc index d716db111..fed86fba5 100644 --- a/src/modes/thread_index/thread_index_list_view.cc +++ b/src/modes/thread_index/thread_index_list_view.cc @@ -167,10 +167,20 @@ namespace Astroid { , PopupItem::Archive)); archive_i->set_tooltip_text ("Archive"); + Gtk::Image * trash = Gtk::manage (new Gtk::Image ()); + trash->set_from_icon_name ("edit-delete", Gtk::ICON_SIZE_LARGE_TOOLBAR); + Gtk::MenuItem * trash_i = Gtk::manage (new Gtk::MenuItem (*trash)); + trash_i->signal_activate ().connect ( + sigc::bind ( + sigc::mem_fun (*this, &ThreadIndexListView::popup_activate_generic) + , PopupItem::Trash)); + trash_i->set_tooltip_text ("Send to Trash"); + item_popup.attach (*reply_i, 0, 1, 0, 1); item_popup.attach (*forward_i, 1, 2, 0, 1); item_popup.attach (*flag_i, 2, 3, 0, 1); item_popup.attach (*archive_i, 3, 4, 0, 1); + item_popup.attach (*trash_i, 4, 5, 0, 1); Gtk::MenuItem * sep = Gtk::manage (new Gtk::SeparatorMenuItem ()); item_popup.append (*sep); @@ -489,6 +499,11 @@ namespace Astroid { "Toggle archive", bind (&ThreadIndexListView::multi_key_handler, this, MArchive, _1)); + multi_keys.register_key ("d", + "thread_index.multi.trash", + "Toggle trash", + bind (&ThreadIndexListView::multi_key_handler, this, MTrash, _1)); + multi_keys.register_key ("S", "thread_index.multi.mark_spam", "Toggle spam", @@ -877,6 +892,17 @@ namespace Astroid { return true; }); + keys->register_key ("d", "thread_index.trash", + "Toggle 'trash' tag on thread", + [&] (Key) { + auto thread = get_current_thread (); + if (thread) { + main_window->actions->doit (refptr(new TrashAction(thread))); + } + + return true; + }); + keys->register_key (Key (GDK_KEY_asterisk), "thread_index.flag", "Toggle 'flagged' tag on thread", [&] (Key) { @@ -1047,6 +1073,7 @@ namespace Astroid { case MSpam: case MMute: case MArchive: + case MTrash: case MTag: { vector> threads; @@ -1070,6 +1097,10 @@ namespace Astroid { a = refptr(new ToggleAction(threads, "inbox")); break; + case MTrash: + a = refptr(new TrashAction(threads)); + break; + case MFlag: a = refptr(new ToggleAction(threads, "flagged")); break; @@ -1205,6 +1236,14 @@ namespace Astroid { } break; + case Trash: + { + if (thread) { + main_window->actions->doit (refptr(new TrashAction(thread))); + } + } + break; + case Open: { if (thread) { diff --git a/src/modes/thread_index/thread_index_list_view.hh b/src/modes/thread_index/thread_index_list_view.hh index a74041eef..0ba99cf97 100644 --- a/src/modes/thread_index/thread_index_list_view.hh +++ b/src/modes/thread_index/thread_index_list_view.hh @@ -85,6 +85,7 @@ namespace Astroid { MUnread = 0, MFlag, MArchive, + MTrash, MSpam, MMute, MToggle, @@ -103,6 +104,7 @@ namespace Astroid { Forward, Flag, Archive, + Trash, Open, OpenNewWindow, }; diff --git a/src/modes/thread_view/thread_view.cc b/src/modes/thread_view/thread_view.cc index 8196f9827..853253202 100644 --- a/src/modes/thread_view/thread_view.cc +++ b/src/modes/thread_view/thread_view.cc @@ -1397,6 +1397,20 @@ namespace Astroid { return true; }); + keys.register_key (Key (GDK_KEY_Delete), + "thread_view.trash_thread", + "Toggle 'trash' tag on the whole thread", + [&] (Key) { + + if (!edit_mode && focused_message) { + if (thread) { + main_window->actions->doit (refptr(new TrashAction(thread))); + } + } + + return true; + }); + keys.register_key ("C-P", "thread_view.print", "Print focused message", @@ -1580,6 +1594,16 @@ namespace Astroid { return true; }); + next_multi.register_key (UnboundKey(), + "thread_view.multi_next_thread.trash", + "Trash and goto next", + [&] (Key) { + keys.handle ("thread_view.trash_thread"); + emit_index_action (IA_Next); + + return true; + }); + next_multi.register_key (Key ("A"), "thread_view.multi_next_thread.archive_next_unread_thread", "Archive, goto next unread", @@ -1590,6 +1614,16 @@ namespace Astroid { return true; }); + next_multi.register_key (UnboundKey(), + "thread_view.multi_next_thread.trash_next_unread_thread", + "Trash and goto next unread", + [&] (Key) { + keys.handle ("thread_view.archive_trash"); + emit_index_action (IA_NextUnread); + + return true; + }); + next_multi.register_key (Key ("x"), "thread_view.multi_next_thread.close", "Archive, close", @@ -1600,6 +1634,16 @@ namespace Astroid { return true; }); + next_multi.register_key ("d", + "thread_view.multi_next_thread.trash_close", + "Trash and close", + [&] (Key) { + keys.handle ("thread_view.trash_thread"); + close (); + + return true; + }); + next_multi.register_key (Key ("j"), "thread_view.multi_next_thread.next_thread", "Goto next", @@ -1658,6 +1702,29 @@ namespace Astroid { return next_multi.handle ("thread_view.multi_next_thread.close"); }); + keys.register_key (UnboundKey (), + "thread_view.trash_then_next", + "Alias for thread_view.multi_next_thread.trash", + [&] (Key) { + return next_multi.handle ("thread_view.multi_next_thread.trash"); + }); + + keys.register_key (UnboundKey (), + "thread_view.trash_then_next_unread", + "Alias for thread_view.multi_next_thread.trash_next_unread", + [&] (Key) { + return next_multi.handle ("thread_view.multi_next_thread.trash_next_unread_thread"); + }); + + keys.register_key ("d", + "thread_view.trash_and_close", + "Alias for thread_view.multi_next_thread.trash_close", + [&] (Key) { + if (edit_mode) return false; + + return next_multi.handle ("thread_view.multi_next_thread.trash_close"); + }); + keys.register_key (UnboundKey (), "thread_view.next_thread", "Alias for thread_view.multi_next_thread.next_thread",