* src/RelLib.py: rework of the API

* src/*.py: rework of the api


svn: r3371
This commit is contained in:
Don Allingham 2004-08-11 03:42:38 +00:00
parent 082907d675
commit 93c5dbebcd
26 changed files with 771 additions and 856 deletions

View File

@ -1,3 +1,7 @@
2004-08-10 Don Allingham <dallingham@users.sourceforge.net>
* src/RelLib.py: rework of the API
* src/*.py: rework of the api
2004-08-06 Don Allingham <dallingham@users.sourceforge.net> 2004-08-06 Don Allingham <dallingham@users.sourceforge.net>
* various: change try_to_find_*_from_handle to * various: change try_to_find_*_from_handle to
get_*_from_handle get_*_from_handle

View File

@ -1,5 +1,5 @@
%define ver 1.1.1 %define ver 1.1.1
%define rel 0.CVS20040730 %define rel 0.CVS20040806
%define prefix /usr %define prefix /usr
%define localstatedir /var/lib %define localstatedir /var/lib
# Ensure that internal RPM macros for configure & makeinstall # Ensure that internal RPM macros for configure & makeinstall

View File

@ -1,5 +1,5 @@
%define ver 1.1.1 %define ver 1.1.1
%define rel 0.CVS20040730 %define rel 0.CVS20040806
%define prefix /usr %define prefix /usr
%define localstatedir /var/lib %define localstatedir /var/lib
# Ensure that internal RPM macros for configure & makeinstall # Ensure that internal RPM macros for configure & makeinstall

View File

@ -213,17 +213,12 @@ class AddSpouse:
""" """
person = epo.person person = epo.person
trans = self.db.start_transaction() trans = self.db.start_transaction()
id = person.get_handle() handle = self.db.add_person(person,trans)
if id == "":
id = self.db.add_person(person,trans)
else:
self.db.add_person_no_map(person,id,trans)
person = self.db.get_person_from_handle(id)
n = person.get_primary_name().get_name() n = person.get_primary_name().get_name()
self.db.add_transaction(trans,_('Add Person (%s)' % n)) self.db.add_transaction(trans,_('Add Person (%s)' % n))
self.addperson(person) self.addperson(person)
self.update_data(id) self.update_data(handle)
self.slist = PeopleModel.PeopleModel(self.db) self.slist = PeopleModel.PeopleModel(self.db)
self.slist.rebuild_data() self.slist.rebuild_data()

View File

@ -55,7 +55,6 @@ def fill_entry(entry,data_list):
entry.set_completion(completion) entry.set_completion(completion)
def fill_option_text(combobox,data): def fill_option_text(combobox,data):
typelist = []
store = gtk.ListStore(gobject.TYPE_STRING) store = gtk.ListStore(gobject.TYPE_STRING)
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
combobox.pack_start(cell,gtk.TRUE) combobox.pack_start(cell,gtk.TRUE)

View File

@ -68,7 +68,6 @@ fmt7 = re.compile(_start+r"([?\d]+)\s*[./-]\s*([?\d]+)\s*$", re.IGNORECASE)
fmt4 = re.compile(_start+"(\S+)\s+(\d+)\s*$", re.IGNORECASE) fmt4 = re.compile(_start+"(\S+)\s+(\d+)\s*$", re.IGNORECASE)
fmt5 = re.compile(_start+"(\d+)\s*$", re.IGNORECASE) fmt5 = re.compile(_start+"(\d+)\s*$", re.IGNORECASE)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #

View File

@ -306,7 +306,7 @@ class ChooseParents:
fam = self.db.find_family_from_handle(family_handle) fam = self.db.find_family_from_handle(family_handle)
for handle in [fam.get_father_handle(), fam.get_mother_handle()] + \ for handle in [fam.get_father_handle(), fam.get_mother_handle()] + \
fam.get_child_handle_list(): fam.get_child_handle_list():
if id: if handle:
self.exclude[handle] = 1 self.exclude[handle] = 1
def redrawf(self): def redrawf(self):
@ -569,28 +569,23 @@ class ChooseParents:
depending on the gender of the person.""" depending on the gender of the person."""
person = epo.person person = epo.person
id = person.get_handle() handle = person.get_handle()
name = person.get_primary_name().get_surname() name = person.get_primary_name().get_surname()
self.db.add_person(person,trans)
if id == "":
id = self.db.add_person(person,trans)
else:
self.db.add_person_no_map(person,id,trans)
self.type = self.prel.get_active() self.type = self.prel.get_active()
if self.type == const.FAMILY_CIVIL_UNION: if self.type == const.FAMILY_CIVIL_UNION:
self.parent_relation_changed(self.prel) self.parent_relation_changed(self.prel)
elif person.get_gender() == RelLib.Person.male: elif person.get_gender() == RelLib.Person.male:
self.redrawf() self.redrawf()
path = self.father_nsort.on_get_path(id) path = self.father_nsort.on_get_path(handle)
top_path = self.father_nsort.on_get_path(name) top_path = self.father_nsort.on_get_path(name)
self.father_list.expand_row(top_path,0) self.father_list.expand_row(top_path,0)
self.father_selection.select_path(path) self.father_selection.select_path(path)
self.father_list.scroll_to_cell(path,None,1,0.5,0) self.father_list.scroll_to_cell(path,None,1,0.5,0)
else: else:
self.redrawm() self.redrawm()
path = self.mother_nsort.on_get_path(id) path = self.mother_nsort.on_get_path(handle)
top_path = self.mother_nsort.on_get_path(name) top_path = self.mother_nsort.on_get_path(name)
self.mother_list.expand_row(top_path,0) self.mother_list.expand_row(top_path,0)
self.mother_selection.select_path(path) self.mother_selection.select_path(path)

View File

@ -61,15 +61,15 @@ class ColumnOrder:
self.glade.get_widget('cancelbutton').connect('clicked',self.cancel_clicked) self.glade.get_widget('cancelbutton').connect('clicked',self.cancel_clicked)
for item in self.arglist: for item in self.arglist:
iter = self.model.append() node = self.model.append()
self.model.set(iter,0,item[0],1,column_names[item[1]],2,item[1]) self.model.set(node,0,item[0],1,column_names[item[1]],2,item[1])
def ok_clicked(self,obj): def ok_clicked(self,obj):
newlist = [] newlist = []
for i in range(0,len(self.arglist)): for i in range(0,len(self.arglist)):
iter = self.model.get_iter((int(i),)) node = self.model.get_iter((int(i),))
newlist.append((self.model.get_value(iter,0), newlist.append((self.model.get_value(node,0),
self.model.get_value(iter,2))) self.model.get_value(node,2)))
self.callback(newlist) self.callback(newlist)
self.top.destroy() self.top.destroy()
@ -77,7 +77,7 @@ class ColumnOrder:
self.top.destroy() self.top.destroy()
def toggled(self, cell, path, model): def toggled(self, cell, path, model):
iter = model.get_iter((int(path),)) node = model.get_iter((int(path),))
value = model.get_value(iter,0) value = model.get_value(node,0)
value = not value value = not value
model.set(iter,0,value) model.set(node,0,value)

View File

@ -128,32 +128,32 @@ class ExistingDbPrompter:
gtk.RESPONSE_OK)) gtk.RESPONSE_OK))
choose.set_local_only(gtk.FALSE) choose.set_local_only(gtk.FALSE)
# Always add automatic (macth all files) filter # Always add automatic (macth all files) filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('Automatic')) mime_filter.set_name(_('Automatic'))
filter.add_pattern('*') mime_filter.add_pattern('*')
choose.add_filter(filter) choose.add_filter(mime_filter)
# Always add native format filter # Always add native format filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('GRAMPS databases')) mime_filter.set_name(_('GRAMPS databases'))
filter.add_mime_type(const.app_gramps) mime_filter.add_mime_type(const.app_gramps)
choose.add_filter(filter) choose.add_filter(mime_filter)
# Always add native format filter # Always add native format filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('GRAMPS XML databases')) mime_filter.set_name(_('GRAMPS XML databases'))
filter.add_mime_type(const.app_gramps_xml) mime_filter.add_mime_type(const.app_gramps_xml)
choose.add_filter(filter) choose.add_filter(mime_filter)
# Always add native format filter # Always add native format filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('GEDCOM')) mime_filter.set_name(_('GEDCOM'))
filter.add_mime_type(const.app_gedcom) mime_filter.add_mime_type(const.app_gedcom)
choose.add_filter(filter) choose.add_filter(mime_filter)
# Add more data type selections if opening existing db # Add more data type selections if opening existing db
for (importData,filter,mime_type) in Plugins._imports: for (importData,mime_filter,mime_type) in Plugins._imports:
choose.add_filter(filter) choose.add_filter(mime_filter)
response = choose.run() response = choose.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
@ -176,7 +176,7 @@ class ExistingDbPrompter:
self.parent.read_file(filename) self.parent.read_file(filename)
return 1 return 1
(junk,the_file) = os.path.split(filename) (junk,the_file) = os.path.split(filename)
for (importData,filter,mime_type) in Plugins._imports: for (importData,mime_filter,mime_type) in Plugins._imports:
if filetype == mime_type or the_file == mime_type: if filetype == mime_type or the_file == mime_type:
choose.destroy() choose.destroy()
QuestionDialog.OkDialog( _("Opening non-native format"), QuestionDialog.OkDialog( _("Opening non-native format"),
@ -234,10 +234,10 @@ class ImportDbPrompter:
gtk.RESPONSE_OK)) gtk.RESPONSE_OK))
choose.set_local_only(gtk.FALSE) choose.set_local_only(gtk.FALSE)
# Always add automatic (macth all files) filter # Always add automatic (macth all files) filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('Automatic')) mime_filter.set_name(_('Automatic'))
filter.add_pattern('*') mime_filter.add_pattern('*')
choose.add_filter(filter) choose.add_filter(mime_filter)
# FIXME: Uncomment when we have grdb importer # FIXME: Uncomment when we have grdb importer
# #
@ -248,8 +248,8 @@ class ImportDbPrompter:
# choose.add_filter(filter) # choose.add_filter(filter)
# Add more data type selections if opening existing db # Add more data type selections if opening existing db
for (importData,filter,mime_type) in Plugins._imports: for (importData,mime_filter,mime_type) in Plugins._imports:
choose.add_filter(filter) choose.add_filter(mime_filter)
response = choose.run() response = choose.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
@ -262,7 +262,7 @@ class ImportDbPrompter:
# self.parent.read_file(filename) # self.parent.read_file(filename)
# return 1 # return 1
(junk,the_file) = os.path.split(filename) (junk,the_file) = os.path.split(filename)
for (importData,filter,mime_type) in Plugins._imports: for (importData,mime_filter,mime_type) in Plugins._imports:
if filetype == mime_type or the_file == mime_type: if filetype == mime_type or the_file == mime_type:
choose.destroy() choose.destroy()
importData(self.parent.db,filename) importData(self.parent.db,filename)
@ -308,16 +308,16 @@ class NewNativeDbPrompter:
self.parent.clear_database() self.parent.clear_database()
# Always add automatic (macth all files) filter # Always add automatic (macth all files) filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('Automatic')) mime_filter.set_name(_('Automatic'))
filter.add_pattern('*') mime_filter.add_pattern('*')
choose.add_filter(filter) choose.add_filter(mime_filter)
# Always add native format filter # Always add native format filter
filter = gtk.FileFilter() mime_filter = gtk.FileFilter()
filter.set_name(_('GRAMPS databases')) mime_filter.set_name(_('GRAMPS databases'))
filter.add_mime_type('application/x-gramps') mime_filter.add_mime_type('application/x-gramps')
choose.add_filter(filter) choose.add_filter(mime_filter)
new_filename = Utils.get_new_filename('grdb') new_filename = Utils.get_new_filename('grdb')

View File

@ -133,24 +133,28 @@ class SourceModel(BaseModel):
self.column_author, self.column_author,
self.column_abbrev, self.column_abbrev,
self.column_pubinfo, self.column_pubinfo,
self.column_handle,
] ]
BaseModel.__init__(self,db) BaseModel.__init__(self,db)
def column_title(self,data): def column_title(self,data):
return unicode(data[1])
def column_author(self,data):
return unicode(data[2]) return unicode(data[2])
def column_abbrev(self,data): def column_handle(self,data):
return unicode(data[3])
def column_id(self,data):
return unicode(data[0]) return unicode(data[0])
def column_pubinfo(self,data): def column_author(self,data):
return unicode(data[3])
def column_abbrev(self,data):
return unicode(data[4]) return unicode(data[4])
def column_id(self,data):
return unicode(data[1])
def column_pubinfo(self,data):
return unicode(data[5])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# PlaceModel # PlaceModel
@ -171,48 +175,52 @@ class PlaceModel(BaseModel):
self.column_country, self.column_country,
self.column_longitude, self.column_longitude,
self.column_latitude, self.column_latitude,
self.column_handle,
] ]
BaseModel.__init__(self,db) BaseModel.__init__(self,db)
def column_name(self,data): def column_name(self,data):
return unicode(data[1])
def column_longitude(self,data):
return unicode(data[2]) return unicode(data[2])
def column_latitude(self,data): def column_handle(self,data):
return unicode(data[0])
def column_longitude(self,data):
return unicode(data[3]) return unicode(data[3])
def column_latitude(self,data):
return unicode(data[4])
def column_id(self,data): def column_id(self,data):
return unicode(data[0]) return unicode(data[1])
def column_parish(self,data): def column_parish(self,data):
try: try:
return data[4].get_parish() return data[5].get_parish()
except: except:
return u'' return u''
def column_city(self,data): def column_city(self,data):
try: try:
return data[4].get_city() return data[5].get_city()
except: except:
return u'' return u''
def column_county(self,data): def column_county(self,data):
try: try:
return data[4].get_county() return data[5].get_county()
except: except:
return u'' return u''
def column_state(self,data): def column_state(self,data):
try: try:
return data[4].get_state() return data[5].get_state()
except: except:
return u'' return u''
def column_country(self,data): def column_country(self,data):
try: try:
return data[4].get_country() return data[5].get_country()
except: except:
return u'' return u''
@ -236,13 +244,13 @@ class MediaModel(BaseModel):
BaseModel.__init__(self,db) BaseModel.__init__(self,db)
def column_description(self,data): def column_description(self,data):
return unicode(data[3]) return unicode(data[4])
def column_path(self,data): def column_path(self,data):
return unicode(data[1])
def column_mime(self,data):
return unicode(data[2]) return unicode(data[2])
def column_mime(self,data):
return unicode(data[3])
def column_id(self,data): def column_id(self,data):
return unicode(data[0]) return unicode(data[1])

View File

@ -484,13 +484,13 @@ class EditPerson:
cnum = cnum + 1 cnum = cnum + 1
tree.append_column(column) tree.append_column(column)
def lds_field(self,ord,combo,date,place): def lds_field(self,lds_ord,combo,date,place):
AutoComp.fill_combo(combo,_temple_names) AutoComp.fill_combo(combo,_temple_names)
if not ord.is_empty(): if not lds_ord.is_empty():
stat = ord.get_status() stat = lds_ord.get_status()
date.set_text(ord.get_date()) date.set_text(lds_ord.get_date())
if ord.get_temple() != "": if lds_ord.get_temple() != "":
name = const.lds_temple_to_abrev[ord.get_temple()] name = const.lds_temple_to_abrev[lds_ord.get_temple()]
else: else:
name = "" name = ""
combo.child.set_text(name) combo.child.set_text(name)
@ -499,9 +499,9 @@ class EditPerson:
combo.child.set_text("") combo.child.set_text("")
build_dropdown(place,self.place_list) build_dropdown(place,self.place_list)
if ord and ord.get_place_handle(): if lds_ord and lds_ord.get_place_handle():
ord_place = self.db.get_place_from_handle(ord.get_place_handle()) lds_ord_place = self.db.get_place_from_handle(lds_ord.get_place_handle())
place.set_text(ord_place.get_title()) place.set_text(lds_ord_place.get_title())
return stat return stat
def draw_lds(self): def draw_lds(self):
@ -793,8 +793,8 @@ class EditPerson:
self.ntree.clear() self.ntree.clear()
self.nmap = {} self.nmap = {}
for name in self.nlist: for name in self.nlist:
iter = self.ntree.add([name.get_name(),_(name.get_type())],name) node = self.ntree.add([name.get_name(),_(name.get_type())],name)
self.nmap[str(name)] = iter self.nmap[str(name)] = node
if self.nlist: if self.nlist:
self.ntree.select_row(0) self.ntree.select_row(0)
Utils.bold_label(self.names_label) Utils.bold_label(self.names_label)
@ -807,8 +807,8 @@ class EditPerson:
self.wtree.clear() self.wtree.clear()
self.wmap = {} self.wmap = {}
for url in self.ulist: for url in self.ulist:
iter = self.wtree.add([url.get_path(),url.get_description()],url) node = self.wtree.add([url.get_path(),url.get_description()],url)
self.wmap[str(url)] = iter self.wmap[str(url)] = node
if len(self.ulist) > 0: if len(self.ulist) > 0:
self.web_go.set_sensitive(0) self.web_go.set_sensitive(0)
@ -827,8 +827,8 @@ class EditPerson:
for addr in self.plist: for addr in self.plist:
location = "%s %s %s %s" % (addr.get_street(),addr.get_city(), location = "%s %s %s %s" % (addr.get_street(),addr.get_city(),
addr.get_state(),addr.get_country()) addr.get_state(),addr.get_country())
iter = self.ptree.add([addr.get_date(),location],addr) node = self.ptree.add([addr.get_date(),location],addr)
self.pmap[str(addr)] = iter self.pmap[str(addr)] = node
if self.plist: if self.plist:
self.ptree.select_row(0) self.ptree.select_row(0)
Utils.bold_label(self.addr_label) Utils.bold_label(self.addr_label)
@ -840,8 +840,8 @@ class EditPerson:
self.atree.clear() self.atree.clear()
self.amap = {} self.amap = {}
for attr in self.alist: for attr in self.alist:
iter = self.atree.add([const.display_pattr(attr.get_type()),attr.get_value()],attr) node = self.atree.add([const.display_pattr(attr.get_type()),attr.get_value()],attr)
self.amap[str(attr)] = iter self.amap[str(attr)] = node
if self.alist: if self.alist:
self.atree.select_row(0) self.atree.select_row(0)
Utils.bold_label(self.attr_label) Utils.bold_label(self.attr_label)
@ -885,9 +885,9 @@ class EditPerson:
for event_handle in self.elist: for event_handle in self.elist:
event = self.db.find_event_from_handle(event_handle) event = self.db.find_event_from_handle(event_handle)
pname = place_title(self.db,event) pname = place_title(self.db,event)
iter = self.etree.add([const.display_pevent(event.get_name()),event.get_description(), node = self.etree.add([const.display_pevent(event.get_name()),event.get_description(),
event.get_quote_date(),pname],event) event.get_quote_date(),pname],event)
self.emap[str(event)] = iter self.emap[str(event)] = node
if self.elist: if self.elist:
self.etree.select_row(0) self.etree.select_row(0)
Utils.bold_label(self.events_label) Utils.bold_label(self.events_label)
@ -939,16 +939,16 @@ class EditPerson:
def on_up_clicked(self,obj): def on_up_clicked(self,obj):
sel = obj.get_selection() sel = obj.get_selection()
store,iter = sel.get_selected() store,node = sel.get_selected()
if iter: if node:
row = store.get_path(iter) row = store.get_path(node)
sel.select_path((row[0]-1)) sel.select_path((row[0]-1))
def on_down_clicked(self,obj): def on_down_clicked(self,obj):
sel = obj.get_selection() sel = obj.get_selection()
store,iter = sel.get_selected() store,node = sel.get_selected()
if iter: if node:
row = store.get_path(iter) row = store.get_path(node)
sel.select_path((row[0]+1)) sel.select_path((row[0]+1))
def on_event_add_clicked(self,obj): def on_event_add_clicked(self,obj):
@ -996,33 +996,33 @@ class EditPerson:
def on_aka_delete_clicked(self,obj): def on_aka_delete_clicked(self,obj):
"""Deletes the selected name from the name list""" """Deletes the selected name from the name list"""
store,iter = self.ntree.get_selected() store,node = self.ntree.get_selected()
if iter: if node:
self.nlist.remove(self.ntree.get_object(iter)) self.nlist.remove(self.ntree.get_object(node))
self.lists_changed = 1 self.lists_changed = 1
self.redraw_name_list() self.redraw_name_list()
def on_delete_url_clicked(self,obj): def on_delete_url_clicked(self,obj):
"""Deletes the selected URL from the URL list""" """Deletes the selected URL from the URL list"""
store,iter = self.wtree.get_selected() store,node = self.wtree.get_selected()
if iter: if node:
self.ulist.remove(self.wtree.get_object(iter)) self.ulist.remove(self.wtree.get_object(node))
self.lists_changed = 1 self.lists_changed = 1
self.redraw_url_list() self.redraw_url_list()
def on_delete_attr_clicked(self,obj): def on_delete_attr_clicked(self,obj):
"""Deletes the selected attribute from the attribute list""" """Deletes the selected attribute from the attribute list"""
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
self.alist.remove(self.atree.get_object(iter)) self.alist.remove(self.atree.get_object(node))
self.lists_changed = 1 self.lists_changed = 1
self.redraw_attr_list() self.redraw_attr_list()
def on_delete_addr_clicked(self,obj): def on_delete_addr_clicked(self,obj):
"""Deletes the selected address from the address list""" """Deletes the selected address from the address list"""
store,iter = self.ptree.get_selected() store,node = self.ptree.get_selected()
if iter: if node:
self.plist.remove(self.ptree.get_object(iter)) self.plist.remove(self.ptree.get_object(node))
self.lists_changed = 1 self.lists_changed = 1
self.redraw_addr_list() self.redraw_addr_list()
@ -1207,44 +1207,44 @@ class EditPerson:
def on_update_attr_clicked(self,obj): def on_update_attr_clicked(self,obj):
import AttrEdit import AttrEdit
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
attr = self.atree.get_object(iter) attr = self.atree.get_object(node)
pname = self.person.get_primary_name().get_name() pname = self.person.get_primary_name().get_name()
AttrEdit.AttributeEditor(self,attr,pname,const.personalAttributes, AttrEdit.AttributeEditor(self,attr,pname,const.personalAttributes,
self.attr_edit_callback,self.window) self.attr_edit_callback,self.window)
def on_update_addr_clicked(self,obj): def on_update_addr_clicked(self,obj):
import AddrEdit import AddrEdit
store,iter = self.ptree.get_selected() store,node = self.ptree.get_selected()
if iter: if node:
AddrEdit.AddressEditor(self,self.ptree.get_object(iter), AddrEdit.AddressEditor(self,self.ptree.get_object(node),
self.addr_edit_callback,self.window) self.addr_edit_callback,self.window)
def on_update_url_clicked(self,obj): def on_update_url_clicked(self,obj):
import UrlEdit import UrlEdit
store,iter = self.wtree.get_selected() store,node = self.wtree.get_selected()
if iter: if node:
pname = self.person.get_primary_name().get_name() pname = self.person.get_primary_name().get_name()
url = self.wtree.get_object(iter) url = self.wtree.get_object(node)
UrlEdit.UrlEditor(self,pname,url,self.url_edit_callback,self.window) UrlEdit.UrlEditor(self,pname,url,self.url_edit_callback,self.window)
def on_event_update_clicked(self,obj): def on_event_update_clicked(self,obj):
import EventEdit import EventEdit
store,iter = self.etree.get_selected() store,node = self.etree.get_selected()
if not iter: if not node:
return return
pname = self.person.get_primary_name().get_name() pname = self.person.get_primary_name().get_name()
event = self.etree.get_object(iter) event = self.etree.get_object(node)
EventEdit.EventEditor(self,pname,const.personalEvents, EventEdit.EventEditor(self,pname,const.personalEvents,
const.save_event,event,None,0, const.save_event,event,None,0,
self.event_edit_callback) self.event_edit_callback)
def on_event_select_row(self,obj): def on_event_select_row(self,obj):
store,iter = obj.get_selected() store,node = obj.get_selected()
if iter: if node:
row = store.get_path(iter) row = store.get_path(node)
event = self.db.find_event_from_handle(self.elist[row[0]]) event = self.db.find_event_from_handle(self.elist[row[0]])
self.event_date_field.set_text(event.get_date()) self.event_date_field.set_text(event.get_date())
self.event_place_field.set_text(place_title(self.db,event)) self.event_place_field.set_text(place_title(self.db,event))
@ -1274,9 +1274,9 @@ class EditPerson:
self.event_edit_btn.set_sensitive(0) self.event_edit_btn.set_sensitive(0)
def on_addr_select_row(self,obj): def on_addr_select_row(self,obj):
store,iter = self.ptree.get_selected() store,node = self.ptree.get_selected()
if iter: if node:
addr = self.ptree.get_object(iter) addr = self.ptree.get_object(node)
self.addr_start.set_text(addr.get_date()) self.addr_start.set_text(addr.get_date())
self.addr_street.set_text(addr.get_street()) self.addr_street.set_text(addr.get_street())
self.addr_city.set_text(addr.get_city()) self.addr_city.set_text(addr.get_city())
@ -1309,9 +1309,9 @@ class EditPerson:
self.addr_edit_btn.set_sensitive(0) self.addr_edit_btn.set_sensitive(0)
def on_name_select_row(self,obj): def on_name_select_row(self,obj):
store,iter = self.ntree.get_selected() store,node = self.ntree.get_selected()
if iter: if node:
name = self.ntree.get_object(iter) name = self.ntree.get_object(node)
self.alt_given_field.set_text(name.get_first_name()) self.alt_given_field.set_text(name.get_first_name())
self.alt_title_field.set_text(name.get_title()) self.alt_title_field.set_text(name.get_title())
self.alt_last_field.set_text(name.get_surname()) self.alt_last_field.set_text(name.get_surname())
@ -1342,9 +1342,9 @@ class EditPerson:
self.name_edit_btn.set_sensitive(0) self.name_edit_btn.set_sensitive(0)
def on_web_select_row(self,obj): def on_web_select_row(self,obj):
store,iter = self.wtree.get_selected() store,node = self.wtree.get_selected()
if iter: if node:
url = self.wtree.get_object(iter) url = self.wtree.get_object(node)
path = url.get_path() path = url.get_path()
self.web_url.set_text(path) self.web_url.set_text(path)
self.web_description.set_text(url.get_description()) self.web_description.set_text(url.get_description())
@ -1360,9 +1360,9 @@ class EditPerson:
self.web_edit_btn.set_sensitive(0) self.web_edit_btn.set_sensitive(0)
def on_attr_select_row(self,obj): def on_attr_select_row(self,obj):
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
attr = self.atree.get_object(iter) attr = self.atree.get_object(node)
self.attr_type.set_text(const.display_pattr(attr.get_type())) self.attr_type.set_text(const.display_pattr(attr.get_type()))
self.attr_value.set_text(short(attr.get_value())) self.attr_value.set_text(short(attr.get_value()))
if len(attr.get_source_references()) > 0: if len(attr.get_source_references()) > 0:
@ -1398,9 +1398,9 @@ class EditPerson:
def on_aka_update_clicked(self,obj): def on_aka_update_clicked(self,obj):
import NameEdit import NameEdit
store,iter = self.ntree.get_selected() store,node = self.ntree.get_selected()
if iter: if node:
NameEdit.NameEditor(self,self.ntree.get_object(iter), NameEdit.NameEditor(self,self.ntree.get_object(node),
self.name_edit_callback,self.window) self.name_edit_callback,self.window)
def load_photo(self,photo): def load_photo(self,photo):
@ -1509,11 +1509,11 @@ class EditPerson:
# change in ordering due to the new birth date # change in ordering due to the new birth date
family = self.person.get_main_parents_family_handle() family = self.person.get_main_parents_family_handle()
if (family): if (family):
f = self.db.find_family_no_map(family,trans) f = self.db.find_family_from_handle(family,trans)
new_order = self.reorder_child_list(self.person,f.get_child_handle_list()) new_order = self.reorder_child_list(self.person,f.get_child_handle_list())
f.set_child_handle_list(new_order) f.set_child_handle_list(new_order)
for (family, rel1, rel2) in self.person.get_parent_family_handle_list(): for (family, rel1, rel2) in self.person.get_parent_family_handle_list():
f = self.db.find_family_no_map(family,trans) f = self.db.find_family_from_handle(family,trans)
new_order = self.reorder_child_list(self.person,f.get_child_handle_list()) new_order = self.reorder_child_list(self.person,f.get_child_handle_list())
f.set_child_handle_list(new_order) f.set_child_handle_list(new_order)
@ -1586,16 +1586,16 @@ class EditPerson:
if self.lds_not_loaded == 0: if self.lds_not_loaded == 0:
self.check_lds() self.check_lds()
ord = RelLib.LdsOrd(self.person.get_lds_baptism()) lds_ord = RelLib.LdsOrd(self.person.get_lds_baptism())
if not self.lds_baptism.are_equal(ord): if not self.lds_baptism.are_equal(lds_ord):
self.person.set_lds_baptism(self.lds_baptism) self.person.set_lds_baptism(self.lds_baptism)
ord = RelLib.LdsOrd(self.person.get_lds_endowment()) lds_ord = RelLib.LdsOrd(self.person.get_lds_endowment())
if not self.lds_endowment.are_equal(ord): if not self.lds_endowment.are_equal(lds_ord):
self.person.set_lds_endowment(self.lds_endowment) self.person.set_lds_endowment(self.lds_endowment)
ord = RelLib.LdsOrd(self.person.get_lds_sealing()) lds_ord = RelLib.LdsOrd(self.person.get_lds_sealing())
if not self.lds_sealing.are_equal(ord): if not self.lds_sealing.are_equal(lds_ord):
self.person.set_lds_sealing(self.lds_sealing) self.person.set_lds_sealing(self.lds_sealing)
if self.lists_changed: if self.lists_changed:
@ -1682,10 +1682,10 @@ class EditPerson:
if media_list: if media_list:
ph = media_list[0] ph = media_list[0]
object_handle = ph.get_reference_handle() object_handle = ph.get_reference_handle()
object = self.db.get_object_from_handle(object_handle) obj = self.db.get_object_from_handle(object_handle)
if self.load_obj != object.get_path(): if self.load_obj != obj.get_path():
if object.get_mime_type()[0:5] == "image": if obj.get_mime_type()[0:5] == "image":
self.load_photo(object.get_path()) self.load_photo(obj.get_path())
else: else:
self.load_photo(None) self.load_photo(None)
else: else:
@ -1843,8 +1843,8 @@ def place_title(db,event):
def build_dropdown(entry,strings): def build_dropdown(entry,strings):
store = gtk.ListStore(gobject.TYPE_STRING) store = gtk.ListStore(gobject.TYPE_STRING)
for value in strings: for value in strings:
iter = store.append() node = store.append()
store.set(iter,0,value) store.set(node,0,value)
completion = gtk.EntryCompletion() completion = gtk.EntryCompletion()
completion.set_text_column(0) completion.set_text_column(0)
completion.set_model(store) completion.set_model(store)

View File

@ -82,7 +82,6 @@ class EditPlace:
self.not_loaded = 1 self.not_loaded = 1
self.ref_not_loaded = 1 self.ref_not_loaded = 1
self.lists_changed = 0 self.lists_changed = 0
self.gallery_ok = 0
if place: if place:
self.srcreflist = place.get_source_references() self.srcreflist = place.get_source_references()
else: else:
@ -224,12 +223,12 @@ class EditPlace:
self.top.show() self.top.show()
def on_delete_event(self,obj,b): def on_delete_event(self,obj,b):
self.glry.close(self.gallery_ok) self.glry.close()
self.close_child_windows() self.close_child_windows()
self.remove_itself_from_menu() self.remove_itself_from_menu()
def close(self,obj): def close(self,obj):
self.glry.close(self.gallery_ok) self.glry.close()
self.close_child_windows() self.close_child_windows()
self.remove_itself_from_menu() self.remove_itself_from_menu()
self.top.destroy() self.top.destroy()
@ -367,7 +366,6 @@ class EditPlace:
if format != self.place.get_note_format(): if format != self.place.get_note_format():
self.place.set_note_format(format) self.place.set_note_format(format)
self.gallery_ok = 1
self.update_lists() self.update_lists()
trans = self.db.start_transaction() trans = self.db.start_transaction()
@ -486,7 +484,7 @@ class EditPlace:
if event and event.get_place_handle() == self.place: if event and event.get_place_handle() == self.place:
pevent.append((p,event)) pevent.append((p,event))
for family_handle in self.db.get_family_keys(): for family_handle in self.db.get_family_keys():
f = self.db.find_family_from_handle(family_handle) f = self.db.get_family_from_handle(family_handle)
for event_handle in f.get_event_list(): for event_handle in f.get_event_list():
event = self.db.find_event_from_handle(event_handle) event = self.db.find_event_from_handle(event_handle)
if event and event.get_place_handle() == self.place: if event and event.get_place_handle() == self.place:
@ -570,7 +568,7 @@ class DeletePlaceQuery:
self.db.commit_event(event,trans) self.db.commit_event(event,trans)
for fid in self.db.get_family_keys(): for fid in self.db.get_family_keys():
f = self.db.find_family_from_handle(fid) f = self.db.get_family_from_handle(fid)
for event_handle in f.get_event_list(): for event_handle in f.get_event_list():
event = self.db.find_event_from_handle(event_handle) event = self.db.find_event_from_handle(event_handle)
if event and event.get_place_handle() == self.place.get_handle(): if event and event.get_place_handle() == self.place.get_handle():

View File

@ -191,7 +191,7 @@ class EditSource:
f_attr_list = [] f_attr_list = []
p_list = [] p_list = []
for key in self.db.get_place_handle_keys(): for key in self.db.get_place_handle_keys():
p = self.db.get_place_handle(key) p = self.db.get_place_from_handle(key)
name = p.get_title() name = p.get_title()
for sref in p.get_source_references(): for sref in p.get_source_references():
if sref.get_base_handle() == self.source.get_handle(): if sref.get_base_handle() == self.source.get_handle():
@ -201,7 +201,7 @@ class EditSource:
name = GrampsCfg.get_nameof()(p) name = GrampsCfg.get_nameof()(p)
for event_handle in p.get_event_list() + [p.get_birth_handle(), p.get_death_handle()]: for event_handle in p.get_event_list() + [p.get_birth_handle(), p.get_death_handle()]:
if event_handle: if event_handle:
event = self.db.find_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_handle)
for sref in event.get_source_references(): for sref in event.get_source_references():
if sref.get_base_handle() == self.source.get_handle(): if sref.get_base_handle() == self.source.get_handle():
p_event_list.append((name,event.get_name())) p_event_list.append((name,event.get_name()))
@ -224,7 +224,7 @@ class EditSource:
if sref.get_base_handle() == self.source.get_handle(): if sref.get_base_handle() == self.source.get_handle():
m_list.append(name) m_list.append(name)
for family_handle in self.db.get_family_keys(): for family_handle in self.db.get_family_keys():
family = self.db.find_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
f_id = family.get_father_handle() f_id = family.get_father_handle()
m_id = family.get_mother_handle() m_id = family.get_mother_handle()
if f_id: if f_id:

View File

@ -631,11 +631,7 @@ class FamilyView:
def new_spouse_after_edit(self,epo,trans): def new_spouse_after_edit(self,epo,trans):
if epo.person.get_handle() == "":
self.parent.db.add_person(epo.person,trans) self.parent.db.add_person(epo.person,trans)
else:
self.parent.db.add_person_no_map(epo.person,epo.person.get_handle(),trans)
self.family = self.parent.db.new_family(trans) self.family = self.parent.db.new_family(trans)
self.parent.people_view.add_to_person_list(epo.person,0) self.parent.people_view.add_to_person_list(epo.person,0)
@ -700,11 +696,7 @@ class FamilyView:
def new_child_after_edit(self,epo,trans): def new_child_after_edit(self,epo,trans):
if epo.person.get_handle() == "":
self.parent.db.add_person(epo.person,trans) self.parent.db.add_person(epo.person,trans)
else:
self.parent.db.add_person_no_map(epo.person,epo.person.get_handle(),trans)
self.parent.people_view.add_to_person_list(epo.person,0) self.parent.people_view.add_to_person_list(epo.person,0)
if not self.family: if not self.family:
@ -796,8 +788,9 @@ class FamilyView:
self.parent.db.commit_person(self.person,trans) self.parent.db.commit_person(self.person,trans)
self.parent.db.delete_family(self.family.get_handle(),trans) self.parent.db.delete_family(self.family.get_handle(),trans)
if len(self.person.get_family_handle_list()) > 0: if len(self.person.get_family_handle_list()) > 0:
family_handle = self.person.get_family_handle_list()[0] handle = self.person.get_family_handle_list()[0]
self.load_family(self.parent.db.find_family_from_handle(family_handle)) family = self.parent.db.find_family_from_handle(handle,trans)
self.load_family(family)
else: else:
self.load_family(self.family) self.load_family(self.family)
else: else:
@ -906,7 +899,7 @@ class FamilyView:
for f in splist: for f in splist:
if not f: if not f:
continue continue
fm = self.parent.db.find_family_no_map(f,None) fm = self.parent.db.find_family_from_handle(f,None)
if fm.get_father_handle() == self.person.get_handle(): if fm.get_father_handle() == self.person.get_handle():
sp_id = fm.get_mother_handle() sp_id = fm.get_mother_handle()
@ -937,7 +930,7 @@ class FamilyView:
self.spouse_selection.select_iter(iter) self.spouse_selection.select_iter(iter)
elif len(flist) > 0: elif len(flist) > 0:
fid = splist[0] fid = splist[0]
fam = self.parent.db.find_family_from_handle(fid) fam = self.parent.db.get_family_from_handle(fid)
self.display_marriage(fam) self.display_marriage(fam)
iter = flist[fid] iter = flist[fid]
self.spouse_selection.select_iter(iter) self.spouse_selection.select_iter(iter)
@ -961,7 +954,7 @@ class FamilyView:
list = person.get_parent_family_handle_list() list = person.get_parent_family_handle_list()
for (f,mrel,frel) in list: for (f,mrel,frel) in list:
fam = self.parent.db.find_family_from_handle(f) fam = self.parent.db.get_family_from_handle(f)
father_handle = fam.get_father_handle() father_handle = fam.get_father_handle()
mother_handle = fam.get_mother_handle() mother_handle = fam.get_mother_handle()
f = self.parent.db.get_person_from_handle(father_handle) f = self.parent.db.get_person_from_handle(father_handle)
@ -1006,7 +999,7 @@ class FamilyView:
if not family: if not family:
self.family = None self.family = None
return return
self.family = self.parent.db.find_family_from_handle(family.get_handle()) self.family = self.parent.db.get_family_from_handle(family.get_handle())
if self.family.get_father_handle() == self.person.get_handle(): if self.family.get_father_handle() == self.person.get_handle():
sp_id = self.family.get_mother_handle() sp_id = self.family.get_mother_handle()

File diff suppressed because it is too large Load Diff

View File

@ -239,7 +239,7 @@ class Gallery(ImageSelect):
self.dataobj = dataobj; self.dataobj = dataobj;
self.iconlist = icon_list; self.iconlist = icon_list;
self.root = self.iconlist.root() self.root = self.iconlist.root()
self.old_media_list = [RelLib.MediaRef(ref) for ref in self.dataobj.get_media_list()] self.old_media_list = [RelLib.MediaRef(ref) for ref in dataobj.get_media_list()]
# Local object variables # Local object variables
self.y = 0 self.y = 0

View File

@ -27,7 +27,8 @@ import gtk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ListModel: class ListModel:
def __init__(self,tree,dlist,select_func=None,event_func=None,mode=gtk.SELECTION_SINGLE): def __init__(self,tree,dlist,select_func=None,
event_func=None,mode=gtk.SELECTION_SINGLE):
self.tree = tree self.tree = tree
l = len(dlist) l = len(dlist)
self.mylist = [TYPE_STRING]*l + [TYPE_PYOBJECT] self.mylist = [TYPE_STRING]*l + [TYPE_PYOBJECT]

View File

@ -268,7 +268,7 @@ class PedigreeView:
self.canvas_items.append(self.anchor_txt) self.canvas_items.append(self.anchor_txt)
for family_handle in self.active_person.get_family_handle_list(): for family_handle in self.active_person.get_family_handle_list():
family = self.parent.db.find_family_from_handle(family_handle) family = self.parent.db.get_family_from_handle(family_handle)
if len(family.get_child_handle_list()) > 0: if len(family.get_child_handle_list()) > 0:
button,arrow = self.make_arrow_button(gtk.ARROW_LEFT, button,arrow = self.make_arrow_button(gtk.ARROW_LEFT,
self.on_show_child_menu) self.on_show_child_menu)
@ -490,7 +490,7 @@ class PedigreeView:
mrel = (m != "Birth") mrel = (m != "Birth")
frel = (f != "Birth") frel = (f != "Birth")
family = self.parent.db.find_family_from_handle(family_handle) family = self.parent.db.get_family_from_handle(family_handle)
list[index] = (person,val) list[index] = (person,val)
if family != None: if family != None:
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
@ -573,7 +573,7 @@ class PedigreeView:
fam_list = person.get_family_handle_list() fam_list = person.get_family_handle_list()
no_spouses = 1 no_spouses = 1
for fam_id in fam_list: for fam_id in fam_list:
family = self.parent.db.find_family_from_handle(fam_id) family = self.parent.db.get_family_from_handle(fam_id)
if family.get_father_handle() == person.get_handle(): if family.get_father_handle() == person.get_handle():
sp_id = family.get_mother_handle() sp_id = family.get_mother_handle()
else: else:
@ -604,7 +604,7 @@ class PedigreeView:
pfam_list = person.get_parent_family_handle_list() pfam_list = person.get_parent_family_handle_list()
no_siblings = 1 no_siblings = 1
for (f,mrel,frel) in pfam_list: for (f,mrel,frel) in pfam_list:
fam = self.parent.db.find_family_from_handle(f) fam = self.parent.db.get_family_from_handle(f)
sib_list = fam.get_child_handle_list() sib_list = fam.get_child_handle_list()
for sib_id in sib_list: for sib_id in sib_list:
if sib_id == person.get_handle(): if sib_id == person.get_handle():
@ -774,7 +774,7 @@ def find_children(db,p):
""" """
childlist = [] childlist = []
for family_handle in p.get_family_handle_list(): for family_handle in p.get_family_handle_list():
family = db.find_family_from_handle(family_handle) family = db.get_family_from_handle(family_handle)
for child_handle in family.get_child_handle_list(): for child_handle in family.get_child_handle_list():
childlist.append(child_handle) childlist.append(child_handle)
return childlist return childlist
@ -790,7 +790,7 @@ def find_parents(db,p):
""" """
parentlist = [] parentlist = []
for (f,mrel,frel) in p.get_parent_family_handle_list(): for (f,mrel,frel) in p.get_parent_family_handle_list():
family = db.find_family_from_handle(f) family = db.get_family_from_handle(f)
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if father_handle not in parentlist: if father_handle not in parentlist:

View File

@ -60,6 +60,8 @@ column_names = [
_('Latitude'), _('Latitude'),
] ]
_HANDLE_COL = len(column_names)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# PlaceView class # PlaceView class
@ -70,7 +72,6 @@ class PlaceView:
def __init__(self,parent,db,glade,update): def __init__(self,parent,db,glade,update):
self.parent = parent self.parent = parent
self.glade = glade self.glade = glade
self.db = db
self.list = glade.get_widget("place_list") self.list = glade.get_widget("place_list")
self.list.connect('button-press-event',self.button_press) self.list.connect('button-press-event',self.button_press)
self.list.connect('key-press-event',self.key_press) self.list.connect('key-press-event',self.key_press)
@ -79,7 +80,7 @@ class PlaceView:
self.renderer = gtk.CellRendererText() self.renderer = gtk.CellRendererText()
self.model = gtk.TreeModelSort(DisplayModels.PlaceModel(self.db)) self.model = gtk.TreeModelSort(DisplayModels.PlaceModel(self.parent.db))
self.list.set_model(self.model) self.list.set_model(self.model)
self.topWindow = self.glade.get_widget("gramps") self.topWindow = self.glade.get_widget("gramps")
@ -176,7 +177,7 @@ class PlaceView:
EditPlace.EditPlace(self.parent,RelLib.Place(),self.new_place_after_edit) EditPlace.EditPlace(self.parent,RelLib.Place(),self.new_place_after_edit)
def new_place_after_edit(self,place): def new_place_after_edit(self,place):
self.db.add_place(place) self.parent.db.add_place(place)
def update_display(self,place): def update_display(self,place):
self.build_tree() self.build_tree()
@ -185,15 +186,15 @@ class PlaceView:
mlist = [] mlist = []
self.selection.selected_foreach(self.blist,mlist) self.selection.selected_foreach(self.blist,mlist)
trans = self.db.start_transaction() trans = self.parent.db.start_transaction()
for place in mlist: for place in mlist:
used = 0 used = 0
for key in self.db.get_person_keys(): for key in self.parent.db.get_person_keys():
p = self.db.get_person_from_handle(key) p = self.parent.db.get_person_from_handle(key)
event_list = [] event_list = []
for e in [p.get_birth_handle(),p.get_death_handle()] + p.get_event_list(): for e in [p.get_birth_handle(),p.get_death_handle()] + p.get_event_list():
event = self.db.find_event_from_handle(e) event = self.parent.db.find_event_from_handle(e)
if event: if event:
event_list.append(event) event_list.append(event)
if p.get_lds_baptism(): if p.get_lds_baptism():
@ -206,11 +207,11 @@ class PlaceView:
if event.get_place_handle() == place.get_handle(): if event.get_place_handle() == place.get_handle():
used = 1 used = 1
for fid in self.db.get_family_keys(): for fid in self.parent.db.get_family_keys():
f = self.db.find_family_from_handle(fid) f = self.parent.db.find_family_from_handle(fid)
event_list = [] event_list = []
for e in f.get_event_list(): for e in f.get_event_list():
event = self.db.find_event_from_handle(e) event = self.parent.db.find_event_from_handle(e)
if event: if event:
event_list.append(event) event_list.append(event)
if f.get_lds_sealing(): if f.get_lds_sealing():
@ -220,7 +221,7 @@ class PlaceView:
used = 1 used = 1
if used == 1: if used == 1:
ans = EditPlace.DeletePlaceQuery(place,self.db,self.update_display) ans = EditPlace.DeletePlaceQuery(place,self.parent.db,self.update_display)
QuestionDialog(_('Delete %s?') % place.get_title(), QuestionDialog(_('Delete %s?') % place.get_title(),
_('This place is currently being used by at least one ' _('This place is currently being used by at least one '
'record in the database. Deleting it will remove it ' 'record in the database. Deleting it will remove it '
@ -229,9 +230,9 @@ class PlaceView:
_('_Delete Place'), _('_Delete Place'),
ans.query_response) ans.query_response)
else: else:
trans = self.db.start_transaction() trans = self.parent.db.start_transaction()
self.db.remove_place(place.get_handle(),trans) self.parent.db.remove_place(place.get_handle(),trans)
self.db.add_transaction(trans,_("Delete Place (%s)") % place.title()) self.parent.db.add_transaction(trans,_("Delete Place (%s)") % place.title())
self.build_tree() self.build_tree()
def on_edit_clicked(self,obj): def on_edit_clicked(self,obj):
@ -243,7 +244,7 @@ class PlaceView:
EditPlace.EditPlace(self.parent, place, self.update_display) EditPlace.EditPlace(self.parent, place, self.update_display)
def blist(self,store,path,iter,list): def blist(self,store,path,iter,list):
id = self.db.get_place_from_handle(store.get_value(iter,1)) id = self.parent.db.get_place_from_handle(store.get_value(iter,_HANDLE_COL))
list.append(id) list.append(id)
def merge(self): def merge(self):
@ -258,5 +259,5 @@ class PlaceView:
ErrorDialog(msg,msg2) ErrorDialog(msg,msg2)
else: else:
import MergeData import MergeData
MergeData.MergePlaces(self.db,mlist[0],mlist[1],self.build_tree) MergeData.MergePlaces(self.parent.db,mlist[0],mlist[1],self.build_tree)

View File

@ -222,6 +222,9 @@ class GedcomParser:
self.is_ftw = 0 self.is_ftw = 0
self.idswap = {} self.idswap = {}
self.gid2id = {} self.gid2id = {}
self.sid2id = {}
self.lid2id = {}
self.fid2id = {}
self.f = open(file,"rU") self.f = open(file,"rU")
self.filename = file self.filename = file
@ -442,7 +445,7 @@ class GedcomParser:
self.ignore_sub_junk(1) self.ignore_sub_junk(1)
def parse_source(self,name,level): def parse_source(self,name,level):
self.source = self.db.find_source(name,self.smap, self.trans) self.source = self.find_or_create_source(name[1:-1])
note = "" note = ""
while 1: while 1:
@ -495,7 +498,7 @@ class GedcomParser:
if self.fam_count % UPDATE == 0 and self.window: if self.fam_count % UPDATE == 0 and self.window:
self.update(self.families_obj,str(self.fam_count)) self.update(self.families_obj,str(self.fam_count))
self.fam_count = self.fam_count + 1 self.fam_count = self.fam_count + 1
self.family = self.db.find_family_with_map(matches[1],self.fmap, self.trans) self.family = self.find_or_create_family(matches[1])
self.parse_family() self.parse_family()
if self.addr != None: if self.addr != None:
father = self.family.get_father_handle() father = self.family.get_father_handle()
@ -563,10 +566,51 @@ class GedcomParser:
intid = Utils.create_id() intid = Utils.create_id()
person.set_handle(intid) person.set_handle(intid)
person.set_gramps_id(gramps_id) person.set_gramps_id(gramps_id)
self.db.add_person_as(person,self.trans) self.db.add_person(person,self.trans)
self.gid2id[gramps_id] = intid self.gid2id[gramps_id] = intid
return person return person
def find_or_create_source(self,gramps_id):
source = RelLib.Source()
intid = self.sid2id.get(gramps_id)
if self.db.source_map.has_key(intid):
source.unserialize(self.db.source_map.get(intid))
else:
intid = Utils.create_id()
source.set_handle(intid)
source.set_gramps_id(gramps_id)
self.db.add_source(source,self.trans)
self.sid2id[gramps_id] = intid
return source
def find_or_create_place(self,gramps_id):
place = RelLib.Place()
intid = self.lid2id.get(gramps_id)
if self.db.place_map.has_key(intid):
place.unserialize(self.db.place_map.get(intid))
else:
intid = Utils.create_id()
place.set_handle(intid)
place.set_title(gramps_id)
place.set_gramps_id(self.db.find_next_place_gramps_id())
print place.get_gramps_id()
self.db.add_place(place,self.trans)
self.lid2id[gramps_id] = intid
return place
def find_or_create_family(self,gramps_id):
family = RelLib.Family()
intid = self.fid2id.get(gramps_id)
if self.db.family_map.has_key(intid):
family.unserialize(self.db.family_map.get(intid))
else:
intid = Utils.create_id()
family.set_handle(intid)
family.set_gramps_id(gramps_id)
self.db.add_family(family,self.trans)
self.fid2id[gramps_id] = intid
return family
def parse_cause(self,event,level): def parse_cause(self,event,level):
while 1: while 1:
matches = self.get_next() matches = self.get_next()
@ -793,7 +837,7 @@ class GedcomParser:
self.person.set_lds_sealing(ord) self.person.set_lds_sealing(ord)
self.parse_ord(ord,2) self.parse_ord(ord,2)
elif matches[1] == "FAMS": elif matches[1] == "FAMS":
family = self.db.find_family_with_map(matches[2],self.fmap, self.trans) family = self.find_or_create_family(matches[2])
self.person.add_family_handle(family.get_handle()) self.person.add_family_handle(family.get_handle())
if note == "": if note == "":
note = self.parse_optional_note(2) note = self.parse_optional_note(2)
@ -802,7 +846,7 @@ class GedcomParser:
self.db.commit_family(family, self.trans) self.db.commit_family(family, self.trans)
elif matches[1] == "FAMC": elif matches[1] == "FAMC":
type,note = self.parse_famc_type(2) type,note = self.parse_famc_type(2)
family = self.db.find_family_with_map(matches[2],self.fmap, self.trans) family = self.find_or_create_family(matches[2])
for f in self.person.get_parent_family_handle_list(): for f in self.person.get_parent_family_handle_list():
if f[0] == family.get_handle(): if f[0] == family.get_handle():
@ -1115,18 +1159,13 @@ class GedcomParser:
elif matches[1] == "DATE": elif matches[1] == "DATE":
ord.set_date_object(self.extract_date(matches[2])) ord.set_date_object(self.extract_date(matches[2]))
elif matches[1] == "FAMC": elif matches[1] == "FAMC":
ord.set_family_handle(self.db.find_family_with_map(matches[2],self.fmap,self.trans)) ord.set_family_handle(self.find_or_create_family(matches[2]))
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
try: try:
val = matches[2] val = matches[2]
if self.placemap.has_key(val): place = self.find_or_create_place(matches[2])
place_handle = self.placemap[val]
else:
place = RelLib.Place()
place.set_title(matches[2]) place.set_title(matches[2])
self.db.add_place(place, self.trans)
place_handle = place.get_handle() place_handle = place.get_handle()
self.placemap[val] = place_handle
ord.set_place_handle(place_handle) ord.set_place_handle(place_handle)
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
except NameError: except NameError:
@ -1172,14 +1211,9 @@ class GedcomParser:
event.set_description(val) event.set_description(val)
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
else: else:
if self.placemap.has_key(val): place = self.find_or_create_place(val)
place_handle = self.placemap[val]
else:
place = RelLib.Place()
place.set_title(matches[2])
self.db.add_place(place, self.trans)
place_handle = place.get_handle() place_handle = place.get_handle()
self.placemap[val] = place_handle place.set_title(matches[2])
event.set_place_handle(place_handle) event.set_place_handle(place_handle)
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == "CAUS": elif matches[1] == "CAUS":
@ -1221,21 +1255,16 @@ class GedcomParser:
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
event.add_source_reference(self.handle_source(matches,level+1)) event.add_source_reference(self.handle_source(matches,level+1))
elif matches[1] == "FAMC": elif matches[1] == "FAMC":
family = self.db.find_family_with_map(matches[2],self.fmap,self.trans) family = self.find_or_create_family(matches[2])
mrel,frel = self.parse_adopt_famc(level+1); mrel,frel = self.parse_adopt_famc(level+1);
if self.person.get_main_parents_family_handle() == family.get_handle(): if self.person.get_main_parents_family_handle() == family.get_handle():
self.person.set_main_parent_family_handle(None) self.person.set_main_parent_family_handle(None)
self.person.add_parent_family_handle(family.get_handle(),mrel,frel) self.person.add_parent_family_handle(family.get_handle(),mrel,frel)
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
val = matches[2] val = matches[2]
if self.placemap.has_key(val): place = self.find_or_create_place(val)
place_handle = self.placemap[val]
else:
place = RelLib.Place()
place.set_title(matches[2])
self.db.add_place(place, self.trans)
place_handle = place.get_handle() place_handle = place.get_handle()
self.placemap[val] = place_handle place.set_title(matches[2])
event.set_place_handle(place_handle) event.set_place_handle(place_handle)
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == "TYPE": elif matches[1] == "TYPE":
@ -1356,14 +1385,9 @@ class GedcomParser:
event.add_source_reference(self.handle_source(matches,level+1)) event.add_source_reference(self.handle_source(matches,level+1))
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
val = matches[2] val = matches[2]
if self.placemap.has_key(val): place = self.find_or_create_place(val)
place_handle = self.placemap[val]
else:
place = RelLib.Place()
place.set_title(matches[2])
self.db.add_place(place, self.trans)
place_handle = place.get_handle() place_handle = place.get_handle()
self.placemap[val] = place_handle place.set_title(matches[2])
event.set_place_handle(place_handle) event.set_place_handle(place_handle)
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == 'OFFI': elif matches[1] == 'OFFI':
@ -1722,13 +1746,13 @@ class GedcomParser:
if matches[2] and matches[2][0] != "@": if matches[2] and matches[2][0] != "@":
self.localref = self.localref + 1 self.localref = self.localref + 1
ref = "gsr%d" % self.localref ref = "gsr%d" % self.localref
s = self.db.find_source(ref,self.smap, self.trans) s = self.find_or_create_source(ref)
source_ref.set_base_handle(s.get_handle()) source_ref.set_base_handle(s.get_handle())
s.set_title('Imported Source #%d' % self.localref) s.set_title('Imported Source #%d' % self.localref)
s.set_note(matches[2] + self.parse_continue_data(level)) s.set_note(matches[2] + self.parse_continue_data(level))
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
else: else:
source_ref.set_base_handle(self.db.find_source(matches[2],self.smap,self.trans).get_handle()) source_ref.set_base_handle(self.find_or_create_source(matches[2][1:-1]))
self.parse_source_reference(source_ref,level) self.parse_source_reference(source_ref,level)
return source_ref return source_ref
@ -1761,7 +1785,7 @@ class GedcomParser:
self.db.remove_person_handle(pid,self.trans) self.db.remove_person_handle(pid,self.trans)
person.set_handle(new_key) person.set_handle(new_key)
person.set_gramps_id(new_key) person.set_gramps_id(new_key)
self.db.add_person_as(person,self.trans) self.db.add_person(person,self.trans)
# give up trying to use the refn as a key # give up trying to use the refn as a key
else: else:
pass pass

View File

@ -422,7 +422,7 @@ class GrampsParser:
intid = Utils.create_id() intid = Utils.create_id()
person.set_handle(intid) person.set_handle(intid)
person.set_gramps_id(gramps_id) person.set_gramps_id(gramps_id)
self.db.add_person_as(person,self.trans) self.db.add_person(person,self.trans)
self.gid2id[gramps_id] = intid self.gid2id[gramps_id] = intid
return person return person
@ -478,15 +478,13 @@ class GrampsParser:
def start_sealed_to(self,attrs): def start_sealed_to(self,attrs):
id = self.map_gid(attrs['ref']) id = self.map_gid(attrs['ref'])
self.ord.set_family_handle(self.db.find_family_no_map(id,self.trans)) self.ord.set_family_handle(self.db.find_family_from_handle(id,self.trans))
def start_place(self,attrs): def start_place(self,attrs):
self.placeobj = self.db.find_place_no_conflicts(attrs['ref'], self.placeobj = self.db.find_place_from_handle(attrs['ref'],self.trans)
self.lmap, self.trans)
def start_placeobj(self,attrs): def start_placeobj(self,attrs):
self.placeobj = self.db.find_place_no_conflicts(attrs['id'], self.placeobj = self.db.find_place_from_handle(attrs['id'],self.trans)
self.lmap,self.trans)
title = attrs['title'] title = attrs['title']
if title == "": if title == "":
title = attrs['id'] title = attrs['id']
@ -637,18 +635,18 @@ class GrampsParser:
if self.callback != None and self.count % self.increment == 0: if self.callback != None and self.count % self.increment == 0:
self.callback(float(self.count)/float(self.entries)) self.callback(float(self.count)/float(self.entries))
self.count = self.count + 1 self.count = self.count + 1
self.family = self.db.find_family_no_conflicts(attrs["id"], self.family = self.db.find_family_from_handle(attrs["id"],self.trans)
self.fmap,self.trans)
if attrs.has_key("type"): if attrs.has_key("type"):
self.family.set_relationship(_FAMILY_TRANS.get(attrs["type"],const.FAMILY_UNKNOWN)) self.family.set_relationship(_FAMILY_TRANS.get(attrs["type"],
const.FAMILY_UNKNOWN))
if attrs.has_key("complete"): if attrs.has_key("complete"):
self.family.set_complete(int(attrs['complete'])) self.family.set_complete(int(attrs['complete']))
else: else:
self.family.set_complete(0) self.family.set_complete(0)
def start_childof(self,attrs): def start_childof(self,attrs):
family = self.db.find_family_no_conflicts(attrs["ref"], family = self.db.find_family_from_handle(attrs["ref"],self.trans)
self.fmap,self.trans)
if attrs.has_key("mrel"): if attrs.has_key("mrel"):
mrel = attrs["mrel"] mrel = attrs["mrel"]
else: else:
@ -686,8 +684,7 @@ class GrampsParser:
def start_sourceref(self,attrs): def start_sourceref(self,attrs):
self.source_ref = RelLib.SourceRef() self.source_ref = RelLib.SourceRef()
source = self.db.find_source_no_conflicts(attrs["ref"], source = self.db.find_source_from_handle(attrs["ref"],self.trans)
self.smap,self.trans)
if attrs.has_key("conf"): if attrs.has_key("conf"):
self.source_ref.confidence = int(attrs["conf"]) self.source_ref.confidence = int(attrs["conf"])
else: else:
@ -717,13 +714,13 @@ class GrampsParser:
self.person.add_source_reference(self.source_ref) self.person.add_source_reference(self.source_ref)
def start_source(self,attrs): def start_source(self,attrs):
self.source = self.db.find_source_no_conflicts(attrs["id"], self.source = self.db.find_source_from_handle(attrs["id"],self.trans)
self.smap,self.trans)
def start_objref(self,attrs): def start_objref(self,attrs):
self.objref = RelLib.MediaRef() self.objref = RelLib.MediaRef()
id = self.db.find_object_no_conflicts(attrs['ref'], obj = self.db.find_object_from_handle(attrs['ref'],self.trans)
self.media_file_map,self.trans).get_handle() id = obj.get_handle()
self.objref.set_reference_handle(id) self.objref.set_reference_handle(id)
if attrs.has_key('priv'): if attrs.has_key('priv'):
self.objref.set_privacy(int(attrs['priv'])) self.objref.set_privacy(int(attrs['priv']))
@ -739,9 +736,7 @@ class GrampsParser:
self.placeobj.add_media_reference(self.objref) self.placeobj.add_media_reference(self.objref)
def start_object(self,attrs): def start_object(self,attrs):
self.object = self.db.find_object_no_conflicts(attrs['id'], self.object = self.db.find_object_from_handle(attrs['id'],self.trans)
self.media_file_map,
self.trans)
self.object.set_mime_type(attrs['mime']) self.object.set_mime_type(attrs['mime'])
self.object.set_description(attrs['description']) self.object.set_description(attrs['description'])
src = attrs["src"] src = attrs["src"]

View File

@ -302,6 +302,7 @@ class Place(SourceNote):
for loc in source.alt_loc: for loc in source.alt_loc:
self.alt_loc = Location(loc) self.alt_loc = Location(loc)
self.handle = source.handle self.handle = source.handle
self.gramps_id = source.gramps_id
self.urls = [] self.urls = []
for u in source.urls: for u in source.urls:
self.urls.append(Url(u)) self.urls.append(Url(u))
@ -315,15 +316,17 @@ class Place(SourceNote):
self.main_loc = None self.main_loc = None
self.alt_loc = [] self.alt_loc = []
self.handle = "" self.handle = ""
self.gramps_id = ""
self.urls = [] self.urls = []
self.media_list = [] self.media_list = []
def serialize(self): def serialize(self):
return (self.handle, self.title, self.long, self.lat, self.main_loc, return (self.handle, self.gramps_id, self.title, self.long, self.lat,
self.alt_loc, self.urls, self.media_list, self.source_list, self.note) self.main_loc, self.alt_loc, self.urls, self.media_list,
self.source_list, self.note)
def unserialize(self,data): def unserialize(self,data):
(self.handle, self.title, self.long, self.lat, self.main_loc, (self.handle, self.gramps_id, self.title, self.long, self.lat, self.main_loc,
self.alt_loc, self.urls, self.media_list, self.source_list, self.alt_loc, self.urls, self.media_list, self.source_list,
self.note) = data self.note) = data
@ -347,6 +350,14 @@ class Place(SourceNote):
"""Returns the database handle for the place object""" """Returns the database handle for the place object"""
return self.handle return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_title(self,name): def set_title(self,name):
"""Sets the title of the place object""" """Sets the title of the place object"""
self.title = name self.title = name
@ -415,13 +426,14 @@ class Place(SourceNote):
case city, upper case county, upper case state, upper case country""" case city, upper case county, upper case state, upper case country"""
if self.main_loc: if self.main_loc:
return [self.title,self.handle,self.main_loc.parish,self.main_loc.city, return [self.title,self.gramps_id,self.main_loc.parish,self.main_loc.city,
self.main_loc.county,self.main_loc.state,self.main_loc.country, self.main_loc.county,self.main_loc.state,self.main_loc.country,
self.title.upper(), self.main_loc.parish.upper(), self.title.upper(), self.main_loc.parish.upper(),
self.main_loc.city.upper(), self.main_loc.county.upper(), self.main_loc.city.upper(), self.main_loc.county.upper(),
self.main_loc.state.upper(), self.main_loc.country.upper()] self.main_loc.state.upper(), self.main_loc.country.upper()]
else: else:
return [self.title,self.handle,'','','','','',self.title.upper(), '','','','',''] return [self.title,self.gramps_id,'','','','','',
self.title.upper(), '','','','','']
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -636,23 +648,25 @@ class MediaObject(SourceNote):
self.mime = source.mime self.mime = source.mime
self.desc = source.desc self.desc = source.desc
self.handle = source.handle self.handle = source.handle
self.gramps_id = source.gramps_id
self.thumb = source.thumb self.thumb = source.thumb
for attr in source.attrlist: for attr in source.attrlist:
self.attrlist.append(Attribute(attr)) self.attrlist.append(Attribute(attr))
else: else:
self.handle = "" self.handle = ""
self.gramps_id = ""
self.path = "" self.path = ""
self.mime = "" self.mime = ""
self.desc = "" self.desc = ""
self.thumb = None self.thumb = None
def serialize(self): def serialize(self):
return (self.handle, self.path, self.mime, self.desc, self.attrlist, return (self.handle, self.gramps_id, self.path, self.mime,
self.source_list, self.note) self.desc, self.attrlist, self.source_list, self.note)
def unserialize(self,data): def unserialize(self,data):
(self.handle, self.path, self.mime, self.desc, self.attrlist, (self.handle, self.gramps_id, self.path, self.mime, self.desc,
self.source_list, self.note) = data self.attrlist, self.source_list, self.note) = data
def set_handle(self,handle): def set_handle(self,handle):
"""Sets the database handle for the place object""" """Sets the database handle for the place object"""
@ -662,6 +676,14 @@ class MediaObject(SourceNote):
"""Returns the database handle for the place object""" """Returns the database handle for the place object"""
return self.handle return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_mime_type(self,type): def set_mime_type(self,type):
self.mime = type self.mime = type
@ -1267,6 +1289,14 @@ class Person(SourceNote):
"""returns the database handle for the Person""" """returns the database handle for the Person"""
return self.handle return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_nick_name(self,name): def set_nick_name(self,name):
"""sets the nickname for the Person""" """sets the nickname for the Person"""
self.nickname = name self.nickname = name
@ -1617,6 +1647,7 @@ class Event(DataObj):
self.name = source.name self.name = source.name
self.cause = source.cause self.cause = source.cause
self.handle = source.handle self.handle = source.handle
self.gramps_id = source.gramps_id
self.media_list = [MediaRef(media_id) for media_id in source.media_list] self.media_list = [MediaRef(media_id) for media_id in source.media_list]
try: try:
if source.witness: if source.witness:
@ -1632,7 +1663,8 @@ class Event(DataObj):
self.name = "" self.name = ""
self.cause = "" self.cause = ""
self.witness = None self.witness = None
self.handle = None self.handle = ""
self.gramps_id = ""
self.media_list = [] self.media_list = []
def clone(self,source): def clone(self,source):
@ -1642,6 +1674,7 @@ class Event(DataObj):
self.name = source.name self.name = source.name
self.cause = source.cause self.cause = source.cause
self.handle = source.handle self.handle = source.handle
self.gramps_id = source.gramps_id
self.private = source.private self.private = source.private
self.source_list = source.source_list[:] self.source_list = source.source_list[:]
self.note = source.note self.note = source.note
@ -1655,12 +1688,12 @@ class Event(DataObj):
self.witness = None self.witness = None
def serialize(self): def serialize(self):
return (self.handle, self.name, self.date, self.description, return (self.handle, self.gramps_id, self.name, self.date, self.description,
self.place, self.cause, self.private, self.source_list, self.place, self.cause, self.private, self.source_list,
self.note, self.witness, self.media_list) self.note, self.witness, self.media_list)
def unserialize(self,data): def unserialize(self,data):
(self.handle, self.name, self.date, self.description, (self.handle, self.gramps_id, self.name, self.date, self.description,
self.place, self.cause, self.private, self.source_list, self.place, self.cause, self.private, self.source_list,
self.note, self.witness, self.media_list) = data self.note, self.witness, self.media_list) = data
@ -1684,6 +1717,14 @@ class Event(DataObj):
"""Returns the database handle for the place object""" """Returns the database handle for the place object"""
return self.handle return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def get_witness_list(self): def get_witness_list(self):
return self.witness return self.witness
@ -1865,6 +1906,7 @@ class Family(SourceNote):
self.type = const.FAMILY_MARRIED self.type = const.FAMILY_MARRIED
self.event_list = [] self.event_list = []
self.handle = "" self.handle = ""
self.gramps_id = ""
self.media_list = [] self.media_list = []
self.attribute_list = [] self.attribute_list = []
self.lds_seal = None self.lds_seal = None
@ -1872,20 +1914,16 @@ class Family(SourceNote):
def serialize(self): def serialize(self):
return (self.handle, self.father_handle, self.mother_handle, return (self.handle, self.gramps_id, self.father_handle, self.mother_handle,
self.child_list, self.type, self.event_list, self.child_list, self.type, self.event_list,
self.media_list, self.attribute_list, self.lds_seal, self.media_list, self.attribute_list, self.lds_seal,
self.complete, self.complete, self.source_list, self.note)
self.source_list,
self.note)
def unserialize(self, data): def unserialize(self, data):
(self.handle, self.father_handle, self.mother_handle, (self.handle, self.gramps_id, self.father_handle, self.mother_handle,
self.child_list, self.type, self.event_list, self.child_list, self.type, self.event_list,
self.media_list, self.attribute_list, self.lds_seal, self.media_list, self.attribute_list, self.lds_seal,
self.complete, self.complete, self.source_list, self.note) = data
self.source_list,
self.note) = data
def set_complete(self,val): def set_complete(self,val):
self.complete = val self.complete = val
@ -1924,6 +1962,14 @@ class Family(SourceNote):
"""returns the database handle for the Family""" """returns the database handle for the Family"""
return unicode(self.handle) return unicode(self.handle)
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def set_relationship(self,type): def set_relationship(self,type):
"""assigns a string indicating the relationship between the """assigns a string indicating the relationship between the
father and the mother""" father and the mother"""
@ -2049,18 +2095,19 @@ class Source:
self.note = Note() self.note = Note()
self.media_list = [] self.media_list = []
self.handle = "" self.handle = ""
self.gramps_id = ""
self.abbrev = "" self.abbrev = ""
def serialize(self): def serialize(self):
return (self.handle,self.title,self.author,self.pubinfo, return (self.handle, self.gramps_id, self.title, self.author,
self.note,self.media_list,self.abbrev) self.pubinfo, self.note, self.media_list, self.abbrev)
def unserialize(self,data): def unserialize(self,data):
(self.handle,self.title,self.author,self.pubinfo, (self.handle, self.gramps_id, self.title, self.author,
self.note,self.media_list,self.abbrev) = data self.pubinfo, self.note, self.media_list, self.abbrev) = data
def get_display_info(self): def get_display_info(self):
return [self.title,self.handle,self.author,self.title.upper(),self.author.upper()] return [self.title,self.gramps_id,self.author,self.title.upper(),self.author.upper()]
def set_handle(self,handle): def set_handle(self,handle):
"""sets the gramps' ID for the Source instance""" """sets the gramps' ID for the Source instance"""
@ -2070,6 +2117,14 @@ class Source:
"""returns the gramps' ID of the Source instance""" """returns the gramps' ID of the Source instance"""
return self.handle return self.handle
def set_gramps_id(self,gramps_id):
"""Sets the GRAMPS ID for the place object"""
self.gramps_id = gramps_id
def get_gramps_id(self):
"""Returns the GRAMPS ID for the place object"""
return self.gramps_id
def add_media_reference(self,media_id): def add_media_reference(self,media_id):
"""Adds a MediaObject object to the Source instance's image list""" """Adds a MediaObject object to the Source instance's image list"""
self.media_list.append(media_id) self.media_list.append(media_id)

View File

@ -186,7 +186,7 @@ class SelectChild:
slist = {} slist = {}
for f in self.person.get_parent_family_handle_list(): for f in self.person.get_parent_family_handle_list():
if f: if f:
family = self.db.find_family_no_map(f[0]) family = self.db.find_family_from_handle(f[0])
if family.get_father_handle(): if family.get_father_handle():
slist[family.get_father_handle()] = 1 slist[family.get_father_handle()] = 1
elif family.get_mother_handle(): elif family.get_mother_handle():

View File

@ -42,6 +42,8 @@ import const
from QuestionDialog import QuestionDialog from QuestionDialog import QuestionDialog
_HANDLE_COL = 5
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# internationalization # internationalization
@ -131,7 +133,7 @@ class SourceView:
def button_press(self,obj,event): def button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
store,iter = self.selection.get_selected() store,iter = self.selection.get_selected()
id = store.get_value(iter,1) id = store.get_value(iter,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(id) source = self.parent.db.get_source_from_handle(id)
EditSource.EditSource(source,self.parent.db,self.parent, EditSource.EditSource(source,self.parent.db,self.parent,
self.topWindow,self.update_display) self.topWindow,self.update_display)
@ -182,7 +184,7 @@ class SourceView:
if not iter: if not iter:
return return
id = store.get_value(iter,1) id = store.get_value(iter,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(id) source = self.parent.db.get_source_from_handle(id)
if self.is_used(source): if self.is_used(source):
@ -249,7 +251,7 @@ class SourceView:
def on_edit_clicked(self,obj): def on_edit_clicked(self,obj):
list_store, iter = self.selection.get_selected() list_store, iter = self.selection.get_selected()
if iter: if iter:
id = list_store.get_value(iter,1) id = list_store.get_value(iter,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(id) source = self.parent.db.get_source_from_handle(id)
EditSource.EditSource(source, self.parent.db, self.parent, EditSource.EditSource(source, self.parent.db, self.parent,
self.topWindow, self.update_display) self.topWindow, self.update_display)

View File

@ -138,7 +138,7 @@
<applyto>/apps/gramps/preferences/oprefix</applyto> <applyto>/apps/gramps/preferences/oprefix</applyto>
<owner>gramps</owner> <owner>gramps</owner>
<type>string</type> <type>string</type>
<default>F%04d</default> <default>O%04d</default>
<locale name="C"> <locale name="C">
<short>Default media object GRAMPS ID pattern</short> <short>Default media object GRAMPS ID pattern</short>
<long>The new GRAMPS IDs for the media object are generated <long>The new GRAMPS IDs for the media object are generated
@ -151,7 +151,7 @@
<applyto>/apps/gramps/preferences/pprefix</applyto> <applyto>/apps/gramps/preferences/pprefix</applyto>
<owner>gramps</owner> <owner>gramps</owner>
<type>string</type> <type>string</type>
<default>F%04d</default> <default>P%04d</default>
<locale name="C"> <locale name="C">
<short>Default place GRAMPS ID pattern</short> <short>Default place GRAMPS ID pattern</short>
<long>The new GRAMPS IDs for the place are generated according <long>The new GRAMPS IDs for the place are generated according
@ -164,7 +164,7 @@
<applyto>/apps/gramps/preferences/sprefix</applyto> <applyto>/apps/gramps/preferences/sprefix</applyto>
<owner>gramps</owner> <owner>gramps</owner>
<type>string</type> <type>string</type>
<default>F%04d</default> <default>S%04d</default>
<locale name="C"> <locale name="C">
<short>Default source GRAMPS ID pattern</short> <short>Default source GRAMPS ID pattern</short>
<long>The new GRAMPS IDs for the source are generated according <long>The new GRAMPS IDs for the source are generated according

View File

@ -1427,10 +1427,7 @@ class Gramps:
def new_after_edit(self,epo,trans): def new_after_edit(self,epo,trans):
if epo: if epo:
if epo.person.get_handle() == "":
self.db.add_person(epo.person,trans) self.db.add_person(epo.person,trans)
else:
self.db.add_person_no_map(epo.person,epo.person.get_handle(),trans)
self.change_active_person(epo.person) self.change_active_person(epo.person)
self.people_view.add_to_person_list(epo.person) self.people_view.add_to_person_list(epo.person)
if self.views.get_current_page() in [FAMILY_VIEW1,FAMILY_VIEW2]: if self.views.get_current_page() in [FAMILY_VIEW1,FAMILY_VIEW2]: