Limit the number of characters in the description and source lists on the edit window

Prevent place duplication


svn: r1477
This commit is contained in:
Don Allingham
2003-04-26 23:17:51 +00:00
parent d428ff7e9c
commit 17eced69ef
4 changed files with 23 additions and 13 deletions

View File

@ -1039,10 +1039,10 @@ class EditPerson:
self.event_place_field.set_text(event.getPlaceName()) self.event_place_field.set_text(event.getPlaceName())
self.event_name_field.set_text(const.display_pevent(event.getName())) self.event_name_field.set_text(const.display_pevent(event.getName()))
self.event_cause_field.set_text(event.getCause()) 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: if len(event.getSourceRefList()) > 0:
psrc = 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()]) self.event_conf_field.set_text(const.confidence[psrc.getConfidence()])
else: else:
self.event_src_field.set_text('') self.event_src_field.set_text('')
@ -1073,7 +1073,7 @@ class EditPerson:
if len(addr.getSourceRefList()) > 0: if len(addr.getSourceRefList()) > 0:
psrc = addr.getSourceRefList()[0] psrc = addr.getSourceRefList()[0]
self.addr_conf_field.set_text(const.confidence[psrc.getConfidence()]) 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: else:
self.addr_src_field.set_text('') self.addr_src_field.set_text('')
self.addr_conf_field.set_text('') self.addr_conf_field.set_text('')
@ -1103,7 +1103,7 @@ class EditPerson:
self.name_type_field.set_text(name.getType()) self.name_type_field.set_text(name.getType())
if len(name.getSourceRefList()) > 0: if len(name.getSourceRefList()) > 0:
psrc = 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()]) self.name_conf_field.set_text(const.confidence[psrc.getConfidence()])
else: else:
self.name_src_field.set_text('') self.name_src_field.set_text('')
@ -1145,10 +1145,10 @@ class EditPerson:
if iter: if iter:
attr = self.atree.get_object(iter) attr = self.atree.get_object(iter)
self.attr_type.set_text(const.display_pattr(attr.getType())) 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: if len(attr.getSourceRefList()) > 0:
psrc = 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()]) self.attr_conf_field.set_text(const.confidence[psrc.getConfidence()])
else: else:
self.attr_src_field.set_text('') self.attr_src_field.set_text('')
@ -1390,6 +1390,8 @@ class EditPerson:
def get_place(self,field,makenew=0): def get_place(self,field,makenew=0):
text = string.strip(field.get_text()) text = string.strip(field.get_text())
if type(text) != type(u' '):
text = unicode(text)
if text: if text:
if self.pmap.has_key(text): if self.pmap.has_key(text):
return self.db.getPlaceMap()[self.pmap[text]] return self.db.getPlaceMap()[self.pmap[text]]
@ -1580,3 +1582,9 @@ def reorder_child_list(person, list):
list.insert(target,person) list.insert(target,person)
return list return list
def short(val,size=60):
if len(val) > size:
return "%s..." % val[0:size]
else:
return val

View File

@ -151,7 +151,7 @@ class PlaceView:
return 0 return 0
def new_place_after_edit(self,place): def new_place_after_edit(self,place):
self.db.addPlace(place) #self.db.addPlace(place)
self.update(0) self.update(0)
def update_display(self,place): def update_display(self,place):

View File

@ -2351,6 +2351,9 @@ class GrampsDB(Persistent):
"""adds a Place instance to the database, assigning it a gramps' """adds a Place instance to the database, assigning it a gramps'
ID number""" ID number"""
# import traceback
# traceback.print_stack()
index = self.pprefix % self.lmapIndex index = self.pprefix % self.lmapIndex
while self.placeMap.has_key(index): while self.placeMap.has_key(index):
self.lmapIndex = self.lmapIndex + 1 self.lmapIndex = self.lmapIndex + 1

View File

@ -2,6 +2,7 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface> <glade-interface>
<requires lib="gnome"/>
<requires lib="canvas"/> <requires lib="canvas"/>
<widget class="GtkDialog" id="editPerson"> <widget class="GtkDialog" id="editPerson">
@ -92,9 +93,7 @@
<property name="show_tabs">True</property> <property name="show_tabs">True</property>
<property name="show_border">True</property> <property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property> <property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property> <property name="scrollable">True</property>
<property name="tab_hborder">2</property>
<property name="tab_vborder">2</property>
<property name="enable_popup">False</property> <property name="enable_popup">False</property>
<signal name="switch_page" handler="on_editperson_switch_page" object="editPerson"/> <signal name="switch_page" handler="on_editperson_switch_page" object="editPerson"/>
@ -2110,7 +2109,7 @@
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">True</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
@ -2546,7 +2545,7 @@
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property> <property name="wrap">True</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
@ -3683,7 +3682,7 @@
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property> <property name="wrap">True</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>