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

View File

@ -286,48 +286,6 @@
</child> </child>
</widget> </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> <widget>
<class>GtkEntry</class> <class>GtkEntry</class>
<name>birthDate</name> <name>birthDate</name>
@ -382,6 +340,30 @@
<yfill>False</yfill> <yfill>False</yfill>
</child> </child>
</widget> </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>
</widget> </widget>
@ -544,48 +526,6 @@
</child> </child>
</widget> </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> <widget>
<class>GtkButton</class> <class>GtkButton</class>
<name>button126</name> <name>button126</name>
@ -615,6 +555,30 @@
<yfill>False</yfill> <yfill>False</yfill>
</child> </child>
</widget> </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>
</widget> </widget>

View File

@ -81,6 +81,9 @@ class EditPerson:
self.lists_changed = 0 self.lists_changed = 0
self.update_birth = 0 self.update_birth = 0
self.update_death = 0 self.update_death = 0
self.pmap = {}
for p in db.getPlaces():
self.pmap[p.get_title()] = p
self.load_obj = None self.load_obj = None
self.top = libglade.GladeXML(const.editPersonFile, "editPerson") self.top = libglade.GladeXML(const.editPersonFile, "editPerson")
@ -177,10 +180,8 @@ class EditPerson:
self.title = self.get_widget("title") self.title = self.get_widget("title")
self.bdate = self.get_widget("birthDate") self.bdate = self.get_widget("birthDate")
self.bplace = self.get_widget("birthPlace") self.bplace = self.get_widget("birthPlace")
self.bpcombo = self.get_widget("bpcombo")
self.ddate = self.get_widget("deathDate") self.ddate = self.get_widget("deathDate")
self.dplace = self.get_widget("deathPlace") self.dplace = self.get_widget("deathPlace")
self.dpcombo = self.get_widget("dpcombo")
self.is_male = self.get_widget("genderMale") self.is_male = self.get_widget("genderMale")
self.is_female = self.get_widget("genderFemale") self.is_female = self.get_widget("genderFemale")
self.is_unknown = self.get_widget("genderUnknown") self.is_unknown = self.get_widget("genderUnknown")
@ -191,19 +192,6 @@ class EditPerson:
self.name_note = self.get_widget("name_note") self.name_note = self.get_widget("name_note")
self.name_source = self.get_widget("name_source") self.name_source = self.get_widget("name_source")
self.gid = self.get_widget("gid") 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.elist = person.getEventList()[:]
self.nlist = person.getAlternateNames()[:] self.nlist = person.getAlternateNames()[:]
@ -227,6 +215,8 @@ class EditPerson:
self.window.editable_enters(self.ddate); self.window.editable_enters(self.ddate);
self.window.editable_enters(self.dplace); 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: if Config.autocomp:
self.comp = AutoComp.AutoComp(self.surname_field,const.surnames) self.comp = AutoComp.AutoComp(self.surname_field,const.surnames)
@ -282,7 +272,51 @@ class EditPerson:
self.notes_field.insert_defaults(person.getNote()) self.notes_field.insert_defaults(person.getNote())
self.notes_field.set_word_wrap(1) 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() ord = person.getLdsBaptism()
self.ldsbap_temple.set_popdown_strings(_temple_names) self.ldsbap_temple.set_popdown_strings(_temple_names)
@ -346,7 +380,9 @@ class EditPerson:
f = fam.getFather() f = fam.getFather()
m = fam.getMother() m = fam.getMother()
if f and m: 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: elif f:
name = Config.nameof(f) name = Config.nameof(f)
elif m: elif m:
@ -364,37 +400,25 @@ class EditPerson:
self.ldsseal_fam.set_menu(myMenu) self.ldsseal_fam.set_menu(myMenu)
self.ldsseal_fam.set_history(hist) self.ldsseal_fam.set_history(hist)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) plist = self.db.getPlaceMap().values()
self.event_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) ord = self.person.getLdsBaptism()
self.event_list.connect('drag_data_get', self.ev_drag_data_get) if ord :
self.event_list.connect('drag_data_received', self.ev_drag_data_received) place = ord.getPlace()
else:
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) place = None
self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) utils.attach_places(plist,self.ldsbapplace,place)
self.web_list.connect('drag_data_get', self.url_drag_data_get) ord = self.person.getLdsSeal()
self.web_list.connect('drag_data_received', self.url_drag_data_received) if ord :
place = ord.getPlace()
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) else:
self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) place = None
self.attr_list.connect('drag_data_get', self.at_drag_data_get) utils.attach_places(plist,self.ldssealplace,place)
self.attr_list.connect('drag_data_received', self.at_drag_data_received) ord = self.person.getLdsEndowment()
if ord :
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY) place = ord.getPlace()
self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY) else:
self.addr_list.connect('drag_data_get', self.ad_drag_data_get) place = None
self.addr_list.connect('drag_data_received', self.ad_drag_data_received) utils.attach_places(plist,self.ldsendowplace,place)
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): def build_bap_menu(self):
menu = gtk.GtkMenu() menu = gtk.GtkMenu()
@ -579,14 +603,8 @@ class EditPerson:
utils.redraw_list(self.elist,self.event_list,disp_event) utils.redraw_list(self.elist,self.event_list,disp_event)
# Remember old combo list input # Remember old combo list input
prev_btext = utils.strip_id(self.bpcombo.entry.get_text()) prev_btext = utils.strip_id(self.bplace.get_text())
prev_dtext = utils.strip_id(self.dpcombo.entry.get_text()) prev_dtext = utils.strip_id(self.dplace.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())
# Update birth with new values, make sure death values don't change # Update birth with new values, make sure death values don't change
if (self.update_birth): if (self.update_birth):
@ -654,12 +672,13 @@ class EditPerson:
pname = self.person.getPrimaryName().getName() pname = self.person.getPrimaryName().getName()
event = self.birth event = self.birth
event.setDate(self.bdate.get_text()) event.setDate(self.bdate.get_text())
p = utils.get_place_from_list(self.bpcombo) def_placename = self.bplace.get_text()
if self.pmap.has_key(def_placename):
p = self.pmap[def_placename]
else:
def_placename = None
if p != None: if p != None:
event.setPlace(p) event.setPlace(p)
def_placename = None
else:
def_placename = self.bpcombo.entry.get_text()
EventEdit.EventEditor(self,pname,const.personalEvents, EventEdit.EventEditor(self,pname,const.personalEvents,
const.save_fevent,event,def_placename,1) const.save_fevent,event,def_placename,1)
@ -672,12 +691,13 @@ class EditPerson:
pname = self.person.getPrimaryName().getName() pname = self.person.getPrimaryName().getName()
event = self.death event = self.death
event.setDate(self.ddate.get_text()) event.setDate(self.ddate.get_text())
p = utils.get_place_from_list(self.dpcombo) def_placename = self.dplace.get_text()
if self.pmap.has_key(def_placename):
p = self.pmap[def_placename]
else:
def_placename = None
if p != None: if p != None:
event.setPlace(p) event.setPlace(p)
def_placename = None
else:
def_placename = self.dpcombo.entry.get_text()
EventEdit.EventEditor(self,pname,const.personalEvents,\ EventEdit.EventEditor(self,pname,const.personalEvents,\
const.save_fevent,event,def_placename,1) const.save_fevent,event,def_placename,1)
@ -775,13 +795,21 @@ class EditPerson:
bplace = string.strip(self.bplace.get_text()) bplace = string.strip(self.bplace.get_text())
dplace = string.strip(self.dplace.get_text()) dplace = string.strip(self.dplace.get_text())
p1 = utils.get_place_from_list(self.bpcombo) bplace = self.bplace.get_text()
if p1 == None and bplace != "": if self.pmap.has_key(bplace):
p1 = self.pmap[bplace]
else:
p1 = None
if bplace != "":
changed = 1 changed = 1
self.birth.setPlace(p1) self.birth.setPlace(p1)
p1 = utils.get_place_from_list(self.dpcombo)
if p1 == None and dplace != "": dplace = self.dplace.get_text()
if self.pmap.has_key(dplace):
p1 = self.pmap[dplace]
else:
p1 = None
if dplace != "":
changed = 1 changed = 1
self.death.setPlace(p1) self.death.setPlace(p1)
@ -1042,7 +1070,9 @@ class EditPerson:
else: else:
n = Config.nameof(m[idval]) n = Config.nameof(m[idval])
msg1 = _("GRAMPS ID value was not changed.") 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)) GnomeWarningDialog("%s\n%s" % (msg1,msg2))
if suffix != name.getSuffix(): if suffix != name.getSuffix():
@ -1069,8 +1099,11 @@ class EditPerson:
utils.modified() utils.modified()
self.birth.setDate(self.bdate.get_text()) self.birth.setDate(self.bdate.get_text())
bplace_obj = utils.get_place_from_list(self.bpcombo)
bplace = string.strip(self.bplace.get_text()) 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 != "": if bplace_obj == None and bplace != "":
bplace_obj = Place() bplace_obj = Place()
bplace_obj.set_title(bplace) bplace_obj.set_title(bplace)
@ -1092,8 +1125,11 @@ class EditPerson:
family.setChildList(new_order) family.setChildList(new_order)
self.death.setDate(self.ddate.get_text()) self.death.setDate(self.ddate.get_text())
dplace_obj = utils.get_place_from_list(self.dpcombo)
dplace = string.strip(self.dplace.get_text()) 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 != "": if dplace_obj == None and dplace != "":
dplace_obj = Place() dplace_obj = Place()
dplace_obj.set_title(dplace) dplace_obj.set_title(dplace)
@ -1155,6 +1191,7 @@ class EditPerson:
self.person.setNote(text) self.person.setNote(text)
utils.modified() utils.modified()
if self.lds_not_loaded == 0:
date = self.ldsbap_date.get_text() date = self.ldsbap_date.get_text()
temple = self.ldsbap_temple.entry.get_text() temple = self.ldsbap_temple.entry.get_text()
if const.lds_temple_codes.has_key(temple): if const.lds_temple_codes.has_key(temple):
@ -1293,25 +1330,7 @@ class EditPerson:
self.gallery.load_images() self.gallery.load_images()
elif page == 8 and self.lds_not_loaded: elif page == 8 and self.lds_not_loaded:
self.lds_not_loaded = 0 self.lds_not_loaded = 0
plist = self.db.getPlaceMap().values() self.draw_lds()
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)
def update_ord(func,ord,date,temple,stat,place): def update_ord(func,ord,date,temple,stat,place):
if not ord: if not ord:

