8000 Trash threads in index and view modes by e11o · Pull Request #589 · astroidmail/astroid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Trash threads in index and view modes #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
9 changes: 9 additions & 0 deletions src/actions/toggle_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ namespace Astroid {
MuteAction::MuteAction (vector<refptr<NotmuchItem>> nmts)
: ToggleAction (nmts, "muted") {
}

TrashAction::TrashAction (refptr<NotmuchItem> nmt)
: ToggleAction (nmt, "trash") {
}

TrashAction::TrashAction (vector<refptr<NotmuchItem>> nmts)
: ToggleAction (nmts, "trash") {
}

}
6 changes: 6 additions & 0 deletions src/actions/toggle_action.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ namespace Astroid {
MuteAction (std::vector<refptr<NotmuchItem>>);
};

class TrashAction : public ToggleAction {
public:
TrashAction (refptr<NotmuchItem>);
TrashAction (std::vector<refptr<NotmuchItem>>);
};

}

39 changes: 39 additions & 0 deletions src/modes/thread_index/thread_index_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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<Action>(new TrashAction(thread)));
}

return true;
});

keys->register_key (Key (GDK_KEY_asterisk), "thread_index.flag",
"Toggle 'flagged' tag on thread",
[&] (Key) {
Expand Down Expand Up @@ -1047,6 +1073,7 @@ namespace Astroid {
case MSpam:
case MMute:
case MArchive:
case MTrash:
case MTag:
{
vector<refptr<NotmuchItem>> threads;
Expand All @@ -1070,6 +1097,10 @@ namespace Astroid {
a = refptr<Action>(new ToggleAction(threads, "inbox"));
break;

case MTrash:
a = refptr<Action>(new TrashAction(threads));
break;

case MFlag:
a = refptr<Action>(new ToggleAction(threads, "flagged"));
break;
Expand Down Expand Up @@ -1205,6 +1236,14 @@ namespace Astroid {
}
break;

case Trash:
{
if (thread) {
main_window->actions->doit (refptr<Action>(new TrashAction(thread)));
}
}
break;

case Open:
{
if (thread) {
Expand Down
2 changes: 2 additions & 0 deletions src/modes/thread_index/thread_index_list_view.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace Astroid {
MUnread = 0,
MFlag,
MArchive,
MTrash,
MSpam,
MMute,
MToggle,
Expand All @@ -103,6 +104,7 @@ namespace Astroid {
Forward,
Flag,
Archive,
Trash,
Open,
OpenNewWindow,
};
Expand Down
67 changes: 67 additions & 0 deletions src/modes/thread_view/thread_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Action>(new TrashAction(thread)));
}
}

return true;
});

keys.register_key ("C-P",
"thread_view.print",
"Print focused message",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
0