Faster loading of EditPerson window

svn: r750
This commit is contained in:
Don Allingham 2002-02-05 05:24:09 +00:00
parent 82f8301454
commit 6e4ad1bb4c
5 changed files with 235 additions and 248 deletions

View File

@ -26,18 +26,20 @@ strings as the possible completions.
import string
import gtk
cnv = string.lower
class AutoComp:
"""
Allows allow completion of the GtkEntry widget with the entries
in the passed string list.
"""
def __init__(self,widget,plist):
def __init__(self,widget,plist,source=None):
self.entry = widget
self.nlist = [("","")]
for n in plist:
n2 = string.lower(n)
self.nlist.append((n2,n))
self.nlist.sort()
if source:
self.nlist = source.nlist
else:
self.nlist = map((lambda n: (cnv(n),n)),plist)
self.nlist.sort()
self.entry.connect("insert-text",self.insert_text)
def insert_text(self,entry,new_text,new_text_len,i_dont_care):

View File

@ -286,48 +286,6 @@
</child>
</widget>
<widget>
<class>GtkCombo</class>
<name>bpcombo</name>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>3</xpad>
<ypad>3</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>birthPlace</name>
<can_focus>True</can_focus>
<signal>
<name>insert_text</name>
<handler>on_combo_insert_text</handler>
<object>bpcombo</object>
<last_modification_time>Thu, 18 Oct 2001 01:13:13 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
<widget>
<class>GtkEntry</class>
<name>birthDate</name>
@ -382,6 +340,30 @@
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>birthPlace</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>3</xpad>
<ypad>3</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
@ -544,48 +526,6 @@
</child>
</widget>
<widget>
<class>GtkCombo</class>
<name>dpcombo</name>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>3</xpad>
<ypad>3</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>deathPlace</name>
<can_focus>True</can_focus>
<signal>
<name>insert_text</name>
<handler>on_combo_insert_text</handler>
<object>dpcombo</object>
<last_modification_time>Thu, 18 Oct 2001 01:14:20 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
<widget>
<class>GtkButton</class>
<name>button126</name>
@ -615,6 +555,30 @@
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>deathPlace</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>3</xpad>
<ypad>3</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>

View File

