Merge lp:~lemonboy/pantheon-mail/draft-save into lp:~elementary-apps/pantheon-mail/trunk

Proposed by The Lemon Man
Status: Merged
Approved by: Danielle Foré
Approved revision: 1998
Merged at revision: 1995
Proposed branch: lp:~lemonboy/pantheon-mail/draft-save
Merge into: lp:~elementary-apps/pantheon-mail/trunk
Diff against target: 159 lines (+37/-61)
3 files modified
src/client/application/geary-controller.vala (+32/-34)
src/client/composer/composer-headerbar.vala (+0/-1)
src/client/composer/composer-widget.vala (+5/-26)
To merge this branch: bzr merge lp:~lemonboy/pantheon-mail/draft-save
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+288036@code.launchpad.net

Commit message

Save drafts on close

Description of the change

What it says on the tin

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Okay, seems like this is partially implemented:

* Clicking away from an inline-composed draft still prompts to close or cancel
* Explicit save (which close should now do) is still present

review: Needs Fixing
1996. By The Lemon Man

One less dialog asking to save the drafts.

1997. By The Lemon Man

Rework the logic behind the draft-saving routines.

1998. By The Lemon Man

Remove the "Save Draft" button from the toolbar.

Revision history for this message
Danielle Foré (danrabbit) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/client/application/geary-controller.vala'
--- src/client/application/geary-controller.vala 2016-02-09 18:34:21 +0000
+++ src/client/application/geary-controller.vala 2016-03-03 23:27:53 +0000
@@ -2110,24 +2110,22 @@
21102110
2111 private bool close_composition_windows() {2111 private bool close_composition_windows() {
2112 Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();2112 Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
2113 bool quit_cancelled = false;
21142113
2115 // If there's composer windows open, give the user a chance to save or cancel.2114 // If there's composer windows open, give the user a chance to save or cancel.
2116 foreach(ComposerWidget cw in composer_widgets) {2115 foreach(ComposerWidget cw in composer_widgets) {
2117 // Check if we should close the window immediately, or if we need to wait.2116 // Check if we should close the window immediately, or if we need to wait.
2118 ComposerWidget.CloseStatus status = cw.should_close();2117 switch (cw.should_close()) {
2119 if (status == ComposerWidget.CloseStatus.PENDING_CLOSE) {2118 case ComposerWidget.CloseStatus.PENDING_CLOSE:
2120 // Window is currently busy saving.2119 // Window is currently busy saving.
2121 waiting_to_close.add(cw);2120 waiting_to_close.add(cw);
2122 } else if (status == ComposerWidget.CloseStatus.CANCEL_CLOSE) {2121 break;
2123 // User cancelled operation.2122
2124 quit_cancelled = true;2123 case ComposerWidget.CloseStatus.DO_CLOSE:
2125 break;2124 // Hide any existing composer windows for the moment; actually deleting the windows
2126 } else if (status == ComposerWidget.CloseStatus.DO_CLOSE) {2125 // will result in their removal from composer_windows, which could crash this loop.
2127 // Hide any existing composer windows for the moment; actually deleting the windows2126 composers_to_destroy.add(cw);
2128 // will result in their removal from composer_windows, which could crash this loop.2127 ((ComposerContainer) cw.parent).vanish();
2129 composers_to_destroy.add(cw);2128 break;
2130 ((ComposerContainer) cw.parent).vanish();
2131 }2129 }
2132 }2130 }
21332131
@@ -2135,13 +2133,6 @@
2135 foreach(ComposerWidget cw in composers_to_destroy)2133 foreach(ComposerWidget cw in composers_to_destroy)
2136 ((ComposerContainer) cw.parent).close_container();2134 ((ComposerContainer) cw.parent).close_container();
21372135
2138 // If we cancelled the quit we can bail here.
2139 if (quit_cancelled) {
2140 waiting_to_close.clear();
2141
2142 return false;
2143 }
2144
2145 // If there's still windows saving, we can't exit just yet. Hide the main window and wait.2136 // If there's still windows saving, we can't exit just yet. Hide the main window and wait.
2146 if (waiting_to_close.size > 0) {2137 if (waiting_to_close.size > 0) {
2147 main_window.hide();2138 main_window.hide();
@@ -2267,22 +2258,29 @@
2267 }2258 }
2268 }2259 }
22692260
2261 main_window.present();
2262
2270 // Find out what to do with the inline composers.2263 // Find out what to do with the inline composers.
2271 // TODO: Remove this in favor of automatically saving drafts2264 Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
2272 main_window.present();2265 foreach (ComposerWidget cw in composer_widgets) {
2273 QuestionDialog dialog = new QuestionDialog(main_window, _("Close open draft messages?"), null,2266 // Skip non-inline composers
2274 Stock._CLOSE, Stock._CANCEL);2267 if (cw.state != ComposerWidget.ComposerState.DETACHED) {
2275 if (dialog.run() == Gtk.ResponseType.OK) {2268 switch (cw.should_close()) {
2276 Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();2269 case ComposerWidget.CloseStatus.PENDING_CLOSE:
2277 foreach (ComposerWidget cw in composer_widgets) {2270 // save_and_exit_async() takes care of killing the
2278 if (cw.state != ComposerWidget.ComposerState.DETACHED)2271 // container when it's done saving the draft
2279 composers_to_destroy.add(cw);2272 break;
2273
2274 case ComposerWidget.CloseStatus.DO_CLOSE:
2275 composers_to_destroy.add(cw);
2276 break;
2277 }
2280 }2278 }
2281 foreach(ComposerWidget cw in composers_to_destroy)
2282 ((ComposerContainer) cw.parent).close_container();
2283 return true;
2284 }2279 }
2285 return false;2280 foreach(ComposerWidget cw in composers_to_destroy)
2281 ((ComposerContainer) cw.parent).close_container();
2282
2283 return true;
2286 }2284 }
22872285
2288 public bool can_switch_conversation_view() {2286 public bool can_switch_conversation_view() {
22892287
=== modified file 'src/client/composer/composer-headerbar.vala'
--- src/client/composer/composer-headerbar.vala 2016-02-05 20:21:57 +0000
+++ src/client/composer/composer-headerbar.vala 2016-03-03 23:27:53 +0000
@@ -31,7 +31,6 @@
31 detach_end.margin_start = 6;31 detach_end.margin_start = 6;
3232
33 insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_DISCARD));33 insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_DISCARD));
34 insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_SAVE));
35 Gtk.Box close_buttons = create_pill_buttons(insert, false);34 Gtk.Box close_buttons = create_pill_buttons(insert, false);
36 insert.clear();35 insert.clear();
3736
3837
=== modified file 'src/client/composer/composer-widget.vala'
--- src/client/composer/composer-widget.vala 2016-02-08 16:00:57 +0000
+++ src/client/composer/composer-widget.vala 2016-03-03 23:27:53 +0000
@@ -16,7 +16,6 @@
16 public enum CloseStatus {16 public enum CloseStatus {
17 DO_CLOSE,17 DO_CLOSE,
18 PENDING_CLOSE,18 PENDING_CLOSE,
19 CANCEL_CLOSE
20 }19 }
21 20
22 public enum ComposerState {21 public enum ComposerState {
@@ -1084,33 +1083,13 @@
1084 if (is_closing)1083 if (is_closing)
1085 return CloseStatus.PENDING_CLOSE;1084 return CloseStatus.PENDING_CLOSE;
1086 1085
1087 bool try_to_save = can_save();
1088
1089 container.present();1086 container.present();
1090 AlertDialog dialog;1087
1091 1088 if (can_save()) {
1092 if (try_to_save) {1089 save_and_exit_async.begin(); // Save
1093 dialog = new TernaryConfirmationDialog(container.top_window,
1094 _("Do you want to discard this message?"), null, Stock._KEEP, Stock._DISCARD,
1095 Gtk.ResponseType.CLOSE);
1096 } else {
1097 dialog = new ConfirmationDialog(container.top_window,
1098 _("Do you want to discard this message?"), null, Stock._DISCARD);
1099 }
1100
1101 Gtk.ResponseType response = dialog.run();
1102 if (response == Gtk.ResponseType.CANCEL || response == Gtk.ResponseType.DELETE_EVENT) {
1103 return CloseStatus.CANCEL_CLOSE; // Cancel
1104 } else if (response == Gtk.ResponseType.OK) {
1105 if (try_to_save) {
1106 save_and_exit_async.begin(); // Save
1107 return CloseStatus.PENDING_CLOSE;
1108 } else {
1109 return CloseStatus.DO_CLOSE;
1110 }
1111 } else {
1112 discard_and_exit_async.begin(); // Discard
1113 return CloseStatus.PENDING_CLOSE;1090 return CloseStatus.PENDING_CLOSE;
1091 } else {
1092 return CloseStatus.DO_CLOSE;
1114 }1093 }
1115 }1094 }
1116 1095

Subscribers

People subscribed via source and target branches