Improved place handing

svn: r752
This commit is contained in:
Don Allingham 2002-02-05 16:23:17 +00:00
parent 03e40fb897
commit f589f8a716
6 changed files with 161 additions and 258 deletions

View File

@ -4555,14 +4555,13 @@
</widget>
<widget>
<class>GtkCombo</class>
<name>ldsbapplace</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>
<class>GtkEntry</class>
<name>lds_bap_place</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>1</left_attach>
<right_attach>2</right_attach>
@ -4577,23 +4576,6 @@
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>entry6</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>
@ -4845,14 +4827,13 @@
</widget>
<widget>
<class>GtkCombo</class>
<name>endowplace</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>
<class>GtkEntry</class>
<name>lds_end_place</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>1</left_attach>
<right_attach>2</right_attach>
@ -4867,23 +4848,6 @@
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>endowp</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>
@ -5184,14 +5148,13 @@
</widget>
<widget>
<class>GtkCombo</class>
<name>sealplace</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>
<class>GtkEntry</class>
<name>lds_seal_place</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>1</left_attach>
<right_attach>2</right_attach>
@ -5206,23 +5169,6 @@
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>entry8</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>

View File

@ -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)

View File

@ -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)

View File

@ -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
#-------------------------------------------------------------------------
#

View File

@ -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()

View File

@ -240,48 +240,6 @@
</child>
</widget>
<widget>
<class>GtkCombo</class>
<name>eventPlace_combo</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>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</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>eventPlace</name>
<can_focus>True</can_focus>
<signal>
<name>insert_text</name>
<handler>on_combo_insert_text</handler>
<object>eventPlace_combo</object>
<last_modification_time>Thu, 18 Oct 2001 01:17:09 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>GtkCombo</class>
<name>personalEvents</name>
@ -573,6 +531,30 @@ French
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>eventPlace</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>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</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>