@ -81,6 +81,9 @@ class EditPerson:
self.lists_changed = 0
self.update_birth = 0
self.update_death = 0
self.pmap = {}
for p in db.getPlaces():
self.pmap[p.get_title()] = p
self.load_obj = None
self.top = libglade.GladeXML(const.editPersonFile, "editPerson")
@ -177,10 +180,8 @@ class EditPerson:
self.title = self.get_widget("title")
self.bdate = self.get_widget("birthDate")
self.bplace = self.get_widget("birthPlace")
self.bpcombo = self.get_widget("bpcombo")
self.ddate = self.get_widget("deathDate")
self.dplace = self.get_widget("deathPlace")
self.dpcombo = self.get_widget("dpcombo")
self.is_male = self.get_widget("genderMale")
self.is_female = self.get_widget("genderFemale")
self.is_unknown = self.get_widget("genderUnknown")
@ -191,19 +192,6 @@ class EditPerson:
self.name_note = self.get_widget("name_note")
self.name_source = self.get_widget("name_source")
self.gid = self.get_widget("gid")
self.ldsbap_date = self.get_widget("ldsbapdate")
self.ldsbap_temple = self.get_widget("ldsbaptemple")
self.ldsend_date = self.get_widget("endowdate")
self.ldsend_temple = self.get_widget("endowtemple")
self.ldsseal_date = self.get_widget("sealdate")
self.ldsseal_temple = self.get_widget("sealtemple")
self.ldsseal_fam = self.get_widget("sealparents")
self.ldsbapstat = self.get_widget("ldsbapstat")
self.ldssealstat = self.get_widget("sealstat")
self.ldsendowstat = self.get_widget("endowstat")
self.ldsbapplace = self.get_widget("ldsbapplace")
self.ldssealplace = self.get_widget("sealplace")
self.ldsendowplace = self.get_widget("endowplace")
self.elist = person.getEventList()[:]
self.nlist = person.getAlternateNames()[:]
@ -227,9 +215,11 @@ class EditPerson:
self.window.editable_enters(self.ddate);
self.window.editable_enters(self.dplace);
a = AutoComp.AutoComp(self.bplace,self.pmap.keys())
AutoComp.AutoComp(self.dplace,self.pmap.keys(),a)
if Config.autocomp:
self.comp = AutoComp.AutoComp(self.surname_field,const.surnames)
self.gid.set_text(person.getId())
self.gid.set_editable(Config.id_edit)
self.event_list.set_column_visibility(3,Config.show_detail)
@ -282,7 +272,51 @@ class EditPerson:
self.notes_field.insert_defaults(person.getNote())
self.notes_field.set_word_wrap(1)
# lds stuff
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.event_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.event_list.connect('drag_data_get', self.ev_drag_data_get)
self.event_list.connect('drag_data_received', self.ev_drag_data_received)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.web_list.connect('drag_data_get', self.url_drag_data_get)
self.web_list.connect('drag_data_received', self.url_drag_data_received)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.attr_list.connect('drag_data_get', self.at_drag_data_get)
self.attr_list.connect('drag_data_received', self.at_drag_data_received)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.addr_list.connect('drag_data_get', self.ad_drag_data_get)
self.addr_list.connect('drag_data_received', self.ad_drag_data_received)
self.redraw_event_list()
self.redraw_attr_list()
self.redraw_addr_list()
self.redraw_name_list()
self.redraw_url_list()
def draw_lds(self):
self.ldsbap_date = self.get_widget("ldsbapdate")
self.ldsbap_temple = self.get_widget("ldsbaptemple")
self.ldsend_date = self.get_widget("endowdate")
self.ldsend_temple = self.get_widget("endowtemple")
self.ldsseal_date = self.get_widget("sealdate")
self.ldsseal_temple = self.get_widget("sealtemple")
self.ldsseal_fam = self.get_widget("sealparents")
self.ldsbapstat = self.get_widget("ldsbapstat")
self.ldssealstat = self.get_widget("sealstat")
self.ldsendowstat = self.get_widget("endowstat")
self.ldsbapplace = self.get_widget("ldsbapplace")
self.ldssealplace = self.get_widget("sealplace")
self.ldsendowplace = self.get_widget("endowplace")
self.build_bap_menu()
self.build_seal_menu()
self.build_endow_menu()
ord = person.getLdsBaptism()
self.ldsbap_temple.set_popdown_strings(_temple_names)
@ -346,7 +380,9 @@ class EditPerson:
f = fam.getFather()
m = fam.getMother()
if f and m:
name = _("%s and %s") % (Config.nameof(f),Config.nameof(m))
name = _("%(father)s and %(mother)s") % {
'father' : Config.nameof(f),
'mother' : Config.nameof(m) }
elif f:
name = Config.nameof(f)
elif m:
@ -364,38 +400,26 @@ class EditPerson:
self.ldsseal_fam.set_menu(myMenu)
self.ldsseal_fam.set_history(hist)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.event_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.event_list.connect('drag_data_get', self.ev_drag_data_get)
self.event_list.connect('drag_data_received', self.ev_drag_data_received)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.web_list.connect('drag_data_get', self.url_drag_data_get)
self.web_list.connect('drag_data_received', self.url_drag_data_received)
plist = self.db.getPlaceMap().values()
ord = self.person.getLdsBaptism()
if ord :
place = ord.getPlace()
else:
place = None
utils.attach_places(plist,self.ldsbapplace,place)
ord = self.person.getLdsSeal()
if ord :
place = ord.getPlace()
else:
place = None
utils.attach_places(plist,self.ldssealplace,place)
ord = self.person.getLdsEndowment()
if ord :
place = ord.getPlace()
else:
place = None
utils.attach_places(plist,self.ldsendowplace,place)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.attr_list.connect('drag_data_get', self.at_drag_data_get)
self.attr_list.connect('drag_data_received', self.at_drag_data_received)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.addr_list.connect('drag_data_get', self.ad_drag_data_get)
self.addr_list.connect('drag_data_received', self.ad_drag_data_received)
self.build_bap_menu()
self.build_seal_menu()
self.build_endow_menu()
# draw lists
self.redraw_event_list()
self.redraw_attr_list()
self.redraw_addr_list()
self.redraw_name_list()
self.redraw_url_list()
self.window.show()
def build_bap_menu(self):
menu = gtk.GtkMenu()
index = 0
@ -579,14 +603,8 @@ class EditPerson:
utils.redraw_list(self.elist,self.event_list,disp_event)
# Remember old combo list input
prev_btext = utils.strip_id(self.bpcombo.entry.get_text())
prev_dtext = utils.strip_id(self.dpcombo.entry.get_text())
# Update combo lists to add in any new places
plist = self.db.getPlaceMap().values()
if len(plist) > 0:
utils.attach_places(plist,self.dpcombo,self.death.getPlace())
utils.attach_places(plist,self.bpcombo,self.birth.getPlace())
prev_btext = utils.strip_id(self.bplace.get_text())
prev_dtext = utils.strip_id(self.dplace.get_text())
# Update birth with new values, make sure death values don't change
if (self.update_birth):
@ -654,12 +672,13 @@ class EditPerson:
pname = self.person.getPrimaryName().getName()
event = self.birth
event.setDate(self.bdate.get_text())
p = utils.get_place_from_list(self.bpcombo)
if p != None:
event.setPlace(p)
def_placename = None
def_placename = self.bplace.get_text()
if self.pmap.has_key(def_placename):
p = self.pmap[def_placename]
else:
def_placename = self.bpcombo.entry.get_text()
def_placename = None
if p != None:
event.setPlace(p)
EventEdit.EventEditor(self,pname,const.personalEvents,
const.save_fevent,event,def_placename,1)
@ -672,12 +691,13 @@ class EditPerson:
pname = self.person.getPrimaryName().getName()
event = self.death
event.setDate(self.ddate.get_text())
p = utils.get_place_from_list(self.dpcombo)
if p != None:
event.setPlace(p)
def_placename = None
def_placename = self.dplace.get_text()
if self.pmap.has_key(def_placename):
p = self.pmap[def_placename]
else:
def_placename = self.dpcombo.entry.get_text()
def_placename = None
if p != None:
event.setPlace(p)
EventEdit.EventEditor(self,pname,const.personalEvents,\
const.save_fevent,event,def_placename,1)
@ -775,14 +795,22 @@ class EditPerson:
bplace = string.strip(self.bplace.get_text())
dplace = string.strip(self.dplace.get_text())
p1 = utils.get_place_from_list(self.bpcombo)
if p1 == None and bplace != "":
changed = 1
bplace = self.bplace.get_text()
if self.pmap.has_key(bplace):
p1 = self.pmap[bplace]
else:
p1 = None
if bplace != "":
changed = 1
self.birth.setPlace(p1)
p1 = utils.get_place_from_list(self.dpcombo)
if p1 == None and dplace != "":
changed = 1
dplace = self.dplace.get_text()
if self.pmap.has_key(dplace):
p1 = self.pmap[dplace]
else:
p1 = None
if dplace != "":
changed = 1
self.death.setPlace(p1)
@ -1042,7 +1070,9 @@ class EditPerson:
else:
n = Config.nameof(m[idval])
msg1 = _("GRAMPS ID value was not changed.")
msg2 = _("%s is already used by %s") % (idval,n)
msg2 = _("%(grampsid)s is already used by %(person)s") % {
'grampsid' : idval,
'person' : n }
GnomeWarningDialog("%s\n%s" % (msg1,msg2))
if suffix != name.getSuffix():
@ -1069,8 +1099,11 @@ class EditPerson:
utils.modified()
self.birth.setDate(self.bdate.get_text())
bplace_obj = utils.get_place_from_list(self.bpcombo)
bplace = string.strip(self.bplace.get_text())
if self.pmap.has_key(bplace):
bplace_obj = self.pmap[bplace]
else:
bplace_obj = None
if bplace_obj == None and bplace != "":
bplace_obj = Place()
bplace_obj.set_title(bplace)
@ -1092,8 +1125,11 @@ class EditPerson:
family.setChildList(new_order)
self.death.setDate(self.ddate.get_text())
dplace_obj = utils.get_place_from_list(self.dpcombo)
dplace = string.strip(self.dplace.get_text())
if self.pmap.has_key(dplace):
dplace_obj = self.pmap[dplace]
else:
dplace_obj = None
if dplace_obj == None and dplace != "":
dplace_obj = Place()
dplace_obj.set_title(dplace)
@ -1155,61 +1191,62 @@ class EditPerson:
self.person.setNote(text)
utils.modified()
date = self.ldsbap_date.get_text()
temple = self.ldsbap_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple):
temple = const.lds_temple_codes[temple]
else:
temple = ""
ord = self.person.getLdsBaptism()
place = utils.get_place_from_list(self.ldsbapplace)
update_ord(self.person.setLdsBaptism,ord,date,temple,self.bap_stat,place)
if self.lds_not_loaded == 0:
date = self.ldsbap_date.get_text()
temple = self.ldsbap_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple):
temple = const.lds_temple_codes[temple]
else:
temple = ""
ord = self.person.getLdsBaptism()
place = utils.get_place_from_list(self.ldsbapplace)
update_ord(self.person.setLdsBaptism,ord,date,temple,self.bap_stat,place)
date = self.ldsend_date.get_text()
temple = self.ldsend_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple):
temple = const.lds_temple_codes[temple]
else:
temple = ""
ord = self.person.getLdsEndowment()
place = utils.get_place_from_list(self.ldsendowplace)
update_ord(self.person.setLdsEndowment,ord,date,temple,self.end_stat,place)
date = self.ldsend_date.get_text()
temple = self.ldsend_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple):
temple = const.lds_temple_codes[temple]
else:
temple = ""
ord = self.person.getLdsEndowment()
place = utils.get_place_from_list(self.ldsendowplace)
update_ord(self.person.setLdsEndowment,ord,date,temple,self.end_stat,place)
date = self.ldsseal_date.get_text()
temple = self.ldsseal_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple):
temple = const.lds_temple_codes[temple]
else:
temple = ""
ord = self.person.getLdsSeal()
place = utils.get_place_from_list(self.ldssealplace)
if not ord:
if self.ldsfam or date or temple:
ord = LdsOrd()
ord.setDate(date)
ord.setTemple(temple)
ord.setFamily(self.ldsfam)
ord.setPlace(place)
self.person.setLdsSeal(ord)
utils.modified()
else:
d = Date()
d.set(date)
if compare_dates(d,ord.getDateObj()) != 0:
ord.setDateObj(d)
utils.modified()
if ord.getPlace() != place:
ord.setPlace(place)
utils.modified()
if ord.getTemple() != temple:
ord.setTemple(temple)
utils.modified()
if ord.getStatus() != self.seal_stat:
ord.setStatus(self.seal_stat)
utils.modified()
if ord.getFamily() != self.ldsfam:
ord.setFamily(self.ldsfam)
utils.modified()
date = self.ldsseal_date.get_text()
temple = self.ldsseal_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple):
temple = const.lds_temple_codes[temple]
else:
temple = ""
ord = self.person.getLdsSeal()
place = utils.get_place_from_list(self.ldssealplace)
if not ord:
if self.ldsfam or date or temple:
ord = LdsOrd()
ord.setDate(date)
ord.setTemple(temple)
ord.setFamily(self.ldsfam)
ord.setPlace(place)
self.person.setLdsSeal(ord)
utils.modified()
else:
d = Date()
d.set(date)
if compare_dates(d,ord.getDateObj()) != 0:
ord.setDateObj(d)
utils.modified()
if ord.getPlace() != place:
ord.setPlace(place)
utils.modified()
if ord.getTemple() != temple:
ord.setTemple(temple)
utils.modified()
if ord.getStatus() != self.seal_stat:
ord.setStatus(self.seal_stat)
utils.modified()
if ord.getFamily() != self.ldsfam:
ord.setFamily(self.ldsfam)
utils.modified()
self.update_lists()
if self.callback:
@ -1293,25 +1330,7 @@ class EditPerson:
self.gallery.load_images()
elif page == 8 and self.lds_not_loaded:
self.lds_not_loaded = 0
plist = self.db.getPlaceMap().values()
ord = self.person.getLdsBaptism()
if ord :
place = ord.getPlace()
else:
place = None
utils.attach_places(plist,self.ldsbapplace,place)
ord = self.person.getLdsSeal()
if ord :
place = ord.getPlace()
else:
place = None
utils.attach_places(plist,self.ldssealplace,place)
ord = self.person.getLdsEndowment()
if ord :
place = ord.getPlace()
else:
place = None
utils.attach_places(plist,self.ldsendowplace,place)
self.draw_lds()
def update_ord(func,ord,date,temple,stat,place):
if not ord:

