[geary/wip/728002-webkit2: 90/96] Only prompt to when closing composer if message is not blank or saved.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2: 90/96] Only prompt to when closing composer if message is not blank or saved.
- Date: Sat, 14 Jan 2017 12:19:23 +0000 (UTC)
commit a8bcba6341a78bb184c60637e950d9c67a0fe2f4
Author: Michael James Gratton <mike vee net>
Date: Fri Jan 6 10:51:58 2017 +1100
Only prompt to when closing composer if message is not blank or saved.
* src/client/composer/composer-widget.vala (ComposerWidget): Add
::is_draft_saved field, update it as the draft manager's state changes,
or if the message has been changed.
(ComposerWidget::should_close): If the message is currently empty or
has been saved, we can simply close straight away.
src/client/composer/composer-widget.vala | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 078c507..1da5624 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -221,6 +221,7 @@ public class ComposerWidget : Gtk.EventBox {
return this.draft_manager != null
&& this.draft_manager.is_open
&& this.account.information.save_drafts
+ && !this.is_draft_saved
&& !this.is_blank;
}
}
@@ -346,6 +347,7 @@ public class ComposerWidget : Gtk.EventBox {
private Geary.App.DraftManager? draft_manager = null;
private Geary.EmailFlags draft_flags = new Geary.EmailFlags.with(Geary.EmailFlags.DRAFT);
private Geary.TimeoutManager draft_timer;
+ private bool is_draft_saved = false;
// Is the composer closing (e.g. saving a draft or sending)?
private bool is_closing = false;
@@ -1057,6 +1059,8 @@ public class ComposerWidget : Gtk.EventBox {
public CloseStatus should_close() {
if (this.is_closing)
return CloseStatus.PENDING_CLOSE;
+ if (this.is_blank || this.is_draft_saved)
+ return CloseStatus.DO_CLOSE;
bool try_to_save = this.can_save;
@@ -1304,18 +1308,22 @@ public class ComposerWidget : Gtk.EventBox {
switch (this.draft_manager.draft_state) {
case Geary.App.DraftManager.DraftState.STORED:
this.draft_save_text = DRAFT_SAVED_TEXT;
+ this.is_draft_saved = true;
break;
case Geary.App.DraftManager.DraftState.STORING:
this.draft_save_text = DRAFT_SAVING_TEXT;
+ this.is_draft_saved = true;
break;
case Geary.App.DraftManager.DraftState.NOT_STORED:
this.draft_save_text = "";
+ this.is_draft_saved = false;
break;
case Geary.App.DraftManager.DraftState.ERROR:
this.draft_save_text = DRAFT_ERROR_TEXT;
+ this.is_draft_saved = false;
break;
default:
@@ -1348,6 +1356,7 @@ public class ComposerWidget : Gtk.EventBox {
}
private inline void draft_changed() {
+ this.is_draft_saved = false;
if (this.can_save) {
this.draft_timer.start();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]