From 4a6ca1510b542ff03b2e01a493b34868c23aed45 Mon Sep 17 00:00:00 2001 From: Esteban Sancho Date: Sat, 27 Oct 2018 23:51:01 -0400 Subject: [PATCH 1/6] Trash is working on single and multiple threads. --- src/actions/toggle_action.cc | 9 ++++++ src/actions/toggle_action.hh | 6 ++++ .../thread_index/thread_index_list_view.cc | 29 +++++++++++++++++++ .../thread_index/thread_index_list_view.hh | 2 ++ 4 files changed, 46 insertions(+) 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 3469b2ebe..b08035149 100644 --- a/src/modes/thread_index/thread_index_list_view.cc +++ b/src/modes/thread_index/thread_index_list_view.cc @@ -487,6 +487,11 @@ namespace Astroid { "Toggle archive", bind (&ThreadIndexListView::multi_key_handler, this, MArchive, _1)); + multi_keys.register_key (Key (GDK_KEY_Delete), + "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", @@ -875,6 +880,17 @@ namespace Astroid { return true; }); + keys->register_key (Key (GDK_KEY_Delete), "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) { @@ -1045,6 +1061,7 @@ namespace Astroid { case MSpam: case MMute: case MArchive: + case MTrash: case MTag: { vector> threads; @@ -1068,6 +1085,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; @@ -1203,6 +1224,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, }; From 1687a203855de7536649809d0319f120dabb8f27 Mon Sep 17 00:00:00 2001 From: Esteban Sancho Date: Sat, 27 Oct 2018 23:51:01 -0400 Subject: [PATCH 2/6] Trash is working from thread_index for single and multiple threads. --- src/actions/toggle_action.cc | 9 ++++++ src/actions/toggle_action.hh | 6 ++++ .../thread_index/thread_index_list_view.cc | 29 +++++++++++++++++++ .../thread_index/thread_index_list_view.hh | 2 ++ 4 files changed, 46 insertions(+) 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 3469b2ebe..b08035149 100644 --- a/src/modes/thread_index/thread_index_list_view.cc +++ b/src/modes/thread_index/thread_index_list_view.cc @@ -487,6 +487,11 @@ namespace Astroid { "Toggle archive", bind (&ThreadIndexListView::multi_key_handler, this, MArchive, _1)); + multi_keys.register_key (Key (GDK_KEY_Delete), + "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", @@ -875,6 +880,17 @@ namespace Astroid { return true; }); + keys->register_key (Key (GDK_KEY_Delete), "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) { @@ -1045,6 +1061,7 @@ namespace Astroid { case MSpam: case MMute: case MArchive: + case MTrash: case MTag: { vector> threads; @@ -1068,6 +1085,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; @@ -1203,6 +1224,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, }; From d9cb57b12ad1b841e953b47858a68bdcf08fdabf Mon Sep 17 00:00:00 2001 From: Esteban Sancho Date: Sun, 28 Oct 2018 00:09:31 -0400 Subject: [PATCH 3/6] Adding trash entry to right-click menu on thread_index --- src/modes/thread_index/thread_index_list_view.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modes/thread_index/thread_index_list_view.cc b/src/modes/thread_index/thread_index_list_view.cc index b08035149..4a1fa8066 100644 --- a/src/modes/thread_index/thread_index_list_view.cc +++ b/src/modes/thread_index/thread_index_list_view.cc @@ -165,10 +165,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); From b7a347fb7368b3955fdb0ff4c17c3d003c08ea5d Mon Sep 17 00:00:00 2001 From: Esteban Sancho Date: Sun, 28 Oct 2018 10:26:59 -0400 Subject: [PATCH 4/6] Sending to trash works in thread_view mode --- src/modes/thread_view/thread_view.cc | 65 ++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/modes/thread_view/thread_view.cc b/src/modes/thread_view/thread_view.cc index 9843cde45..00d0b5b90 100644 --- a/src/modes/thread_view/thread_view.cc +++ b/src/modes/thread_view/thread_view.cc @@ -1385,6 +1385,20 @@ namespace Astroid { return true; }); + keys.register_key (Key (GDK_KEY_BackSpace), + "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", @@ -1568,6 +1582,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", @@ -1578,6 +1602,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", @@ -1588,6 +1622,16 @@ namespace Astroid { return true; }); + next_multi.register_key (Key (GDK_KEY_Delete), + "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", @@ -1646,6 +1690,27 @@ 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 (Key (GDK_KEY_Delete), + "thread_view.trash_and_close", + "Alias for thread_view.multi_next_thread.trash_close", + [&] (Key) { + 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", From d463681080aa8cbdd1c2500cd5ee50467005be36 Mon Sep 17 00:00:00 2001 From: Esteban Sancho Date: Fri, 17 Apr 2020 20:39:57 -0400 Subject: [PATCH 5/6] Changing trash keybindings --- src/modes/thread_view/thread_view.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modes/thread_view/thread_view.cc b/src/modes/thread_view/thread_view.cc index c5b95a220..853253202 100644 --- a/src/modes/thread_view/thread_view.cc +++ b/src/modes/thread_view/thread_view.cc @@ -1397,7 +1397,7 @@ namespace Astroid { return true; }); - keys.register_key (Key (GDK_KEY_BackSpace), + keys.register_key (Key (GDK_KEY_Delete), "thread_view.trash_thread", "Toggle 'trash' tag on the whole thread", [&] (Key) { @@ -1634,7 +1634,7 @@ namespace Astroid { return true; }); - next_multi.register_key (Key (GDK_KEY_Delete), + next_multi.register_key ("d", "thread_view.multi_next_thread.trash_close", "Trash and close", [&] (Key) { @@ -1716,10 +1716,12 @@ namespace Astroid { return next_multi.handle ("thread_view.multi_next_thread.trash_next_unread_thread"); }); - keys.register_key (Key (GDK_KEY_Delete), + 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"); }); From 5c0783deb09b9e6b1401a5dd2940d089570c7c96 Mon Sep 17 00:00:00 2001 From: Esteban Sancho Date: Sat, 18 Apr 2020 12:33:54 -0400 Subject: [PATCH 6/6] Changing default key binding for trashing in index list to "d" --- src/modes/thread_index/thread_index_list_view.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modes/thread_index/thread_index_list_view.cc b/src/modes/thread_index/thread_index_list_view.cc index 4b72b87f9..fed86fba5 100644 --- a/src/modes/thread_index/thread_index_list_view.cc +++ b/src/modes/thread_index/thread_index_list_view.cc @@ -499,7 +499,7 @@ namespace Astroid { "Toggle archive", bind (&ThreadIndexListView::multi_key_handler, this, MArchive, _1)); - multi_keys.register_key (Key (GDK_KEY_Delete), + multi_keys.register_key ("d", "thread_index.multi.trash", "Toggle trash", bind (&ThreadIndexListView::multi_key_handler, this, MTrash, _1)); @@ -892,7 +892,7 @@ namespace Astroid { return true; }); - keys->register_key (Key (GDK_KEY_Delete), "thread_index.trash", + keys->register_key ("d", "thread_index.trash", "Toggle 'trash' tag on thread", [&] (Key) { auto thread = get_current_thread ();