2007-04-07 Don Allingham <don@gramps-project.org>

* 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
This commit is contained in:
Don Allingham 2007-04-08 04:24:38 +00:00
parent 00632c6a70
commit a712445a2b
11 changed files with 65 additions and 27 deletions

View File

@ -1,3 +1,14 @@
2007-04-07 Don Allingham <don@gramps-project.org>
* 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 <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: 0000998: Source Ref link refers to nothing in
Narrative web report.

View File

@ -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:

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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):

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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):
"""

View File

@ -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())