[postr] Only show save/quit confirmation if unsaved
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [postr] Only show save/quit confirmation if unsaved
- Date: Sun, 8 Nov 2009 06:02:44 +0000 (UTC)
commit aaad4ecb754be28e85bdb4505724223a805c04c4
Author: David Ignacio <deignacio gmail com>
Date: Sun Nov 8 03:00:05 2009 -0300
Only show save/quit confirmation if unsaved
Only show save/quit confirmation dialog if the model
has unsaved data.
Signed-off-by: Germán Póo-Caamaño <gpoo gnome org>
src/ImageStore.py | 11 +++++++++++
src/postr.py | 4 +++-
2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/ImageStore.py b/src/ImageStore.py
index 563f4df..c74b9fe 100644
--- a/src/ImageStore.py
+++ b/src/ImageStore.py
@@ -48,3 +48,14 @@ class ImageStore (gtk.ListStore):
gtk.TreeIter, # COL_PRIVACY
gtk.TreeIter, # COL_SAFETY
gobject.TYPE_BOOLEAN) # COL_VISIBLE
+ self._dirty = False
+ self.connect("row-changed", self._on_row_changed)
+
+ def dirty(self):
+ return self._dirty
+
+ def markClean(self):
+ self._dirty = False
+
+ def _on_row_changed(self, model, path, iter):
+ self._dirty = self.iter_n_children(None) > 0
diff --git a/src/postr.py b/src/postr.py
index ef59c1d..188b663 100644
--- a/src/postr.py
+++ b/src/postr.py
@@ -408,7 +408,7 @@ class Postr(UniqueApp):
return True
elif response == gtk.RESPONSE_ACCEPT:
self.save_upload_set()
- elif self.is_connected and self.model.iter_n_children(None) > 0:
+ elif self.is_connected and self.model.iter_n_children(None) > 0 and self.model.dirty():
dialog = gtk.MessageDialog(type=gtk.MESSAGE_WARNING, parent=self.window)
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT,
@@ -954,6 +954,8 @@ class Postr(UniqueApp):
iter = self.model.iter_next(iter)
dest.close()
+ self.model.markClean()
+
dialog.destroy()
def _marshal_row(self, path, iter):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]