* src/Marriage.py: proper window management on delete event.

* src/RelLib.py (Event.are_equal): Correction.
* src/Date.py (is_empty): Require empty text for a date to be empty.
* src/WriteXML (write_object): Remove places from Media.
* src/GrampsDbBase.py (undo): Typos.
* src/GrampsDBCallback: Pretty printing for warnings.


svn: r4297
This commit is contained in:
Alex Roitman 2005-04-05 04:33:11 +00:00
parent e5cd5c0e3d
commit 4dc68a517c
7 changed files with 60 additions and 44 deletions

View File

@ -1,3 +1,11 @@
2005-04-04 Alex Roitman <shura@gramps-project.org>
* src/Marriage.py: proper window management on delete event.
* src/RelLib.py (Event.are_equal): Correction.
* src/Date.py (is_empty): Require empty text for a date to be empty.
* src/WriteXML (write_object): Remove places from Media.
* src/GrampsDbBase.py (undo): Typos.
* src/GrampsDBCallback: Pretty printing for warnings.
2005-04-04 Don Allingham <don@gramps-project.org>
* src/ChooseParents.py: fix father/mother relationship
* src/FamilyView.py: fix update of child pointers after add

View File

@ -464,9 +464,9 @@ class Date:
def is_empty(self):
"""
Returns True if the date is a date range or a date span.
Returns True if the date contains no information (empty text).
"""
return self.modifier == MOD_TEXTONLY
return self.modifier == MOD_TEXTONLY and not self.text
def is_compound(self):
"""

View File

@ -120,7 +120,7 @@ class GrampsDBCallback(object):
for (k,v) in s.items():
if self.__signal_map.has_key(k):
# signal name clash
sys.err.write("Warning: signal name clash: ", str(k))
sys.err.write("Warning: signal name clash: %s\n" % str(k))
self.__signal_map[k] = v
# self.__signal_map now contains the connonical list
@ -130,7 +130,7 @@ class GrampsDBCallback(object):
def connect(self, signal_name, callback):
# Check that signal exists.
if signal_name not in self.__signal_map.keys():
sys.stderr.write("Warning: attempt to connect to unknown signal: ", str(signal_name))
sys.stderr.write("Warning: attempt to connect to unknown signal: %s\n" % str(signal_name))
return
# Add callable to callback_map
@ -146,28 +146,29 @@ class GrampsDBCallback(object):
# Check signal exists
if signal_name not in self.__signal_map.keys():
sys.stderr.write("Warning: attempt to emit to unknown signal: ", str(signal_name))
sys.stderr.write("Warning: attempt to emit to unknown signal: %s\n"
% str(signal_name))
return
# type check arguments
arg_types = self.__signal_map[signal_name]
if arg_types == None and len(args) > 0:
sys.stderr.write("Warning: signal emitted with "\
"wrong number of args: ", str(signal_name))
"wrong number of args: %s\n" % str(signal_name))
return
if len(args) > 0:
if len(args) != len(arg_types):
sys.stderr.write("Warning: signal emitted with "\
"wrong number of args: ", str(signal_name))
"wrong number of args: %s\n" % str(signal_name))
return
if arg_types != None:
for i in range(0,len(arg_types)):
if not isinstance(args[i],arg_types[i]):
sys.stderr.write("Warning: signal emitted with "\
"wrong arg types: %s" % (str(signal_name),))
sys.stderr.write("arg passed was: %s type should be: %s"
"wrong arg types: %s\n" % (str(signal_name),))
sys.stderr.write(" arg passed was: %s, type should be: %s\n"
% (args[i],repr(arg_types[i])))
return
@ -181,9 +182,9 @@ class GrampsDBCallback(object):
type(cb) == types.MethodType: # call func
cb(*args)
else:
sys.stderr.write("Warning: badly formed entry in callback map")
sys.stderr.write("Warning: badly formed entry in callback map.\n")
except:
sys.stderr.write("Warning: exception occured in callback function.")
sys.stderr.write("Warning: exception occured in callback function.\n")
#
# instance signals control methods

View File

@ -977,25 +977,25 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
(key, handle, data) = transaction.get_record(record_id)
if key == PERSON_KEY:
if data == None:
self.emit('person-delete',([str(handle),]))
self.emit('person-delete',([str(handle)],))
del self.person_map[str(handle)]
else:
self.person_map[str(handle)] = data
self.emit('person-update',([str(handle),]))
self.emit('person-update',([str(handle)],))
elif key == FAMILY_KEY:
if data == None:
self.emit('family-delete',([str(handle),]))
self.emit('family-delete',([str(handle)],))
del self.family_map[str(handle)]
else:
self.family_map[str(handle)] = data
self.emit('family-update',([str(handle),]))
self.emit('family-update',([str(handle)],))
elif key == SOURCE_KEY:
if data == None:
self.emit('source-delete',([str(handle),]))
self.emit('source-delete',([str(handle)],))
del self.source_map[str(handle)]
else:
self.source_map[str(handle)] = data
self.emit('source-update',([str(handle),]))
self.emit('source-update',([str(handle)],))
elif key == EVENT_KEY:
if data == None:
del self.event_map[str(handle)]
@ -1003,17 +1003,17 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
self.event_map[str(handle)] = data
elif key == PLACE_KEY:
if data == None:
self.emit('place-delete',([str(handle),]))
self.emit('place-delete',([str(handle)],))
del self.place_map[str(handle)]
else:
self.place_map[str(handle)] = data
self.emit('place-update',([str(handle),]))
self.emit('place-update',([str(handle)],))
elif key == MEDIA_KEY:
if data == None:
self.emit('media-delete',([str(handle),]))
self.emit('media-delete',([str(handle)],))
del self.media_map[str(handle)]
else:
self.emit('media-update',([str(handle),]))
self.emit('media-update',([str(handle)],))
self.media_map[str(handle)] = data
if self.undo_callback:

View File

@ -338,7 +338,7 @@ class Marriage:
child_window.close(None)
self.child_windows = {}
def close(self,ok=0):
def close(self):
self.gallery.close()
self.close_child_windows()
self.remove_itself_from_winsmenu()
@ -611,25 +611,32 @@ class Marriage:
return changed
def cancel_callback(self):
self.close(0)
self.close()
def on_cancel_edit(self,obj):
if self.did_data_change() and not GrampsKeys.get_dont_ask():
global quit
self.quit = obj
SaveDialog(_('Save Changes?'),
_('If you close without saving, the changes you '
'have made will be lost'),
self.cancel_callback,
self.save)
else:
self.close(0)
self.close()
def save(self):
self.on_close_marriage_editor(None)
def on_delete_event(self,obj,b):
self.on_cancel_edit(obj)
if self.did_data_change() and not GrampsKeys.get_dont_ask():
SaveDialog(_('Save Changes?'),
_('If you close without saving, the changes you '
'have made will be lost'),
self.cancel_callback,
self.save)
return True
else:
self.close()
return False
def on_close_marriage_editor(self,*obj):
@ -700,7 +707,7 @@ class Marriage:
self.db.commit_family(self.family,trans)
self.db.transaction_commit(trans,_("Edit Marriage"))
self.close(1)
self.close()
def event_edit_callback(self,event):
"""Birth and death events may not be in the map"""

View File

@ -2126,17 +2126,18 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase):
witness_list = self.get_witness_list()
other_list = other.get_witness_list()
if (not witness_list) and (not other_list):
return True
elif not (witness_list and other_list):
if (witness_list and not other_list) or \
(other_list and not witness_list):
return False
for a in witness_list:
if a in other_list:
other_list.remove(a)
else:
if witness_list and other_list:
another_list = other_list[:]
for a in witness_list:
if a in another_list:
another_list.remove(a)
else:
return False
if another_list:
return False
if other_list:
return False
return True
def set_name(self,name):
@ -3735,8 +3736,10 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase):
return False
if (self.date and other.date and \
not self.date.is_equal(other.date)) \
or (self.date and not other.date) \
or (not self.date and other.date):
or ((not self.date) and other.date and \
not other.date.is_empty()) \
or ((not other.date) and self.date and \
not self.date.is_empty()):
return False
if self.get_text() != other.get_text():
return False

View File

@ -844,19 +844,16 @@ class XmlWriter:
self.g.write(' description="%s"' % self.fix(obj.get_description()))
alist = obj.get_attribute_list()
note = obj.get_note()
phandle = obj.get_place_handle()
dval = obj.get_date_object()
slist = obj.get_source_references()
if len(alist) == 0 and len(slist) == 0 and note == "" and \
phandle == "" and not dval.is_empty():
if len(alist) == 0 and len(slist) == 0 and note == "" \
and not dval.is_empty():
self.g.write('/>\n')
else:
self.g.write('>\n')
self.write_attribute_list(alist)
if note != "":
self.write_note("note",obj.get_note_object(),3)
if phandle:
self.g.write(' <place ref="%s"/>\n' % phandle)
if not dval.is_empty():
self.write_date(dval,3)
for s in slist: