Commit 7f4a80ce authored by Charles Lindsay's avatar Charles Lindsay

Prompt before deleting messages

Closes: bgo #713875
parent 7bcdd232
......@@ -1337,9 +1337,12 @@ public class GearyController : Geary.BaseObject {
}
private void on_shift_key(bool pressed) {
main_window.main_toolbar.update_trash_buttons(
(!pressed && current_folder_supports_trash()) || !(current_folder is Geary.FolderSupport.Remove),
current_account.can_support_archive);
if (main_window != null && main_window.main_toolbar != null
&& current_account != null && current_folder != null) {
main_window.main_toolbar.update_trash_buttons(
(!pressed && current_folder_supports_trash()) || !(current_folder is Geary.FolderSupport.Remove),
current_account.can_support_archive);
}
}
// this signal does not necessarily indicate that the application previously didn't have
......@@ -1921,6 +1924,16 @@ public class GearyController : Geary.BaseObject {
return false;
}
public bool confirm_delete(int num_messages) {
main_window.present();
AlertDialog dialog = new ConfirmationDialog(main_window, ngettext(
"Do you want to permanently delete this message?",
"Do you want to permanently delete these messages?", num_messages),
null, _("Delete"));
return (dialog.run() == Gtk.ResponseType.OK);
}
private async void archive_or_delete_selection_async(bool archive, bool trash,
Cancellable? cancellable) throws Error {
if (main_window.conversation_viewer.current_conversation != null
......@@ -1963,10 +1976,14 @@ public class GearyController : Geary.BaseObject {
debug("Deleting selected messages");
Geary.FolderSupport.Remove? supports_remove = current_folder as Geary.FolderSupport.Remove;
if (supports_remove == null)
if (supports_remove == null) {
debug("Folder %s doesn't support remove", current_folder.to_string());
else
yield supports_remove.remove_email_async(ids, cancellable);
} else {
if (confirm_delete(ids.size))
yield supports_remove.remove_email_async(ids, cancellable);
else
last_deleted_conversation = null;
}
}
private void on_archive_or_delete_selection_finished(Object? source, AsyncResult result) {
......
......@@ -38,7 +38,8 @@ public class MainWindow : Gtk.ApplicationWindow {
conversation_list_view = new ConversationListView(conversation_list_store);
add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK);
add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK
| Gdk.EventMask.FOCUS_CHANGE_MASK);
// This code both loads AND saves the pane positions with live
// updating. This is more resilient against crashes because
......@@ -63,6 +64,7 @@ public class MainWindow : Gtk.ApplicationWindow {
delete_event.connect(on_delete_event);
key_press_event.connect(on_key_press_event);
key_release_event.connect(on_key_release_event);
focus_in_event.connect(on_focus_event);
GearyApplication.instance.controller.notify[GearyController.PROP_CURRENT_CONVERSATION].
connect(on_conversation_monitor_changed);
Geary.Engine.instance.account_available.connect(on_account_available);
......@@ -188,6 +190,11 @@ public class MainWindow : Gtk.ApplicationWindow {
return propagate_key_event(event);
}
private bool on_focus_event() {
on_shift_key(false);
return false;
}
private void on_conversation_monitor_changed() {
Geary.App.ConversationMonitor? conversation_monitor =
GearyApplication.instance.controller.current_conversations;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment