[geary/wip/draft-management: 2/4] Allow saving drafts when closing composer due to view change



commit 5588fc7e156ec3e769327b98e27f336140ae24f4
Author: Michael Gratton <mike vee net>
Date:   Mon Jul 22 22:02:49 2019 +1000

    Allow saving drafts when closing composer due to view change
    
    Use the composer's built-in confirm dialog when deciding to close
    inline composers due to a new folder/conversation being selected.
    
    See #290

 src/client/application/application-controller.vala | 24 +++++++---------------
 1 file changed, 7 insertions(+), 17 deletions(-)
---
diff --git a/src/client/application/application-controller.vala 
b/src/client/application/application-controller.vala
index c1770eea..e493977d 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -2116,26 +2116,16 @@ public class Application.Controller : Geary.BaseObject {
 
         // Find out what to do with the inline composers.
         // TODO: Remove this in favor of automatically saving drafts
-        Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
         this.main_window.present();
+        bool create_okay = true;
         foreach (ComposerWidget cw in composer_widgets) {
-            if (cw.state != ComposerWidget.ComposerState.DETACHED)
-                composers_to_destroy.add(cw);
-        }
-        string message = ngettext(
-            "Close the draft message?",
-            "Close all draft messages?",
-            composers_to_destroy.size
-        );
-        ConfirmationDialog dialog = new ConfirmationDialog(
-            main_window, message, null, Stock._CLOSE, "destructive-action"
-        );
-        if (dialog.run() == Gtk.ResponseType.OK) {
-            foreach(ComposerWidget cw in composers_to_destroy)
-                ((ComposerContainer) cw.parent).close_container();
-            return true;
+            if (cw.state != ComposerWidget.ComposerState.DETACHED &&
+                cw.should_close() == ComposerWidget.CloseStatus.CANCEL_CLOSE) {
+                create_okay = false;
+                break;
+            }
         }
-        return false;
+        return create_okay;
     }
 
     public bool can_switch_conversation_view() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]