Merge lp:~spud/spud/save-fix into lp:spud

Proposed by Fraser Waters
Status: Merged
Merged at revision: 418
Proposed branch: lp:~spud/spud/save-fix
Merge into: lp:spud
Diff against target: 97 lines (+27/-28)
1 file modified
diamond/diamond/interface.py (+27/-28)
To merge this branch: bzr merge lp:~spud/spud/save-fix
Reviewer Review Type Date Requested Status
Jon Hill Approve
Review via email: mp+67814@code.launchpad.net

Description of the change

Fixes bug #809810 and a small bug with close_file().

To post a comment you must log in.
Revision history for this message
Jon Hill (jon-hill) wrote :

Grand. Looks fine to me (untested though ;-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'diamond/diamond/interface.py'
2--- diamond/diamond/interface.py 2011-07-11 11:11:00 +0000
3+++ diamond/diamond/interface.py 2011-07-13 15:53:21 +0000
4@@ -258,9 +258,6 @@
5 return
6
7 def close_file(self):
8- if self.filename is None:
9- return
10-
11 self.remove_children(None)
12 self.init_datatree()
13
14@@ -356,15 +353,30 @@
15
16 return
17
18+ def save_continue(self):
19+
20+ if not self.saved:
21+ prompt_response = dialogs.prompt(self.main_window,
22+ "Unsaved data. Do you want to save the current document before continuing?", gtk.MESSAGE_WARNING, True)
23+
24+ if prompt_response == gtk.RESPONSE_YES:
25+ if self.filename is None:
26+ return self.on_save_as()
27+ else:
28+ return self.on_save()
29+ elif prompt_response == gtk.RESPONSE_CANCEL:
30+ return False
31+
32+ return True
33+
34 def on_new(self, widget=None):
35 """
36 Called when new is clicked. Clear the treestore and reset the datatree.
37 """
38
39- if not self.saved:
40- prompt_response = dialogs.prompt(self.main_window, "Unsaved data. Do you wish to continue?", gtk.MESSAGE_WARNING)
41- if not prompt_response == gtk.RESPONSE_YES:
42- return
43+ if not self.save_continue():
44+ return
45+
46 self.open_file(filename = None)
47 self.filename = None
48
49@@ -375,10 +387,8 @@
50 Called when open is clicked. Open a user supplied file.
51 """
52
53- if not self.saved:
54- prompt_response = dialogs.prompt(self.main_window, "Unsaved data. Do you want to save the current document before continuing?", gtk.MESSAGE_WARNING)
55- if not prompt_response == gtk.RESPONSE_YES:
56- return
57+ if not self.save_continue():
58+ return
59
60 filter_names_and_patterns = {}
61 if self.suffix is None:
62@@ -401,10 +411,8 @@
63 Called when open schema is clicked. Clear the treestore and reset the schema.
64 """
65
66- if not self.saved:
67- prompt_response = dialogs.prompt(self.main_window, "Unsaved data. Do you wish to continue?", gtk.MESSAGE_WARNING)
68- if not prompt_response == gtk.RESPONSE_YES:
69- return
70+ if not self.save_continue():
71+ return
72
73 filename = dialogs.get_filename(title = "Open RELAX NG schema", action = gtk.FILE_CHOOSER_ACTION_OPEN, filter_names_and_patterns = {"RNG files":"*.rng"}, folder_uri = self.schemafile_path)
74 if not filename is None:
75@@ -493,19 +501,10 @@
76 changed.
77 """
78
79- if self.saved:
80- self.destroy()
81- else:
82- prompt_response = dialogs.prompt(self.main_window, "Unsaved data. Do you wish to save?", gtk.MESSAGE_WARNING, True)
83- if prompt_response == gtk.RESPONSE_YES:
84- if self.filename is None:
85- retval = self.on_save_as()
86- else:
87- retval = self.on_save()
88- if retval is True:
89- self.destroy()
90- elif prompt_response == gtk.RESPONSE_NO:
91- self.destroy()
92+ if not self.save_continue():
93+ return
94+
95+ self.destroy()
96
97 return
98

Subscribers

People subscribed via source and target branches