From f589f8a71647d49b4f120657845711916c605ccb Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 5 Feb 2002 16:23:17 +0000 Subject: [PATCH] Improved place handing svn: r752 --- gramps/src/EditPerson.glade | 96 ++++-------------- gramps/src/EditPerson.py | 189 ++++++++++++++++-------------------- gramps/src/EventEdit.py | 43 +++++--- gramps/src/Plugins.py | 20 +--- gramps/src/Report.py | 5 - gramps/src/dialog.glade | 66 +++++-------- 6 files changed, 161 insertions(+), 258 deletions(-) diff --git a/gramps/src/EditPerson.glade b/gramps/src/EditPerson.glade index ca958ffc2..2435efb6d 100644 --- a/gramps/src/EditPerson.glade +++ b/gramps/src/EditPerson.glade @@ -4555,14 +4555,13 @@ - GtkCombo - ldsbapplace - False - True - False - True - False - + GtkEntry + lds_bap_place + True + True + True + 0 + 1 2 @@ -4577,23 +4576,6 @@ True False - - - GtkEntry - GtkCombo:entry - entry6 - True - - insert_text - on_combo_insert_text - bpcombo - Thu, 18 Oct 2001 01:13:13 GMT - - True - True - 0 - - @@ -4845,14 +4827,13 @@ - GtkCombo - endowplace - False - True - False - True - False - + GtkEntry + lds_end_place + True + True + True + 0 + 1 2 @@ -4867,23 +4848,6 @@ True False - - - GtkEntry - GtkCombo:entry - endowp - True - - insert_text - on_combo_insert_text - bpcombo - Thu, 18 Oct 2001 01:13:13 GMT - - True - True - 0 - - @@ -5184,14 +5148,13 @@ - GtkCombo - sealplace - False - True - False - True - False - + GtkEntry + lds_seal_place + True + True + True + 0 + 1 2 @@ -5206,23 +5169,6 @@ True False - - - GtkEntry - GtkCombo:entry - entry8 - True - - insert_text - on_combo_insert_text - bpcombo - Thu, 18 Oct 2001 01:13:13 GMT - - True - True - 0 - - diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index 8ec671e7b..4511c2ca6 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -215,8 +215,8 @@ 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) + self.autoplace = AutoComp.AutoComp(self.bplace,self.pmap.keys()) + AutoComp.AutoComp(self.dplace,self.pmap.keys(),self.autoplace) if Config.autocomp: self.comp = AutoComp.AutoComp(self.surname_field,const.surnames) @@ -243,7 +243,11 @@ class EditPerson: self.get_widget("user_colon").hide() self.get_widget("user_data").hide() - if Config.uselds: + self.lds_baptism = self.person.getLdsBaptism() + self.lds_endowment = self.person.getLdsEndowment() + self.lds_sealing = self.person.getLdsSeal() + + if Config.uselds or self.lds_baptism or self.lds_endowment or self.lds_sealing: self.get_widget("lds_tab").show() self.get_widget("lds_page").show() @@ -298,7 +302,29 @@ class EditPerson: self.redraw_name_list() self.redraw_url_list() + + def set_lds_field(self,ord,combo,date,place): + combo.set_popdown_strings(_temple_names) + if ord: + stat = ord.getStatus() + date.set_text(ord.getDate()) + if ord.getTemple() != "": + name = const.lds_temple_to_abrev[ord.getTemple()] + else: + name = "" + combo.entry.set_text(name) + else: + stat = 0 + combo.entry.set_text("") + + AutoComp.AutoComp(place,None,self.autoplace) + if ord and ord.getPlace(): + place.set_text(ord.getPlace().get_title()) + return stat + def draw_lds(self): + """Draws the LDS window. This window is not always drawn, and in may cases + is hidden.""" self.ldsbap_date = self.get_widget("ldsbapdate") self.ldsbap_temple = self.get_widget("ldsbaptemple") @@ -310,58 +336,28 @@ class EditPerson: 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.ldsbapplace = self.get_widget("lds_bap_place") + self.ldssealplace = self.get_widget("lds_seal_place") + self.ldsendowplace = self.get_widget("lds_end_place") - self.build_bap_menu() - self.build_seal_menu() - self.build_endow_menu() + self.bap_stat = self.set_lds_field(self.person.getLdsBaptism(), + self.ldsbap_temple, self.ldsbap_date, + self.ldsbapplace) - ord = person.getLdsBaptism() - self.ldsbap_temple.set_popdown_strings(_temple_names) - if ord: - self.bap_stat = ord.getStatus() - self.ldsbap_date.set_text(ord.getDate()) - if ord.getTemple() != "": - name = const.lds_temple_to_abrev[ord.getTemple()] - else: - name = "" - self.ldsbap_temple.entry.set_text(name) - else: - self.bap_stat = 0 - self.ldsbap_temple.entry.set_text("") + self.end_stat = self.set_lds_field(self.person.getLdsEndowment(), + self.ldsend_temple, self.ldsend_date, + self.ldsendowplace) - ord = person.getLdsEndowment() - self.ldsend_temple.set_popdown_strings(_temple_names) + ord = self.person.getLdsSeal() + self.seal_stat = self.set_lds_field(self.person.getLdsSeal(), + self.ldsseal_temple, self.ldsseal_date, + self.ldssealplace) if ord: - self.end_stat = ord.getStatus() - self.ldsend_date.set_text(ord.getDate()) - if ord.getTemple() != "": - name = const.lds_temple_to_abrev[ord.getTemple()] - else: - name = "" - self.ldsend_temple.entry.set_text(name) - else: - self.end_stat = 0 - self.ldsend_temple.entry.set_text("") - - ord = person.getLdsSeal() - self.ldsseal_temple.set_popdown_strings(_temple_names) - if ord: - self.seal_stat = ord.getStatus() - self.ldsseal_date.set_text(ord.getDate()) self.ldsfam = ord.getFamily() - if ord.getTemple() != "": - name = const.lds_temple_to_abrev[ord.getTemple()] - else: - name = "" - self.ldsseal_temple.entry.set_text(name) else: - self.seal_stat = 0 - self.ldsseal_temple.entry.set_text("") self.ldsfam = None + myMenu = gtk.GtkMenu() item = gtk.GtkMenuItem(_("None")) item.set_data("f",None) @@ -371,8 +367,8 @@ class EditPerson: index = 0 hist = 0 - flist = [person.getMainFamily()] - for (fam,mrel,frel) in person.getAltFamilyList(): + flist = [self.person.getMainFamily()] + for (fam,mrel,frel) in self.person.getAltFamilyList(): flist.append(fam) for fam in flist: if fam == None: @@ -400,25 +396,9 @@ class EditPerson: self.ldsseal_fam.set_menu(myMenu) self.ldsseal_fam.set_history(hist) - 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.build_bap_menu() + self.build_seal_menu() + self.build_endow_menu() def build_bap_menu(self): menu = gtk.GtkMenu() @@ -673,12 +653,9 @@ class EditPerson: event = self.birth event.setDate(self.bdate.get_text()) 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: - event.setPlace(p) + p = self.get_place(self.bplace) + if p != None: + event.setPlace(p) EventEdit.EventEditor(self,pname,const.personalEvents, const.save_fevent,event,def_placename,1) @@ -692,12 +669,9 @@ class EditPerson: event = self.death event.setDate(self.ddate.get_text()) 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: - event.setPlace(p) + p = self.get_place(self.dplace) + if p != None: + event.setPlace(p) EventEdit.EventEditor(self,pname,const.personalEvents,\ const.save_fevent,event,def_placename,1) @@ -832,7 +806,7 @@ class EditPerson: def check_lds(self): date = self.ldsbap_date.get_text() temple = self.ldsbap_temple.entry.get_text() - place = utils.get_place_from_list(self.ldsbapplace) + place = self.get_place(self.ldsbapplace) if const.lds_temple_codes.has_key(temple): temple = const.lds_temple_codes[temple] @@ -854,7 +828,7 @@ class EditPerson: date = self.ldsend_date.get_text() temple = self.ldsend_temple.entry.get_text() - place = utils.get_place_from_list(self.ldsendowplace) + place = self.get_place(self.ldsendowplace) if const.lds_temple_codes.has_key(temple): temple = const.lds_temple_codes[temple] @@ -876,7 +850,7 @@ class EditPerson: date = self.ldsseal_date.get_text() temple = self.ldsseal_temple.entry.get_text() - place = utils.get_place_from_list(self.ldssealplace) + place = self.get_place(self.ldssealplace) if const.lds_temple_codes.has_key(temple): temple = const.lds_temple_codes[temple] else: @@ -1100,16 +1074,7 @@ class EditPerson: self.birth.setDate(self.bdate.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 != "": - bplace_obj = Place() - bplace_obj.set_title(bplace) - self.db.addPlace(bplace_obj) - utils.modified() - self.birth.setPlace(bplace_obj) + self.birth.setPlace(self.get_place(self.bplace,1)) if not self.person.getBirth().are_equal(self.birth): self.person.setBirth(self.birth) @@ -1125,17 +1090,7 @@ class EditPerson: family.setChildList(new_order) self.death.setDate(self.ddate.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 != "": - dplace_obj = Place() - dplace_obj.set_title(dplace) - self.db.addPlace(dplace_obj) - utils.modified() - self.death.setPlace(dplace_obj) + self.death.setPlace(self.get_place(self.dplace,1)) if not self.person.getDeath().are_equal(self.death): self.person.setDeath(self.death) @@ -1199,7 +1154,7 @@ class EditPerson: else: temple = "" ord = self.person.getLdsBaptism() - place = utils.get_place_from_list(self.ldsbapplace) + place = self.get_place(self.ldsbapplace,1) update_ord(self.person.setLdsBaptism,ord,date,temple,self.bap_stat,place) date = self.ldsend_date.get_text() @@ -1209,7 +1164,8 @@ class EditPerson: else: temple = "" ord = self.person.getLdsEndowment() - place = utils.get_place_from_list(self.ldsendowplace) + place = self.get_place(self.ldsendowplace,1) + print place update_ord(self.person.setLdsEndowment,ord,date,temple,self.end_stat,place) date = self.ldsseal_date.get_text() @@ -1219,7 +1175,7 @@ class EditPerson: else: temple = "" ord = self.person.getLdsSeal() - place = utils.get_place_from_list(self.ldssealplace) + place = self.get_place(self.ldssealplace,1) if not ord: if self.ldsfam or date or temple: ord = LdsOrd() @@ -1253,6 +1209,23 @@ class EditPerson: self.callback(self) utils.destroy_passed_object(obj) + def get_place(self,field,makenew=0): + text = string.strip(field.get_text()) + if text != "": + if self.pmap.has_key(text): + return self.pmap[text] + elif makenew: + place = Place() + place.set_title(text) + self.pmap[text] = place + self.db.addPlace(place) + utils.modified() + return place + else: + return None + else: + return None + def on_primary_name_source_clicked(self,obj): import Sources Sources.SourceSelector(self.pname.getSourceRefList(),self,src_changed) @@ -1334,7 +1307,7 @@ class EditPerson: def update_ord(func,ord,date,temple,stat,place): if not ord: - if (date or temple): + if (date or temple or place): ord = LdsOrd() ord.setDate(date) ord.setTemple(temple) diff --git a/gramps/src/EventEdit.py b/gramps/src/EventEdit.py index 7dabfcebf..70f39c050 100644 --- a/gramps/src/EventEdit.py +++ b/gramps/src/EventEdit.py @@ -37,6 +37,8 @@ import Sources import const import utils import Config +import AutoComp + from Date import compare_dates from RelLib import * from intl import gettext @@ -53,6 +55,11 @@ class EventEditor: self.parent = parent self.event = event self.trans = trans + + self.pmap = {} + for p in self.parent.db.getPlaces(): + self.pmap[p.get_title()] = p + if event: self.srcreflist = self.event.getSourceRefList() self.date = Date(self.event.getDateObj()) @@ -91,14 +98,15 @@ class EventEditor: self.window.editable_enters(self.cause_field); self.window.editable_enters(self.descr_field); - values = self.parent.db.getPlaceMap().values() + AutoComp.AutoComp(self.place_field,self.pmap.keys()) + if event != None: self.name_field.set_text(event.getName()) - - utils.attach_places(values,self.place_combo,event.getPlace()) - self.place_field.set_text(event.getPlaceName()) if (def_placename): self.place_field.set_text(def_placename) + else: + self.place_field.set_text(event.getPlaceName()) + self.date_field.set_text(self.date.getDate()) self.cause_field.set_text(event.getCause()) self.descr_field.set_text(event.getDescription()) @@ -108,7 +116,6 @@ class EventEditor: self.note_field.insert_defaults(event.getNote()) self.note_field.set_word_wrap(1) else: - utils.attach_places(values,self.place_combo,None) if (def_placename): self.place_field.set_text(def_placename) @@ -118,7 +125,6 @@ class EventEditor: self.window.set_data("o",self) self.top.signal_autoconnect({ "destroy_passed_object" : utils.destroy_passed_object, - "on_combo_insert_text" : utils.combo_insert_text, "on_event_edit_ok_clicked" : self.on_event_edit_ok_clicked, "on_source_clicked" : self.on_edit_source_clicked }) @@ -141,6 +147,23 @@ class EventEditor: def on_edit_source_clicked(self,obj): Sources.SourceSelector(self.srcreflist,self.parent,src_changed) + def get_place(self,field,makenew=0): + text = strip(field.get_text()) + if text != "": + if self.pmap.has_key(text): + return self.pmap[text] + elif makenew: + place = Place() + place.set_title(text) + self.pmap[text] = place + self.parent.db.addPlace(place) + utils.modified() + return place + else: + return None + else: + return None + def on_event_edit_ok_clicked(self,obj): ename = self.name_field.get_text() @@ -148,7 +171,8 @@ class EventEditor: ecause = self.cause_field.get_text() eplace = strip(self.place_field.get_text()) - eplace_obj = utils.get_place_from_list(self.place_combo) + + eplace_obj = self.get_place(self.place_field,1) enote = self.note_field.get_chars(0,-1) edesc = self.descr_field.get_text() epriv = self.priv.get_active() @@ -158,11 +182,6 @@ class EventEditor: self.event.setSourceRefList(self.srcreflist) self.parent.elist.append(self.event) - if eplace_obj == None and eplace != "": - eplace_obj = Place() - eplace_obj.set_title(eplace) - self.parent.db.addPlace(eplace_obj) - self.update_event(ename,self.date,eplace_obj,edesc,enote,epriv,ecause) self.parent.redraw_event_list() utils.destroy_passed_object(obj) diff --git a/gramps/src/Plugins.py b/gramps/src/Plugins.py index e9c9474e9..109362117 100644 --- a/gramps/src/Plugins.py +++ b/gramps/src/Plugins.py @@ -276,10 +276,7 @@ def load_plugins(dir): a = __import__(plugin) _success.append(a) except: - print _("Failed to load the module: %s") % plugin - import traceback - traceback.print_exc() - _failed.append(plugin) + print _("Note: failed to load the plugin module: %s") % plugin #------------------------------------------------------------------------- # @@ -298,10 +295,7 @@ def reload_plugins(obj): try: reload(plugin) except: - print _("Failed to load the module: %s") % plugin - import traceback - traceback.print_exc() - _failed.append(plugin) + print _("Note: failed to load the plugin module: %s") % plugin # attempt to load the plugins that have failed in the past @@ -309,10 +303,7 @@ def reload_plugins(obj): try: __import__(plugin) except: - print _("Failed to load the module: %s") % plugin - import traceback - traceback.print_exc() - _failed.append(plugin) + print _("Note: failed to load the plugin module: %s") % plugin # attempt to load any new files found for dir in _loaddir: @@ -329,10 +320,7 @@ def reload_plugins(obj): a = __import__(plugin) _success.append(a) except: - print _("Failed to load the module: %s") % plugin - import traceback - traceback.print_exc() - _failed.append(plugin) + print _("Note: failed to load the plugin module: %s") % plugin #------------------------------------------------------------------------- # diff --git a/gramps/src/Report.py b/gramps/src/Report.py index eafc1720e..2c110fb09 100644 --- a/gramps/src/Report.py +++ b/gramps/src/Report.py @@ -562,11 +562,6 @@ 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() diff --git a/gramps/src/dialog.glade b/gramps/src/dialog.glade index fc89d203c..8f1157f06 100644 --- a/gramps/src/dialog.glade +++ b/gramps/src/dialog.glade @@ -240,48 +240,6 @@ - - GtkCombo - eventPlace_combo - False - True - False - True - False - - - 1 - 2 - 2 - 3 - 3 - 3 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - eventPlace - True - - insert_text - on_combo_insert_text - eventPlace_combo - Thu, 18 Oct 2001 01:17:09 GMT - - True - True - 0 - - - - GtkCombo personalEvents @@ -573,6 +531,30 @@ French False + + + GtkEntry + eventPlace + True + True + True + 0 + + + 1 + 2 + 2 + 3 + 3 + 3 + True + False + False + False + True + False + +