* src/ChooseParents.py: use integers instead of strings for
relationship types * src/PedView.py: use integers instead of strings for relationship types * src/ReadGedcom.py: use integers instead of strings for relationship types * src/ReadXML.py: use integers instead of strings for relationship types * src/RelLib.py: use integers instead of strings for relationship types * src/SelectChild.py: use integers instead of strings for relationship types * src/WriteXML.py: use integers instead of strings for relationship types * src/const.py.in: use integers instead of strings for relationship types * src/gramps_main.py: call database update function * src/GrampsBSDDB.py: add database upgrade function * src/GrampsDbBase.py: add database upgrade function svn: r4113
This commit is contained in:
parent
164cfe3983
commit
31f3958a1c
@ -1,4 +1,23 @@
|
|||||||
2005-03-02 Don Allingham <dallingham@users.sourceforge.net>
|
2005-03-02 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/ChooseParents.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/PedView.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/ReadGedcom.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/ReadXML.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/RelLib.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/SelectChild.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/WriteXML.py: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/const.py.in: use integers instead of strings for
|
||||||
|
relationship types
|
||||||
|
* src/gramps_main.py: call database update function
|
||||||
|
* src/GrampsBSDDB.py: add database upgrade function
|
||||||
|
* src/GrampsDbBase.py: add database upgrade function
|
||||||
* src/Marriage.py: fix lds menu
|
* src/Marriage.py: fix lds menu
|
||||||
* src/AddSpouse.py: use ComboBox instead of ComboBoxEntry for
|
* src/AddSpouse.py: use ComboBox instead of ComboBoxEntry for
|
||||||
handling child/parent relationships
|
handling child/parent relationships
|
||||||
|
@ -151,8 +151,8 @@ class ChooseParents:
|
|||||||
frel = fr
|
frel = fr
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
mrel = "Birth"
|
mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
frel = "Birth"
|
frel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
|
|
||||||
if self.family:
|
if self.family:
|
||||||
self.type = self.family.get_relationship()
|
self.type = self.family.get_relationship()
|
||||||
@ -172,14 +172,9 @@ class ChooseParents:
|
|||||||
"on_familyDialog_delete_event" : self.on_delete_event,
|
"on_familyDialog_delete_event" : self.on_delete_event,
|
||||||
})
|
})
|
||||||
|
|
||||||
values = const.child_relations.get_values()
|
self.keys = const.child_rel_list
|
||||||
self.keys = []
|
self.build_list(self.mcombo,mrel)
|
||||||
for value in values:
|
self.build_list(self.fcombo,frel)
|
||||||
self.keys.append(const.child_relations.find_key(value))
|
|
||||||
self.keys.sort()
|
|
||||||
|
|
||||||
self.build_list(self.mcombo,mr)
|
|
||||||
self.build_list(self.fcombo,fr)
|
|
||||||
|
|
||||||
self.val = self.top.run()
|
self.val = self.top.run()
|
||||||
if self.val == gtk.RESPONSE_OK:
|
if self.val == gtk.RESPONSE_OK:
|
||||||
@ -192,15 +187,10 @@ class ChooseParents:
|
|||||||
opt_menu.add_attribute(cell,'text',0)
|
opt_menu.add_attribute(cell,'text',0)
|
||||||
|
|
||||||
store = gtk.ListStore(str)
|
store = gtk.ListStore(str)
|
||||||
sel_index = 0
|
|
||||||
index = 0
|
|
||||||
for val in self.keys:
|
for val in self.keys:
|
||||||
if _(sel) == val:
|
|
||||||
sel_index = index
|
|
||||||
index += 1
|
|
||||||
store.append(row=[val])
|
store.append(row=[val])
|
||||||
opt_menu.set_model(store)
|
opt_menu.set_model(store)
|
||||||
opt_menu.set_active(sel_index)
|
opt_menu.set_active(sel)
|
||||||
|
|
||||||
def build_father_list(self):
|
def build_father_list(self):
|
||||||
self.father_selection = self.father_list.get_selection()
|
self.father_selection = self.father_list.get_selection()
|
||||||
@ -432,12 +422,12 @@ class ChooseParents:
|
|||||||
try:
|
try:
|
||||||
mother_rel = self.keys[self.mcombo.get_active()]
|
mother_rel = self.keys[self.mcombo.get_active()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
mother_rel = "Birth"
|
mother_rel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
|
|
||||||
try:
|
try:
|
||||||
father_rel = self.keys[self.fcombo.get_active()]
|
father_rel = self.keys[self.fcombo.get_active()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
father_rel = "Birth"
|
father_rel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
if self.father or self.mother:
|
if self.father or self.mother:
|
||||||
@ -592,12 +582,12 @@ class ModifyParents:
|
|||||||
self.flabel = self.glade.get_widget("flabel")
|
self.flabel = self.glade.get_widget("flabel")
|
||||||
self.mlabel = self.glade.get_widget("mlabel")
|
self.mlabel = self.glade.get_widget("mlabel")
|
||||||
|
|
||||||
self.orig_mrel = _("Birth")
|
self.orig_mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
self.orig_frel = _("Birth")
|
self.orig_frel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
for (f,mr,fr) in self.person.get_parent_family_handle_list():
|
for (f,mr,fr) in self.person.get_parent_family_handle_list():
|
||||||
if f == self.family.get_handle():
|
if f == self.family.get_handle():
|
||||||
self.orig_mrel = _(mr)
|
self.orig_mrel = mr
|
||||||
self.orig_frel = _(fr)
|
self.orig_frel = fr
|
||||||
|
|
||||||
self.glade.signal_autoconnect({
|
self.glade.signal_autoconnect({
|
||||||
"on_parents_help_clicked" : self.on_help_clicked,
|
"on_parents_help_clicked" : self.on_help_clicked,
|
||||||
@ -645,11 +635,7 @@ class ModifyParents:
|
|||||||
self.mcombo.set_sensitive(False)
|
self.mcombo.set_sensitive(False)
|
||||||
self.glade.get_widget('ok').set_sensitive(False)
|
self.glade.get_widget('ok').set_sensitive(False)
|
||||||
|
|
||||||
values = const.child_relations.get_values()
|
self.keys = const.child_rel_list
|
||||||
self.keys = []
|
|
||||||
for value in values:
|
|
||||||
self.keys.append(const.child_relations.find_key(value))
|
|
||||||
self.keys.sort()
|
|
||||||
|
|
||||||
self.build_list(self.mcombo,self.orig_mrel)
|
self.build_list(self.mcombo,self.orig_mrel)
|
||||||
self.build_list(self.fcombo,self.orig_frel)
|
self.build_list(self.fcombo,self.orig_frel)
|
||||||
@ -663,15 +649,10 @@ class ModifyParents:
|
|||||||
cell = gtk.CellRendererText()
|
cell = gtk.CellRendererText()
|
||||||
|
|
||||||
store = gtk.ListStore(str)
|
store = gtk.ListStore(str)
|
||||||
sel_index = 0
|
|
||||||
index = 0
|
|
||||||
for val in self.keys:
|
for val in self.keys:
|
||||||
if _(sel) == val:
|
|
||||||
sel_index = index
|
|
||||||
index += 1
|
|
||||||
store.append(row=[val])
|
store.append(row=[val])
|
||||||
opt_menu.set_model(store)
|
opt_menu.set_model(store)
|
||||||
opt_menu.set_active(sel_index)
|
opt_menu.set_active(sel)
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def on_help_clicked(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
|
@ -33,7 +33,7 @@ from RelLib import *
|
|||||||
from GrampsDbBase import *
|
from GrampsDbBase import *
|
||||||
from bsddb import dbshelve, db
|
from bsddb import dbshelve, db
|
||||||
|
|
||||||
_DBVERSION = 1
|
_DBVERSION = 2
|
||||||
|
|
||||||
def find_surname(key,data):
|
def find_surname(key,data):
|
||||||
return str(data[3].get_surname())
|
return str(data[3].get_surname())
|
||||||
@ -98,6 +98,9 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
def get_media_cursor(self):
|
def get_media_cursor(self):
|
||||||
return GrampsBSDDBCursor(self.media_map)
|
return GrampsBSDDBCursor(self.media_map)
|
||||||
|
|
||||||
|
def need_upgrade(self):
|
||||||
|
return self.metadata['version'] < _DBVERSION
|
||||||
|
|
||||||
def load(self,name,callback,mode="w"):
|
def load(self,name,callback,mode="w"):
|
||||||
if self.person_map:
|
if self.person_map:
|
||||||
self.close()
|
self.close()
|
||||||
@ -169,15 +172,20 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
self.undodb = db.DB()
|
self.undodb = db.DB()
|
||||||
self.undodb.open(self.undolog, db.DB_RECNO, db.DB_CREATE)
|
self.undodb.open(self.undolog, db.DB_RECNO, db.DB_CREATE)
|
||||||
|
|
||||||
if not self.readonly and self.metadata.get('version') == None:
|
|
||||||
self.metadata['version'] = _DBVERSION
|
|
||||||
|
|
||||||
self.metadata = self.dbopen(name, "meta")
|
self.metadata = self.dbopen(name, "meta")
|
||||||
self.bookmarks = self.metadata.get('bookmarks')
|
self.bookmarks = self.metadata.get('bookmarks')
|
||||||
|
|
||||||
|
gstats = self.metadata.get('gender_stats')
|
||||||
|
|
||||||
|
if not self.readonly and gstats == None:
|
||||||
|
self.metadata['version'] = _DBVERSION
|
||||||
|
elif not self.metadata.has_key('version'):
|
||||||
|
self.metadata['version'] = 0
|
||||||
|
|
||||||
if self.bookmarks == None:
|
if self.bookmarks == None:
|
||||||
self.bookmarks = []
|
self.bookmarks = []
|
||||||
|
|
||||||
self.genderStats = GenderStats(self.metadata.get('gender_stats'))
|
self.genderStats = GenderStats(gstats)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def abort_changes(self):
|
def abort_changes(self):
|
||||||
@ -351,3 +359,35 @@ class GrampsBSDDB(GrampsDbBase):
|
|||||||
return obj
|
return obj
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def upgrade(self):
|
||||||
|
child_rel_notrans = [
|
||||||
|
"None", "Birth", "Adopted", "Stepchild",
|
||||||
|
"Sponsored", "Foster", "Unknown", "Other", ]
|
||||||
|
|
||||||
|
version = self.metadata['version']
|
||||||
|
if version < 2:
|
||||||
|
cursor = self.get_person_cursor()
|
||||||
|
data = cursor.first()
|
||||||
|
while data:
|
||||||
|
handle,info = data
|
||||||
|
person = Person()
|
||||||
|
person.unserialize(info)
|
||||||
|
|
||||||
|
plist = person.get_parent_family_handle_list()
|
||||||
|
new_list = []
|
||||||
|
for (f,mrel,frel) in plist:
|
||||||
|
try:
|
||||||
|
mrel = child_rel_notrans.index(mrel)
|
||||||
|
except:
|
||||||
|
mrel = Person.CHILD_REL_BIRTH
|
||||||
|
try:
|
||||||
|
frel = child_rel_notrans.index(frel)
|
||||||
|
except:
|
||||||
|
frel = Person.CHILD_REL_BIRTH
|
||||||
|
new_list.append((f,mrel,frel))
|
||||||
|
person.parent_family_list = new_list
|
||||||
|
self.commit_person(person,None)
|
||||||
|
data = cursor.next()
|
||||||
|
cursor.close()
|
||||||
|
self.metadata['version'] = 2
|
||||||
|
@ -165,6 +165,12 @@ class GrampsDbBase:
|
|||||||
self.place2title = {}
|
self.place2title = {}
|
||||||
self.name_groups = {}
|
self.name_groups = {}
|
||||||
|
|
||||||
|
def need_upgrade(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def upgrade(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def create_id(self):
|
def create_id(self):
|
||||||
s = ""
|
s = ""
|
||||||
for val in [ int(time.time()*10000) & 0x7fffffff,
|
for val in [ int(time.time()*10000) & 0x7fffffff,
|
||||||
|
@ -384,6 +384,8 @@ class Gallery(ImageSelect):
|
|||||||
image = ImgManip.get_thumbnail_image(media_obj.get_path())
|
image = ImgManip.get_thumbnail_image(media_obj.get_path())
|
||||||
else:
|
else:
|
||||||
image = Utils.find_mime_type_pixbuf(mtype)
|
image = Utils.find_mime_type_pixbuf(mtype)
|
||||||
|
if not image:
|
||||||
|
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
||||||
except gobject.GError,msg:
|
except gobject.GError,msg:
|
||||||
ErrorDialog(str(msg))
|
ErrorDialog(str(msg))
|
||||||
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
||||||
|
@ -110,9 +110,6 @@ def set_thumbnail_image(path):
|
|||||||
pixbuf = pixbuf.scale_simple(pw,ph,gtk.gdk.INTERP_BILINEAR)
|
pixbuf = pixbuf.scale_simple(pw,ph,gtk.gdk.INTERP_BILINEAR)
|
||||||
pixbuf.save(_build_thumb_path(path),"jpeg")
|
pixbuf.save(_build_thumb_path(path),"jpeg")
|
||||||
except:
|
except:
|
||||||
import traceback
|
|
||||||
traceback.print_stack()
|
|
||||||
|
|
||||||
print "Could not create thumbnail for",path
|
print "Could not create thumbnail for",path
|
||||||
|
|
||||||
def get_thumbnail_image(path):
|
def get_thumbnail_image(path):
|
||||||
|
@ -499,8 +499,8 @@ class PedigreeView:
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
if family_handle:
|
if family_handle:
|
||||||
mrel = (m != "Birth")
|
mrel = m != RelLib.Person.CHILD_REL_BIRTH
|
||||||
frel = (f != "Birth")
|
frel = f != RelLib.Person.CHILD_REL_BIRTH
|
||||||
|
|
||||||
family = self.parent.db.get_family_from_handle(family_handle)
|
family = self.parent.db.get_family_from_handle(family_handle)
|
||||||
if family != None:
|
if family != None:
|
||||||
|
@ -83,6 +83,10 @@ file_systems = {
|
|||||||
"SMBFS" : _('Networked Windows file system')
|
"SMBFS" : _('Networked Windows file system')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rel_types = (RelLib.Person.CHILD_REL_BIRTH,
|
||||||
|
RelLib.Person.CHILD_REL_UNKWN,
|
||||||
|
RelLib.Person.CHILD_REL_NONE)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GEDCOM events to GRAMPS events conversion
|
# GEDCOM events to GRAMPS events conversion
|
||||||
@ -744,8 +748,8 @@ class GedcomParser:
|
|||||||
self.barf(level+1)
|
self.barf(level+1)
|
||||||
|
|
||||||
def parse_ftw_relations(self,level):
|
def parse_ftw_relations(self,level):
|
||||||
mrel = "Birth"
|
mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
frel = "Birth"
|
frel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
matches = self.get_next()
|
matches = self.get_next()
|
||||||
@ -759,14 +763,16 @@ class GedcomParser:
|
|||||||
# FTW
|
# FTW
|
||||||
elif matches[1] == "_MREL":
|
elif matches[1] == "_MREL":
|
||||||
if matches[2].lower() != "natural":
|
if matches[2].lower() != "natural":
|
||||||
mrel = matches[2]
|
mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
elif matches[1] == "ADOP":
|
elif matches[1] == "ADOP":
|
||||||
mrel = "Adopted"
|
mrel = RelLib.Person.CHILD_REL_ADOPT
|
||||||
frel = "Adopted"
|
frel = RelLib.Person.CHILD_REL_ADOPT
|
||||||
# Legacy
|
# Legacy
|
||||||
elif matches[1] == "_STAT":
|
elif matches[1] == "_STAT":
|
||||||
mrel = matches[2]
|
mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
frel = matches[2]
|
frel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
|
#mrel = matches[2]
|
||||||
|
#frel = matches[2]
|
||||||
# Legacy _PREF
|
# Legacy _PREF
|
||||||
elif matches[1][0] == "_":
|
elif matches[1][0] == "_":
|
||||||
pass
|
pass
|
||||||
@ -811,7 +817,7 @@ class GedcomParser:
|
|||||||
if f[0] == self.family.get_handle():
|
if f[0] == self.family.get_handle():
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if (mrel=="Birth" or mrel=="") and (frel=="Birth" or frel==""):
|
if mrel in rel_types and frel in reltypes:
|
||||||
child.set_main_parent_family_handle(self.family.get_handle())
|
child.set_main_parent_family_handle(self.family.get_handle())
|
||||||
else:
|
else:
|
||||||
if child.get_main_parents_family_handle() == self.family:
|
if child.get_main_parents_family_handle() == self.family:
|
||||||
@ -963,11 +969,11 @@ class GedcomParser:
|
|||||||
if f[0] == handle:
|
if f[0] == handle:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if ftype == "" or ftype == "Birth":
|
if ftype in rel_types:
|
||||||
if self.person.get_main_parents_family_handle() == None:
|
if self.person.get_main_parents_family_handle() == None:
|
||||||
self.person.set_main_parent_family_handle(handle)
|
self.person.set_main_parent_family_handle(handle)
|
||||||
else:
|
else:
|
||||||
self.person.add_parent_family_handle(handle,"Unknown","Unknown")
|
self.person.add_parent_family_handle(handle,RelLib.Person.CHILD_REL_UNKWN,RelLib.Person.CHILD_REL_UNKWN)
|
||||||
else:
|
else:
|
||||||
if self.person.get_main_parents_family_handle() == handle:
|
if self.person.get_main_parents_family_handle() == handle:
|
||||||
self.person.set_main_parent_family_handle(None)
|
self.person.set_main_parent_family_handle(None)
|
||||||
@ -1420,9 +1426,9 @@ class GedcomParser:
|
|||||||
return (mrel,frel)
|
return (mrel,frel)
|
||||||
elif matches[1] == "ADOP":
|
elif matches[1] == "ADOP":
|
||||||
if matches[2] == "HUSB":
|
if matches[2] == "HUSB":
|
||||||
mrel = "Birth"
|
mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
elif matches[2] == "WIFE":
|
elif matches[2] == "WIFE":
|
||||||
frel = "Birth"
|
frel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
else:
|
else:
|
||||||
self.barf(level+1)
|
self.barf(level+1)
|
||||||
return None
|
return None
|
||||||
|
@ -796,13 +796,19 @@ class GrampsParser:
|
|||||||
family = self.find_family_by_gramps_id(self.map_fid(attrs["ref"]))
|
family = self.find_family_by_gramps_id(self.map_fid(attrs["ref"]))
|
||||||
|
|
||||||
if attrs.has_key("mrel"):
|
if attrs.has_key("mrel"):
|
||||||
mrel = attrs["mrel"]
|
try:
|
||||||
|
mrel = const.child_rel_notrans[attrs["mrel"]]
|
||||||
|
except:
|
||||||
|
mrel = RelLib.Person.CHILD_REL_NONE
|
||||||
else:
|
else:
|
||||||
mrel = "Birth"
|
mrel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
if attrs.has_key("frel"):
|
if attrs.has_key("frel"):
|
||||||
frel = attrs["frel"]
|
try:
|
||||||
|
frel = const.child_rel_notrans[attrs["frel"]]
|
||||||
|
except:
|
||||||
|
frel = RelLib.Person.CHILD_REL_NONE
|
||||||
else:
|
else:
|
||||||
frel = "Birth"
|
frel = RelLib.Person.CHILD_REL_BIRTH
|
||||||
self.person.add_parent_family_handle(family.get_handle(),mrel,frel)
|
self.person.add_parent_family_handle(family.get_handle(),mrel,frel)
|
||||||
|
|
||||||
def start_parentin(self,attrs):
|
def start_parentin(self,attrs):
|
||||||
|
@ -325,6 +325,15 @@ class Person(PrimaryObject,DataObj):
|
|||||||
MALE = 1
|
MALE = 1
|
||||||
FEMALE = 0
|
FEMALE = 0
|
||||||
|
|
||||||
|
CHILD_REL_NONE = 0
|
||||||
|
CHILD_REL_BIRTH = 1
|
||||||
|
CHILD_REL_ADOPT = 2
|
||||||
|
CHILD_REL_STEP = 3
|
||||||
|
CHILD_REL_SPONS = 4
|
||||||
|
CHILD_REL_FOST = 5
|
||||||
|
CHILD_REL_UNKWN = 6
|
||||||
|
CHILD_REL_OTHER = 7
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Creates a new Person instance. After initialization, most
|
Creates a new Person instance. After initialization, most
|
||||||
|
@ -90,14 +90,8 @@ class SelectChild:
|
|||||||
self.mrel = self.xml.get_widget("mrel_combo")
|
self.mrel = self.xml.get_widget("mrel_combo")
|
||||||
self.frel = self.xml.get_widget("frel_combo")
|
self.frel = self.xml.get_widget("frel_combo")
|
||||||
|
|
||||||
values = const.child_relations.get_values()
|
self.build_list(self.mrel,RelLib.Person.CHILD_REL_BIRTH)
|
||||||
self.keys = []
|
self.build_list(self.frel,RelLib.Person.CHILD_REL_BIRTH)
|
||||||
for value in values:
|
|
||||||
self.keys.append(const.child_relations.find_key(value))
|
|
||||||
self.keys.sort()
|
|
||||||
|
|
||||||
self.build_list(self.mrel,"Birth")
|
|
||||||
self.build_list(self.frel,"Birth")
|
|
||||||
|
|
||||||
if self.family:
|
if self.family:
|
||||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
||||||
@ -122,15 +116,10 @@ class SelectChild:
|
|||||||
opt_menu.add_attribute(cell,'text',0)
|
opt_menu.add_attribute(cell,'text',0)
|
||||||
|
|
||||||
store = gtk.ListStore(str)
|
store = gtk.ListStore(str)
|
||||||
sel_index = 0
|
for val in const.child_rel_list:
|
||||||
index = 0
|
|
||||||
for val in self.keys:
|
|
||||||
if _(sel) == val:
|
|
||||||
sel_index = index
|
|
||||||
index += 1
|
|
||||||
store.append(row=[val])
|
store.append(row=[val])
|
||||||
opt_menu.set_model(store)
|
opt_menu.set_model(store)
|
||||||
opt_menu.set_active(sel_index)
|
opt_menu.set_active(sel)
|
||||||
|
|
||||||
def add_columns(self,tree):
|
def add_columns(self,tree):
|
||||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||||
@ -320,19 +309,20 @@ class SelectChild:
|
|||||||
|
|
||||||
self.family.add_child_handle(select_child.get_handle())
|
self.family.add_child_handle(select_child.get_handle())
|
||||||
|
|
||||||
mrel = self.keys[self.mrel.get_active()]
|
mrel = self.mrel.get_active()
|
||||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
||||||
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
||||||
if mrel == "Birth":
|
if mrel == RelLib.Person.CHILD_REL_BIRTH:
|
||||||
mrel = "Unknown"
|
mrel = RelLib.Person.CHILD_REL_UNKWN
|
||||||
|
|
||||||
frel = self.keys[self.frel.get_active()]
|
frel = self.frel.get_active()
|
||||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
||||||
if father and father.get_gender() !=RelLib.Person.MALE:
|
if father and father.get_gender() !=RelLib.Person.MALE:
|
||||||
if frel == "Birth":
|
if frel == RelLib.Person.CHILD_REL_BIRTH:
|
||||||
frel = "Unknown"
|
frel = RelLib.Person.CHILD_REL_UNKWN
|
||||||
|
|
||||||
select_child.add_parent_family_handle(self.family.get_handle(),mrel,frel)
|
select_child.add_parent_family_handle(self.family.get_handle(),
|
||||||
|
mrel,frel)
|
||||||
|
|
||||||
self.db.commit_person(select_child,trans)
|
self.db.commit_person(select_child,trans)
|
||||||
self.db.commit_family(self.family,trans)
|
self.db.commit_family(self.family,trans)
|
||||||
@ -392,87 +382,3 @@ class SelectChild:
|
|||||||
else:
|
else:
|
||||||
return ("","")
|
return ("","")
|
||||||
|
|
||||||
class EditRel:
|
|
||||||
|
|
||||||
def __init__(self,db,child,family,update):
|
|
||||||
self.db = db
|
|
||||||
self.update = update
|
|
||||||
self.child = child
|
|
||||||
self.family = family
|
|
||||||
|
|
||||||
self.xml = gtk.glade.XML(const.gladeFile,"editrel","gramps")
|
|
||||||
self.top = self.xml.get_widget('editrel')
|
|
||||||
self.mdesc = self.xml.get_widget('mrel_desc')
|
|
||||||
self.fdesc = self.xml.get_widget('frel_desc')
|
|
||||||
self.mentry = self.xml.get_widget('mrel')
|
|
||||||
self.fentry = self.xml.get_widget('frel')
|
|
||||||
self.mcombo = self.xml.get_widget('mrel_combo')
|
|
||||||
self.fcombo = self.xml.get_widget('frel_combo')
|
|
||||||
|
|
||||||
name = NameDisplay.displayer.display(child)
|
|
||||||
Utils.set_titles(self.top,self.xml.get_widget('title'),
|
|
||||||
_('Relationships of %s') % name)
|
|
||||||
|
|
||||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
|
||||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
|
||||||
|
|
||||||
if father:
|
|
||||||
fname = NameDisplay.displayer.display(father)
|
|
||||||
val = _("Relationship to %(father)s") % {
|
|
||||||
'father' : fname }
|
|
||||||
self.fdesc.set_text('<b>%s</b>' % val)
|
|
||||||
self.fcombo.set_sensitive(1)
|
|
||||||
else:
|
|
||||||
val = _("Relationship to father")
|
|
||||||
self.fdesc.set_text('<b>%s</b>' % val)
|
|
||||||
self.fcombo.set_sensitive(0)
|
|
||||||
|
|
||||||
if mother:
|
|
||||||
mname = NameDisplay.displayer.display(mother)
|
|
||||||
val = _("Relationship to %(mother)s") % {
|
|
||||||
'mother' : mname }
|
|
||||||
self.mdesc.set_text('<b>%s</b>' % val)
|
|
||||||
self.mcombo.set_sensitive(1)
|
|
||||||
else:
|
|
||||||
val = _("Relationship to mother")
|
|
||||||
self.mdesc.set_text('<b>%s</b>' % val)
|
|
||||||
self.mcombo.set_sensitive(0)
|
|
||||||
|
|
||||||
self.xml.signal_autoconnect({
|
|
||||||
"on_ok_clicked" : self.on_ok_clicked,
|
|
||||||
"destroy_passed_object" : self.close
|
|
||||||
})
|
|
||||||
|
|
||||||
f = self.child.get_parent_family(self.family.get_handle())
|
|
||||||
if f:
|
|
||||||
self.fentry.set_text(_(f[2]))
|
|
||||||
self.mentry.set_text(_(f[1]))
|
|
||||||
|
|
||||||
self.fdesc.set_use_markup(True)
|
|
||||||
self.mdesc.set_use_markup(True)
|
|
||||||
self.top.show()
|
|
||||||
|
|
||||||
def close(self,obj):
|
|
||||||
self.top.destroy()
|
|
||||||
|
|
||||||
def on_ok_clicked(self,obj):
|
|
||||||
mrel = const.child_relations.find_value(self.mentry.get_text())
|
|
||||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
|
||||||
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
|
||||||
if mrel == "Birth":
|
|
||||||
mrel = "Unknown"
|
|
||||||
|
|
||||||
frel = const.child_relations.find_value(self.fentry.get_text())
|
|
||||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
|
||||||
if father and father.get_gender() !=RelLib.Person.MALE:
|
|
||||||
if frel == "Birth":
|
|
||||||
frel = "Unknown"
|
|
||||||
|
|
||||||
self.child.change_parent_family_handle(self.family.get_handle(),mrel,frel)
|
|
||||||
trans = self.db.transaction_begin()
|
|
||||||
self.db.commit_person(self.child,trans)
|
|
||||||
n = self.child.get_primary_name().get_regular_name()
|
|
||||||
self.db.transaction_commit(trans,_("Parent Relationships (%s)") % n)
|
|
||||||
|
|
||||||
self.update()
|
|
||||||
self.top.destroy()
|
|
||||||
|
@ -300,12 +300,12 @@ class XmlWriter:
|
|||||||
self.write_url_list(person.get_url_list())
|
self.write_url_list(person.get_url_list())
|
||||||
|
|
||||||
for alt in person.get_parent_family_handle_list():
|
for alt in person.get_parent_family_handle_list():
|
||||||
if alt[1] != "Birth":
|
if alt[1] != RelLib.Person.CHILD_REL_BIRTH:
|
||||||
mrel=' mrel="%s"' % alt[1]
|
mrel=' mrel="%s"' % const.child_rel_notrans[alt[1]]
|
||||||
else:
|
else:
|
||||||
mrel=''
|
mrel=''
|
||||||
if alt[2] != "Birth":
|
if alt[2] != "Birth":
|
||||||
frel=' frel="%s"' % alt[2]
|
frel=' frel="%s"' % const.child_rel_notrans[alt[2]]
|
||||||
else:
|
else:
|
||||||
frel=''
|
frel=''
|
||||||
parent_family = self.db.get_family_from_handle (alt[0])
|
parent_family = self.db.get_family_from_handle (alt[0])
|
||||||
|
@ -225,6 +225,14 @@ shortopts = "O:i:o:f:a:p:?"
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
child_rel_list = [
|
||||||
|
_("None"), _("Birth"), _("Adopted"), _("Stepchild"),
|
||||||
|
_("Sponsored"), _("Foster"), _("Unknown"), _("Other"), ]
|
||||||
|
|
||||||
|
child_rel_notrans = [
|
||||||
|
"None", "Birth", "Adopted", "Stepchild",
|
||||||
|
"Sponsored", "Foster", "Unknown", "Other", ]
|
||||||
|
|
||||||
child_relations = TransTable( {
|
child_relations = TransTable( {
|
||||||
_("Birth") : "Birth",
|
_("Birth") : "Birth",
|
||||||
_("Adopted") : "Adopted",
|
_("Adopted") : "Adopted",
|
||||||
|
@ -1583,9 +1583,10 @@ class Gramps:
|
|||||||
if res.get_name() == "" and owner.get_name():
|
if res.get_name() == "" and owner.get_name():
|
||||||
self.db.set_researcher(owner)
|
self.db.set_researcher(owner)
|
||||||
|
|
||||||
if callback:
|
|
||||||
callback(_('Setting up bookmarks...'))
|
|
||||||
self.setup_bookmarks()
|
self.setup_bookmarks()
|
||||||
|
if callback and self.db.need_upgrade():
|
||||||
|
callback(_('Upgrading database...'))
|
||||||
|
self.db.upgrade()
|
||||||
|
|
||||||
GrampsKeys.save_last_file(name)
|
GrampsKeys.save_last_file(name)
|
||||||
self.gtop.get_widget("filter").set_text("")
|
self.gtop.get_widget("filter").set_text("")
|
||||||
|
Loading…
Reference in New Issue
Block a user