From a712445a2b5fb8016d27bc82e40f2035453788c2 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 8 Apr 2007 04:24:38 +0000 Subject: [PATCH] 2007-04-07 Don Allingham * src/plugins/Checkpoint.py: update from 2.2 * src/GrampsDb/_GrampsDbWriteXML.py: clean up * src/Editors/_EditPrimary.py: prevent double OK clicks * src/Editors/_EditPlace.py: prevent double OK clicks * src/Editors/_EditSource.py: prevent double OK clicks * src/Editors/_EditPerson.py: prevent double OK clicks * src/Editors/_EditRepository.py: prevent double OK clicks * src/Editors/_EditFamily.py: prevent double OK clicks * src/Editors/_EditEvent.py: prevent double OK clicks svn: r8361 --- ChangeLog | 11 +++++++ src/Editors/_EditEvent.py | 3 ++ src/Editors/_EditFamily.py | 4 +++ src/Editors/_EditPerson.py | 4 ++- src/Editors/_EditPlace.py | 1 + src/Editors/_EditPrimary.py | 6 ++-- src/Editors/_EditRepository.py | 2 ++ src/Editors/_EditSource.py | 2 ++ src/GrampsDb/_GrampsDbWriteXML.py | 5 ++-- src/GrampsDbUtils/_WriteXML.py | 4 +-- src/plugins/Checkpoint.py | 50 ++++++++++++++++++------------- 11 files changed, 65 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 679810e8c..0caeae2b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-04-07 Don Allingham + * src/plugins/Checkpoint.py: update from 2.2 + * src/GrampsDb/_GrampsDbWriteXML.py: clean up + * src/Editors/_EditPrimary.py: prevent double OK clicks + * src/Editors/_EditPlace.py: prevent double OK clicks + * src/Editors/_EditSource.py: prevent double OK clicks + * src/Editors/_EditPerson.py: prevent double OK clicks + * src/Editors/_EditRepository.py: prevent double OK clicks + * src/Editors/_EditFamily.py: prevent double OK clicks + * src/Editors/_EditEvent.py: prevent double OK clicks + 2007-04-05 Brian Matherly * src/plugins/NarrativeWeb.py: 0000998: Source Ref link refers to nothing in Narrative web report. diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index f9f498acd..c16afcb34 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -208,10 +208,12 @@ class EditEvent(EditPrimary): GrampsDisplay.help('adv-ev') def save(self,*obj): + self.ok_button.set_sensitive(False) if self.object_is_empty(): ErrorDialog(_("Cannot save event"), _("No data exists for this event. Please " "enter data or cancel the edit.")) + self.ok_button.set_sensitive(True) return t = self.obj.get_type() @@ -219,6 +221,7 @@ class EditEvent(EditPrimary): ErrorDialog( _("Cannot save event"), _("The event type cannot be empty")) + self.ok_button.set_sensitive(True) return if self.obj.handle == None: diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index 238f7094d..baaa2b153 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -773,6 +773,7 @@ class EditFamily(EditPrimary): def save(self,*obj): + self.ok_button.set_sensitive(False) self.in_save = True if not self.added: @@ -792,6 +793,7 @@ class EditFamily(EditPrimary): QuestionDialog.ErrorDialog(_("A father cannot be his own child"), _("%s is listed as both the father and child " "of the family.") % name) + self.ok_button.set_sensitive(True) return elif self.obj.get_mother_handle() in child_list: @@ -801,6 +803,7 @@ class EditFamily(EditPrimary): QuestionDialog.ErrorDialog(_("A mother cannot be her own child"), _("%s is listed as both the mother and child " "of the family.") % name) + self.ok_button.set_sensitive(True) return @@ -834,6 +837,7 @@ class EditFamily(EditPrimary): QuestionDialog.ErrorDialog(_("Cannot save family"), _("No data exists for this family. Please " "enter data or cancel the edit.")) + self.ok_button.set_sensitive(True) return elif original and self.object_is_empty(): trans = self.db.transaction_begin() diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index c7234abf7..2d9ef98ae 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -577,15 +577,17 @@ class EditPerson(EditPrimary): "the person's marriages.") ErrorDialog(msg2, msg) - def save(self, *obj): + def save(self, obj): """ Save the data. """ + self.ok_button.set_sensitive(False) if self.object_is_empty(): ErrorDialog(_("Cannot save person"), _("No data exists for this person. Please " "enter data or cancel the edit.")) + self.ok_button.set_sensitive(True) return self._check_for_unknown_gender() diff --git a/src/Editors/_EditPlace.py b/src/Editors/_EditPlace.py index 7f8b056c4..cfb0443a5 100644 --- a/src/Editors/_EditPlace.py +++ b/src/Editors/_EditPlace.py @@ -206,6 +206,7 @@ class EditPlace(EditPrimary): Config.sync() def save(self,*obj): + self.ok_button.set_sensitive(False) title = self.obj.get_title() trans = self.db.transaction_begin() diff --git a/src/Editors/_EditPrimary.py b/src/Editors/_EditPrimary.py index 218d330fb..3a6562819 100644 --- a/src/Editors/_EditPrimary.py +++ b/src/Editors/_EditPrimary.py @@ -43,6 +43,7 @@ class EditPrimary(ManagedWindow.ManagedWindow): self.db = state.db self.callback = callback self.signal_keys = [] + self.ok_button = None self.get_from_handle = get_from_handle ManagedWindow.ManagedWindow.__init__(self, uistate, track, obj) @@ -110,8 +111,9 @@ class EditPrimary(ManagedWindow.ManagedWindow): return cmp(self.obj.serialize()[1:], self.empty_object().serialize()[1:]) == 0 - def define_ok_button(self,button,function): - button.connect('clicked',function) + def define_ok_button(self, button, function): + self.ok_button = button + button.connect('clicked', function) button.set_sensitive(not self.db.readonly) def define_cancel_button(self,button): diff --git a/src/Editors/_EditRepository.py b/src/Editors/_EditRepository.py index 09876c33a..28fa04276 100644 --- a/src/Editors/_EditRepository.py +++ b/src/Editors/_EditRepository.py @@ -141,11 +141,13 @@ class EditRepository(EditPrimary): self.define_ok_button(self.glade.get_widget('ok'), self.save) def save(self,*obj): + self.ok_button.set_sensitive(False) if self.object_is_empty(): from QuestionDialog import ErrorDialog ErrorDialog(_("Cannot save repository"), _("No data exists for this repository. Please " "enter data or cancel the edit.")) + self.ok_button.set_sensitive(True) return trans = self.db.transaction_begin() diff --git a/src/Editors/_EditSource.py b/src/Editors/_EditSource.py index 777624511..66a9df777 100644 --- a/src/Editors/_EditSource.py +++ b/src/Editors/_EditSource.py @@ -160,12 +160,14 @@ class EditSource(EditPrimary): return (_('Edit Source'), self.get_menu_title()) def save(self,*obj): + self.ok_button.set_sensitive(False) if self.object_is_empty(): from QuestionDialog import ErrorDialog ErrorDialog(_("Cannot save source"), _("No data exists for this source. Please " "enter data or cancel the edit.")) + self.ok_button.set_sensitive(True) return trans = self.db.transaction_begin() diff --git a/src/GrampsDb/_GrampsDbWriteXML.py b/src/GrampsDb/_GrampsDbWriteXML.py index caab3acbe..3921126a0 100644 --- a/src/GrampsDb/_GrampsDbWriteXML.py +++ b/src/GrampsDb/_GrampsDbWriteXML.py @@ -120,7 +120,7 @@ class GrampsDbXmlWriter(object): Writes a database to the XML file. """ - def __init__(self,db,strip_photos,compress=1,version="unknown"): + def __init__(self, db, strip_photos=0, compress=1, version="unknown"): """ Initializes, but does not write, an XML file. @@ -173,7 +173,8 @@ class GrampsDbXmlWriter(object): else: g = open(filename,"w") except IOError,msg: - raise GrampsDbWriteFailure((_('Failure writing %s') % filename,msg)) + print str(msg) + raise GrampsDbWriteFailure((_('Failure writing %s') % filename,str(msg))) return 0 self.g = codecs.getwriter("utf8")(g) diff --git a/src/GrampsDbUtils/_WriteXML.py b/src/GrampsDbUtils/_WriteXML.py index 084edbdc1..9e4039da4 100644 --- a/src/GrampsDbUtils/_WriteXML.py +++ b/src/GrampsDbUtils/_WriteXML.py @@ -78,10 +78,10 @@ class XmlWriter(GrampsDbXmlWriter): Writes a database to the XML file. """ - def __init__(self,db,callback,strip_photos,compress=1): + def __init__(self, db, callback, strip_photos, compress=1): """ """ - GrampsDbXmlWriter.__init__(self,version=const.version) + GrampsDbXmlWriter.__init__(self, db, version=const.version) def write(self,filename): """ diff --git a/src/plugins/Checkpoint.py b/src/plugins/Checkpoint.py index dc64b373d..dc3b645cb 100644 --- a/src/plugins/Checkpoint.py +++ b/src/plugins/Checkpoint.py @@ -46,6 +46,7 @@ import gtk.glade # gramps modules # #------------------------------------------------------------------------- +import GrampsDb import GrampsDbUtils import Utils import GrampsDisplay @@ -145,9 +146,10 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): # Display controls according to the state if self.options.handler.options_dict['rcs']: - self.rcs_rb.set_active(1) + self.rcs_rb.set_active(_rcs_found) + self.cust_rb.set_active(not _rcs_found) else: - self.cust_rb.set_active(1) + self.cust_rb.set_active(True) self.cust_arch_cb.set_sensitive(self.cust_rb.get_active()) self.cust_ret_cb.set_sensitive(self.cust_rb.get_active()) @@ -155,9 +157,7 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): # Disable RCS if the rcs binary is not available # and show the normally hidden warning - if not _rcs_found: - self.rcs_rb.set_sensitive(False) - self.glade.get_widget('warning_label').show() + warning_label = self.glade.get_widget('warning_label') self.title = _("Checkpoint Data") window = self.glade.get_widget('top') @@ -172,6 +172,13 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): self.show() + if not _rcs_found: + self.rcs_rb.set_sensitive(False) + self.cust_rb.set_sensitive(True) + warning_label.show() + else: + warning_label.hide() + def build_menu_names(self,obj): return (_("Checkpoint tool"),None) @@ -217,11 +224,11 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) if self.options.handler.options_dict['rcs']: - self.rcs(archive,cli) + self.rcs(archive, cli) elif archive: - self.custom(self.options.handler.options_dict['cacmd'],True,cli) + self.custom(self.options.handler.options_dict['cacmd'], True, cli) else: - self.custom(self.options.handler.options_dict['crcmd'],False,cli) + self.custom(self.options.handler.options_dict['crcmd'], False, cli) if not cli: self.uistate.window.window.set_cursor(None) @@ -241,7 +248,8 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): stderr = subprocess.PIPE, stdin = subprocess.PIPE ) if checkin: - xmlwrite = GrampsDbUtils.XmlWriter(self.db,self.callback,False,False) + xmlwrite = GrampsDbUtils.XmlWriter(self.db, self.callback, + False, False) xmlwrite.write_handle(proc.stdin) else: pass @@ -276,13 +284,14 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): else: dialog(msg1,msg2) - def rcs(self,checkin,cli): + def rcs(self, checkin, cli): """ Check the generated XML file into RCS. Initialize the RCS file if it does not already exist. """ (archive_base,ext) = os.path.splitext(self.db.get_save_path()) + archive_base = os.path.join(archive_base, "archive") comment = self.timestamp() archive = archive_base + ",v" @@ -290,9 +299,8 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): # If the archive file does not exist, we either set it up # or die trying if not os.path.exists(archive): - proc = subprocess.Popen( - 'rcs -i -U -q -t-"GRAMPS database" %s' % archive, - stderr = subprocess.PIPE ) + cmd = [ 'rcs', '-i', '-U', '-q', '-t-"GRAMPS database"', archive ] + proc = subprocess.Popen(cmd, stderr = subprocess.PIPE ) status = proc.wait() message = "\n".join(proc.stderr.readlines()) proc.stderr.close() @@ -318,18 +326,21 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): if checkin: # At this point, we have an existing archive file - xmlwrite = GrampsDbUtils.XmlWriter(self.db,self.callback,False,False) + xmlwrite = GrampsDbUtils.XmlWriter(self.db, self.callback, + False, False) xmlwrite.write(archive_base) + + cmd = ["ci", archive_base] proc = subprocess.Popen( - "ci %s" % archive_base, - stdin = subprocess.PIPE, - stderr = subprocess.PIPE ) + cmd, + stdin = subprocess.PIPE, + stderr = subprocess.PIPE ) proc.stdin.write(comment) proc.stdin.close() - status = proc.wait() message = "\n".join(proc.stderr.readlines()) proc.stderr.close() + status = proc.wait() del proc if status: @@ -347,9 +358,8 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow): else: dialog(msg1,msg2) else: - proc = subprocess.Popen( - "co -p %s > %s.gramps" % (archive_base,archive_base), + ("co", "-p", archive_base), stdout=subprocess.PIPE, stderr = subprocess.PIPE ) status = proc.wait() message = "\n".join(proc.stderr.readlines())