From 17eced69ef9318803d64baea4aa1e522959b772d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 26 Apr 2003 23:17:51 +0000 Subject: [PATCH] Limit the number of characters in the description and source lists on the edit window Prevent place duplication svn: r1477 --- src/EditPerson.py | 20 ++++++++++++++------ src/PlaceView.py | 2 +- src/RelLib.py | 3 +++ src/edit_person.glade | 11 +++++------ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/EditPerson.py b/src/EditPerson.py index 73c728b85..c1dccff43 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -1039,10 +1039,10 @@ class EditPerson: self.event_place_field.set_text(event.getPlaceName()) self.event_name_field.set_text(const.display_pevent(event.getName())) self.event_cause_field.set_text(event.getCause()) - self.event_descr_field.set_text(event.getDescription()) + self.event_descr_field.set_text(short(event.getDescription())) if len(event.getSourceRefList()) > 0: psrc = event.getSourceRefList()[0] - self.event_src_field.set_text(psrc.getBase().getTitle()) + self.event_src_field.set_text(short(psrc.getBase().getTitle())) self.event_conf_field.set_text(const.confidence[psrc.getConfidence()]) else: self.event_src_field.set_text('') @@ -1073,7 +1073,7 @@ class EditPerson: if len(addr.getSourceRefList()) > 0: psrc = addr.getSourceRefList()[0] self.addr_conf_field.set_text(const.confidence[psrc.getConfidence()]) - self.addr_src_field.set_text(psrc.getBase().getTitle()) + self.addr_src_field.set_text(short(psrc.getBase().getTitle())) else: self.addr_src_field.set_text('') self.addr_conf_field.set_text('') @@ -1103,7 +1103,7 @@ class EditPerson: self.name_type_field.set_text(name.getType()) if len(name.getSourceRefList()) > 0: psrc = name.getSourceRefList()[0] - self.name_src_field.set_text(psrc.getBase().getTitle()) + self.name_src_field.set_text(short(psrc.getBase().getTitle())) self.name_conf_field.set_text(const.confidence[psrc.getConfidence()]) else: self.name_src_field.set_text('') @@ -1145,10 +1145,10 @@ class EditPerson: if iter: attr = self.atree.get_object(iter) self.attr_type.set_text(const.display_pattr(attr.getType())) - self.attr_value.set_text(attr.getValue()) + self.attr_value.set_text(short(attr.getValue())) if len(attr.getSourceRefList()) > 0: psrc = attr.getSourceRefList()[0] - self.attr_src_field.set_text(psrc.getBase().getTitle()) + self.attr_src_field.set_text(short(psrc.getBase().getTitle())) self.attr_conf_field.set_text(const.confidence[psrc.getConfidence()]) else: self.attr_src_field.set_text('') @@ -1390,6 +1390,8 @@ class EditPerson: def get_place(self,field,makenew=0): text = string.strip(field.get_text()) + if type(text) != type(u' '): + text = unicode(text) if text: if self.pmap.has_key(text): return self.db.getPlaceMap()[self.pmap[text]] @@ -1580,3 +1582,9 @@ def reorder_child_list(person, list): list.insert(target,person) return list + +def short(val,size=60): + if len(val) > size: + return "%s..." % val[0:size] + else: + return val diff --git a/src/PlaceView.py b/src/PlaceView.py index 37553b6d7..8482b783b 100644 --- a/src/PlaceView.py +++ b/src/PlaceView.py @@ -151,7 +151,7 @@ class PlaceView: return 0 def new_place_after_edit(self,place): - self.db.addPlace(place) + #self.db.addPlace(place) self.update(0) def update_display(self,place): diff --git a/src/RelLib.py b/src/RelLib.py index bb5837c14..1fdc19652 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -2351,6 +2351,9 @@ class GrampsDB(Persistent): """adds a Place instance to the database, assigning it a gramps' ID number""" +# import traceback +# traceback.print_stack() + index = self.pprefix % self.lmapIndex while self.placeMap.has_key(index): self.lmapIndex = self.lmapIndex + 1 diff --git a/src/edit_person.glade b/src/edit_person.glade index d3831d9e2..de102d403 100644 --- a/src/edit_person.glade +++ b/src/edit_person.glade @@ -2,6 +2,7 @@ + @@ -92,9 +93,7 @@ True True GTK_POS_TOP - False - 2 - 2 + True False @@ -2110,7 +2109,7 @@ False False GTK_JUSTIFY_CENTER - False + True False 0 0.5 @@ -2546,7 +2545,7 @@ False False GTK_JUSTIFY_CENTER - False + True False 0 0.5 @@ -3683,7 +3682,7 @@ False False GTK_JUSTIFY_LEFT - False + True False 0 0.5