View File

@ -141,7 +141,7 @@ class Report:
class ReportDialog:
frame_pad = 5
border_pad = 5
border_pad = 2
def __init__(self,database,person):
"""Initialize a dialog to request that the user select options
@ -546,10 +546,7 @@ class ReportDialog:
its strings should be."""
(pagecount_map, start_text) = self.get_print_pagecount_map()
if pagecount_map:
table = GtkTable(2,4)
else:
table = GtkTable(1,4)
table = GtkTable(2,4)
self.paper_frame.add(table)
self.papersize_menu = GtkOptionMenu()
self.orientation_menu = GtkOptionMenu()
@ -565,13 +562,18 @@ class ReportDialog:
PaperMenu.make_paper_menu(self.papersize_menu)
PaperMenu.make_orientation_menu(self.orientation_menu)
l = GtkLabel(_("Quality"))
l.set_alignment(1.0,0.5)
table.attach(l,0,1,2,3,FILL,FILL,pad,pad)
l = GtkOptionMenu()
table.attach(l,1,2,2,3,xpadding=pad,ypadding=pad)
# The optional pagecount stuff.
if pagecount_map:
self.pagecount_menu = GtkOptionMenu()
myMenu = utils.build_string_optmenu(pagecount_map, start_text)
self.pagecount_menu.set_menu(myMenu)
table.attach(GtkLabel(_("Page Count")),0,1,1,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,1,2,1,2,xpadding=pad,ypadding=pad)
table.attach(GtkLabel(_("Page Count")),2,1,3,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,3,2,4,2,xpadding=pad,ypadding=pad)
def setup_html_frame(self):
"""Set up the html frame of the dialog. This sole purpose of

View File

@ -204,8 +204,8 @@ msgstr ""
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
"Language-Team: LANGUAGE <LL@li.org>\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=CHARSET\\n"
"Content-Transfer-Encoding: ENCODING\\n"
"Content-Type: text/plain; charset=iso-8859-1\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Generated-By: pygettext.py %(version)s\\n"
''')