View File

@ -141,7 +141,7 @@ class Report:
class ReportDialog: class ReportDialog:
frame_pad = 5 frame_pad = 5
border_pad = 5 border_pad = 2
def __init__(self,database,person): def __init__(self,database,person):
"""Initialize a dialog to request that the user select options """Initialize a dialog to request that the user select options
@ -546,10 +546,7 @@ class ReportDialog:
its strings should be.""" its strings should be."""
(pagecount_map, start_text) = self.get_print_pagecount_map() (pagecount_map, start_text) = self.get_print_pagecount_map()
if pagecount_map:
table = GtkTable(2,4) table = GtkTable(2,4)
else:
table = GtkTable(1,4)
self.paper_frame.add(table) self.paper_frame.add(table)
self.papersize_menu = GtkOptionMenu() self.papersize_menu = GtkOptionMenu()
self.orientation_menu = GtkOptionMenu() self.orientation_menu = GtkOptionMenu()
@ -565,13 +562,18 @@ class ReportDialog:
PaperMenu.make_paper_menu(self.papersize_menu) PaperMenu.make_paper_menu(self.papersize_menu)
PaperMenu.make_orientation_menu(self.orientation_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. # The optional pagecount stuff.
if pagecount_map: if pagecount_map:
self.pagecount_menu = GtkOptionMenu() self.pagecount_menu = GtkOptionMenu()
myMenu = utils.build_string_optmenu(pagecount_map, start_text) myMenu = utils.build_string_optmenu(pagecount_map, start_text)
self.pagecount_menu.set_menu(myMenu) self.pagecount_menu.set_menu(myMenu)
table.attach(GtkLabel(_("Page Count")),0,1,1,2,FILL,FILL,pad,pad) table.attach(GtkLabel(_("Page Count")),2,1,3,2,FILL,FILL,pad,pad)
table.attach(self.pagecount_menu,1,2,1,2,xpadding=pad,ypadding=pad) table.attach(self.pagecount_menu,3,2,4,2,xpadding=pad,ypadding=pad)
def setup_html_frame(self): def setup_html_frame(self):
"""Set up the html frame of the dialog. This sole purpose of """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" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
"Language-Team: LANGUAGE <LL@li.org>\\n" "Language-Team: LANGUAGE <LL@li.org>\\n"
"MIME-Version: 1.0\\n" "MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=CHARSET\\n" "Content-Type: text/plain; charset=iso-8859-1\\n"
"Content-Transfer-Encoding: ENCODING\\n" "Content-Transfer-Encoding: 8bit\\n"
"Generated-By: pygettext.py %(version)s\\n" "Generated-By: pygettext.py %(version)s\\n"
''') ''')