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
1=== modified file 'src/client/application/geary-controller.vala'
2--- src/client/application/geary-controller.vala 2016-02-09 18:34:21 +0000
3+++ src/client/application/geary-controller.vala 2016-03-03 23:27:53 +0000
4@@ -2110,24 +2110,22 @@
5
6 private bool close_composition_windows() {
7 Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
8- bool quit_cancelled = false;
9
10 // If there's composer windows open, give the user a chance to save or cancel.
11 foreach(ComposerWidget cw in composer_widgets) {
12 // Check if we should close the window immediately, or if we need to wait.
13- ComposerWidget.CloseStatus status = cw.should_close();
14- if (status == ComposerWidget.CloseStatus.PENDING_CLOSE) {
15- // Window is currently busy saving.
16- waiting_to_close.add(cw);
17- } else if (status == ComposerWidget.CloseStatus.CANCEL_CLOSE) {
18- // User cancelled operation.
19- quit_cancelled = true;
20- break;
21- } else if (status == ComposerWidget.CloseStatus.DO_CLOSE) {
22- // Hide any existing composer windows for the moment; actually deleting the windows
23- // will result in their removal from composer_windows, which could crash this loop.
24- composers_to_destroy.add(cw);
25- ((ComposerContainer) cw.parent).vanish();
26+ switch (cw.should_close()) {
27+ case ComposerWidget.CloseStatus.PENDING_CLOSE:
28+ // Window is currently busy saving.
29+ waiting_to_close.add(cw);
30+ break;
31+
32+ case ComposerWidget.CloseStatus.DO_CLOSE:
33+ // Hide any existing composer windows for the moment; actually deleting the windows
34+ // will result in their removal from composer_windows, which could crash this loop.
35+ composers_to_destroy.add(cw);
36+ ((ComposerContainer) cw.parent).vanish();
37+ break;
38 }
39 }
40
41@@ -2135,13 +2133,6 @@
42 foreach(ComposerWidget cw in composers_to_destroy)
43 ((ComposerContainer) cw.parent).close_container();
44
45- // If we cancelled the quit we can bail here.
46- if (quit_cancelled) {
47- waiting_to_close.clear();
48-
49- return false;
50- }
51-
52 // If there's still windows saving, we can't exit just yet. Hide the main window and wait.
53 if (waiting_to_close.size > 0) {
54 main_window.hide();
55@@ -2267,22 +2258,29 @@
56 }
57 }
58
59+ main_window.present();
60+
61 // Find out what to do with the inline composers.
62- // TODO: Remove this in favor of automatically saving drafts
63- main_window.present();
64- QuestionDialog dialog = new QuestionDialog(main_window, _("Close open draft messages?"), null,
65- Stock._CLOSE, Stock._CANCEL);
66- if (dialog.run() == Gtk.ResponseType.OK) {
67- Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
68- foreach (ComposerWidget cw in composer_widgets) {
69- if (cw.state != ComposerWidget.ComposerState.DETACHED)
70- composers_to_destroy.add(cw);
71+ Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
72+ foreach (ComposerWidget cw in composer_widgets) {
73+ // Skip non-inline composers
74+ if (cw.state != ComposerWidget.ComposerState.DETACHED) {
75+ switch (cw.should_close()) {
76+ case ComposerWidget.CloseStatus.PENDING_CLOSE:
77+ // save_and_exit_async() takes care of killing the
78+ // container when it's done saving the draft
79+ break;
80+
81+ case ComposerWidget.CloseStatus.DO_CLOSE:
82+ composers_to_destroy.add(cw);
83+ break;
84+ }
85 }
86- foreach(ComposerWidget cw in composers_to_destroy)
87- ((ComposerContainer) cw.parent).close_container();
88- return true;
89 }
90- return false;
91+ foreach(ComposerWidget cw in composers_to_destroy)
92+ ((ComposerContainer) cw.parent).close_container();
93+
94+ return true;
95 }
96
97 public bool can_switch_conversation_view() {
98
99=== modified file 'src/client/composer/composer-headerbar.vala'
100--- src/client/composer/composer-headerbar.vala 2016-02-05 20:21:57 +0000
101+++ src/client/composer/composer-headerbar.vala 2016-03-03 23:27:53 +0000
102@@ -31,7 +31,6 @@
103 detach_end.margin_start = 6;
104
105 insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_DISCARD));
106- insert.add(create_toolbar_button(null, ComposerWidget.ACTION_CLOSE_SAVE));
107 Gtk.Box close_buttons = create_pill_buttons(insert, false);
108 insert.clear();
109
110
111=== modified file 'src/client/composer/composer-widget.vala'
112--- src/client/composer/composer-widget.vala 2016-02-08 16:00:57 +0000
113+++ src/client/composer/composer-widget.vala 2016-03-03 23:27:53 +0000
114@@ -16,7 +16,6 @@
115 public enum CloseStatus {
116 DO_CLOSE,
117 PENDING_CLOSE,
118- CANCEL_CLOSE
119 }
120
121 public enum ComposerState {
122@@ -1084,33 +1083,13 @@
123 if (is_closing)
124 return CloseStatus.PENDING_CLOSE;
125
126- bool try_to_save = can_save();
127-
128 container.present();
129- AlertDialog dialog;
130-
131- if (try_to_save) {
132- dialog = new TernaryConfirmationDialog(container.top_window,
133- _("Do you want to discard this message?"), null, Stock._KEEP, Stock._DISCARD,
134- Gtk.ResponseType.CLOSE);
135- } else {
136- dialog = new ConfirmationDialog(container.top_window,
137- _("Do you want to discard this message?"), null, Stock._DISCARD);
138- }
139-
140- Gtk.ResponseType response = dialog.run();
141- if (response == Gtk.ResponseType.CANCEL || response == Gtk.ResponseType.DELETE_EVENT) {
142- return CloseStatus.CANCEL_CLOSE; // Cancel
143- } else if (response == Gtk.ResponseType.OK) {
144- if (try_to_save) {
145- save_and_exit_async.begin(); // Save
146- return CloseStatus.PENDING_CLOSE;
147- } else {
148- return CloseStatus.DO_CLOSE;
149- }
150- } else {
151- discard_and_exit_async.begin(); // Discard
152+
153+ if (can_save()) {
154+ save_and_exit_async.begin(); // Save
155 return CloseStatus.PENDING_CLOSE;
156+ } else {
157+ return CloseStatus.DO_CLOSE;
158 }
159 }
160

Subscribers

People subscribed via source and target branches