[geary] Prompt before deleting messages
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Prompt before deleting messages
- Date: Tue, 11 Feb 2014 02:05:47 +0000 (UTC)
commit 7f4a80ce26c0a1f051f035eab06672f712c6e587
Author: Charles Lindsay <chaz yorba org>
Date: Mon Feb 10 18:02:07 2014 -0800
Prompt before deleting messages
Closes: bgo #713875
src/client/application/geary-controller.vala | 29 ++++++++++++++++++++-----
src/client/components/main-window.vala | 9 +++++++-
2 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 13562cf..fb09d59 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -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) {
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index e6fc42b..887bd43 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]