[Xfce4-commits] <postler:master> Ask whether to discard if closing composer after typing
Christian Dywan
noreply at xfce.org
Tue Jul 13 00:54:12 CEST 2010
Updating branch refs/heads/master
to 82e091f7fd5eb826ad90c95412791bf2f564620e (commit)
from 9c76cc4ce9b566d173e59b590de2ef7425c64c41 (commit)
commit 82e091f7fd5eb826ad90c95412791bf2f564620e
Author: Christian Dywan <christian at twotoasts.de>
Date: Tue Jul 6 21:47:11 2010 +0200
Ask whether to discard if closing composer after typing
postler/postler-composer.vala | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index ebbdb9e..3794483 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -129,7 +129,24 @@ public class Postler.Composer : Gtk.Window {
}
void action_close () {
- destroy ();
+ if (!window_not_closed ())
+ destroy ();
+ }
+
+ bool window_not_closed () {
+ if (content.can_undo ()) {
+ var dialog = new Gtk.MessageDialog (this, 0,
+ Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
+ _("Do you want to discard the unsaved message?"));
+ dialog.add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_DISCARD, Gtk.ResponseType.OK);
+ dialog.set_default_response (Gtk.ResponseType.CANCEL);
+ int response = dialog.run ();
+ dialog.destroy ();
+ if (response != Gtk.ResponseType.OK)
+ return true;
+ }
+ return false;
}
void insert_text (string text) {
@@ -292,6 +309,8 @@ public class Postler.Composer : Gtk.Window {
settings.set ("enable-spell-checking", true,
"spell-checking-languages", languages, null);
}
+
+ delete_event.connect (window_not_closed);
}
public bool prepare_reply (string? location=null, bool quote=false) {
More information about the Xfce4-commits
mailing list