* src/gramps_main.py: dropped New Database message. After all, it should

be incredibly obvious.
* src/Utils.py: create_id to generate random internal ID
* src/RelLib.py: new internal ID support
* src/AddSpouse.py: bug fixes
* src/ChooseParents.py: bug fixes
* src/PeopleModel.py: bug fixes
* src/PeopleView.py: bug fixes
* src/FamilyView.py: bug fixes
* src/Bookmarks.py: support for new internal IDs
* src/EditPerson.py: support for new internal IDs
* src/plugins/ReadGedcom.py: handle new internal IDs


svn: r3233
This commit is contained in:
Don Allingham 2004-06-27 03:10:06 +00:00
parent 2faa14b1a7
commit 4c76be91dd
18 changed files with 247 additions and 204 deletions

View File

@ -1,3 +1,17 @@
2004-06-26 Don Allingham <dallingham@users.sourceforge.net>
* src/gramps_main.py: dropped New Database message. After all, it should
be incredibly obvious.
* src/Utils.py: create_id to generate random internal ID
* src/RelLib.py: new internal ID support
* src/AddSpouse.py: bug fixes
* src/ChooseParents.py: bug fixes
* src/PeopleModel.py: bug fixes
* src/PeopleView.py: bug fixes
* src/FamilyView.py: bug fixes
* src/Bookmarks.py: support for new internal IDs
* src/EditPerson.py: support for new internal IDs
* src/plugins/ReadGedcom.py: handle new internal IDs
2004-06-24 Alex Roitman <shura@alex.neuro.umn.edu>
* src/gramps_main.py (on_import_activate,on_export_activate):
Add methods.

22
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for gramps 1.1.0.
# Generated by GNU Autoconf 2.59 for gramps 1.1.1.
#
# Report bugs to <gramps-bugs@lists.sourceforge.net>.
#
@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='gramps'
PACKAGE_TARNAME='gramps'
PACKAGE_VERSION='1.1.0'
PACKAGE_STRING='gramps 1.1.0'
PACKAGE_VERSION='1.1.1'
PACKAGE_STRING='gramps 1.1.1'
PACKAGE_BUGREPORT='gramps-bugs@lists.sourceforge.net'
ac_unique_file="src/gramps.py"
@ -723,7 +723,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures gramps 1.1.0 to adapt to many kinds of systems.
\`configure' configures gramps 1.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -785,7 +785,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of gramps 1.1.0:";;
short | recursive ) echo "Configuration of gramps 1.1.1:";;
esac
cat <<\_ACEOF
@ -885,7 +885,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
gramps configure 1.1.0
gramps configure 1.1.1
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@ -899,7 +899,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gramps $as_me 1.1.0, which was
It was created by gramps $as_me 1.1.1, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@ -1535,7 +1535,7 @@ fi
# Define the identity of the package.
PACKAGE='gramps'
VERSION='1.1.0'
VERSION='1.1.1'
cat >>confdefs.h <<_ACEOF
@ -1661,7 +1661,7 @@ INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
RELEASE=1
RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-')
VERSIONSTRING=$VERSION
if test x"$RELEASE" != "x"
@ -2736,7 +2736,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by gramps $as_me 1.1.0, which was
This file was extended by gramps $as_me 1.1.1, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -2791,7 +2791,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
gramps config.status 1.1.0
gramps config.status 1.1.1
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"

View File

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

View File

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

View File

@ -172,7 +172,7 @@ class AddSpouse:
return mlist
def select_function(self,store,path,iter,id_list):
id_list.append(store.get_value(iter,1))
id_list.append(store.get_value(iter,PeopleModel.COLUMN_INT_ID))
def select_row(self,obj):
"""
@ -244,7 +244,7 @@ class AddSpouse:
trans = self.db.start_transaction()
if not self.active_family:
self.active_family = self.db.new_family()
self.active_family = self.db.new_family(trans)
self.person.add_family_id(self.active_family.get_id())
self.db.commit_person(self.person,trans)
spouse.add_family_id(self.active_family.get_id())

View File

@ -84,7 +84,7 @@ class Bookmarks :
"""adds a person's name to the drop down menu"""
data = self.db.person_map.get(str(person_id))
if data:
name = data[2].get_name()
name = data[3].get_name()
item = gtk.MenuItem(name)
item.connect("activate", self.callback, person_id)
item.show()
@ -144,7 +144,7 @@ class Bookmarks :
index = 0
for person_id in self.bookmarks:
data = self.db.person_map.get(str(person_id))
name = data[2].get_name()
name = data[3].get_name()
self.namelist.append([name])
self.namelist.set_row_data(index,person_id)
index = index + 1

View File

@ -401,10 +401,10 @@ class ChooseParents:
#self.father_model.center_selected()
def father_select_function(self,store,path,iter,id_list):
id_list.append(self.father_model.get_value(iter,1))
id_list.append(self.father_model.get_value(iter,PeopleModel.COLUMN_INT_ID))
def mother_select_function(self,store,path,iter,id_list):
id_list.append(self.mother_model.get_value(iter,1))
id_list.append(self.mother_model.get_value(iter,PeopleModel.COLUMN_INT_ID))
def get_selected_father_ids(self):
mlist = []
@ -528,7 +528,7 @@ class ChooseParents:
self.db.add_transaction(trans,_("Choose Parents"))
self.close(obj)
def add_new_parent(self,epo):
def add_new_parent(self,epo,trans):
"""Adds a new person to either the father list or the mother list,
depending on the gender of the person."""
@ -536,22 +536,18 @@ class ChooseParents:
id = person.get_id()
if id == "":
id = self.db.add_person(person)
id = self.db.add_person(person,trans)
else:
self.db.add_person_no_map(person,id)
self.db.add_person_no_map(person,id,trans)
self.type = const.save_frel(unicode(self.prel.get_text()))
dinfo = self.db.get_person_display(id)
rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]]
if self.type == "Partners":
self.parent_relation_changed(self.prel)
elif person.get_gender() == RelLib.Person.male:
self.father_model.add(rdata,None,1)
self.father_model.center_selected()
self.redrawf()
else:
self.mother_model.add(rdata,None,1)
self.mother_model.center_selected()
self.redrawm()
self.full_update()
def add_parent_clicked(self,obj):

View File

@ -81,11 +81,11 @@ class EditPerson:
"""Creates an edit window. Associates a person with the window."""
self.person = person
self.orig_id = person.get_id()
self.orig_surname = person.get_primary_name().get_surname()
self.parent = parent
self.orig_id = self.person.get_gramps_id()
if self.parent.child_windows.has_key(self.orig_id):
self.parent.child_windows[self.orig_id].present(None)
self.parent.child_windows[self.person.get_id()].present(None)
return
self.db = db
self.callback = callback
@ -288,7 +288,7 @@ class EditPerson:
build_dropdown(self.dplace,self.place_list)
build_dropdown(self.surname,self.db.get_surnames())
self.gid.set_text(person.get_id())
self.gid.set_text(person.get_gramps_id())
self.gid.set_editable(GrampsCfg.id_edit)
self.lds_baptism = RelLib.LdsOrd(self.person.get_lds_baptism())
@ -1094,7 +1094,7 @@ class EditPerson:
if self.complete.get_active() != self.person.get_complete():
changed = 1
if self.person.get_id() != idval:
if self.person.get_gramps_id() != idval:
changed = 1
if suffix != name.get_suffix():
changed = 1
@ -1449,13 +1449,13 @@ class EditPerson:
self.birth.set_date(unicode(self.bdate.get_text()))
self.birth.set_place_id(self.get_place(self.bplace,1))
if idval != self.person.get_id():
if idval != self.person.get_gramps_id():
m = self.db.get_person_keys()
if not m.has_key(idval):
if m.has_key(self.person.get_id()):
del m[self.person.get_id()]
if m.has_key(self.person.get_gramps_id()):
del m[self.person.get_gramps_id()]
m[idval] = self.person
self.person.set_id(idval)
self.person.set_gramps_id(idval)
else:
n = GrampsCfg.nameof(m[idval])
msg1 = _("GRAMPS ID value was not changed.")
@ -1605,7 +1605,6 @@ class EditPerson:
self.update_lists()
if self.callback:
change = (self.orig_surname != surname) or (self.orig_id != idval)
self.callback(self,trans)
self.db.commit_person(self.person, trans)

View File

@ -25,10 +25,10 @@
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gobject
import gtk
import gtk.glade
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
from gobject import TYPE_STRING, TYPE_INT
#-------------------------------------------------------------------------
#
@ -158,7 +158,7 @@ class FamilyView:
already_init = self.cadded[fv]
self.ap_model = gtk.ListStore(gobject.TYPE_STRING)
self.ap_model = gtk.ListStore(TYPE_STRING)
self.ap_data.set_model(self.ap_model)
if not already_init:
column = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0)
@ -166,7 +166,7 @@ class FamilyView:
self.ap_data.connect('button-press-event',self.ap_button_press)
self.ap_data.connect('key-press-event',self.ap_key_press)
self.ap_parents_model = gtk.ListStore(gobject.TYPE_STRING)
self.ap_parents_model = gtk.ListStore(TYPE_STRING)
self.ap_parents.set_model(self.ap_parents_model)
self.ap_selection = self.ap_parents.get_selection()
if not already_init:
@ -175,7 +175,7 @@ class FamilyView:
self.ap_parents.connect('button-press-event',self.ap_par_button_press)
self.ap_parents.connect('key-press-event',self.ap_par_key_press)
self.sp_parents_model = gtk.ListStore(gobject.TYPE_STRING)
self.sp_parents_model = gtk.ListStore(TYPE_STRING)
self.sp_parents.set_model(self.sp_parents_model)
self.sp_selection = self.sp_parents.get_selection()
if not already_init:
@ -184,7 +184,7 @@ class FamilyView:
self.sp_parents.connect('button-press-event',self.sp_par_button_press)
self.sp_parents.connect('key-press-event',self.sp_par_key_press)
self.spouse_model = gtk.ListStore(gobject.TYPE_STRING)
self.spouse_model = gtk.ListStore(TYPE_STRING)
self.spouse_list.set_model(self.spouse_model)
self.spouse_selection = self.spouse_list.get_selection()
if not already_init:
@ -202,15 +202,16 @@ class FamilyView:
self.child_list.connect('drag_data_get', self.drag_data_get)
self.child_list.connect('drag_data_received',self.drag_data_received)
self.child_model = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING,
gobject.TYPE_STRING,gobject.TYPE_STRING,
gobject.TYPE_STRING,gobject.TYPE_STRING,
gobject.TYPE_STRING)
self.child_model = gtk.ListStore(TYPE_INT, TYPE_STRING,
TYPE_STRING,TYPE_STRING,
TYPE_STRING,TYPE_STRING,
TYPE_STRING,TYPE_STRING)
self.child_selection = self.child_list.get_selection()
if not already_init:
self.child_list.connect('button-press-event',self.on_child_list_button_press)
self.child_list.connect('button-press-event',
self.on_child_list_button_press)
self.child_list.connect('key-press-event',self.child_key_press)
self.swap_btn.connect('clicked',self.spouse_swap)
@ -291,7 +292,7 @@ class FamilyView:
model, iter = self.child_selection.get_selected()
if not iter:
return
id = self.child_model.get_value(iter,2)
id = self.child_model.get_value(iter,7)
if event.keyval == gtk.gdk.keyval_from_name("Return") and not event.state:
self.child_rel_by_id(id)
elif event.keyval == gtk.gdk.keyval_from_name("Return") \
@ -431,7 +432,7 @@ class FamilyView:
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
self.build_nav_menu(event)
return
id = self.child_model.get_value(iter,2)
id = self.child_model.get_value(iter,7)
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
self.child_rel_by_id(id)
elif event.state == gtk.gdk.SHIFT_MASK and \
@ -484,7 +485,7 @@ class FamilyView:
model, iter = self.child_selection.get_selected()
if not iter:
return
child = self.parent.db.get_person(self.child_model.get_value(iter,2))
child = self.parent.db.get_person(self.child_model.get_value(iter,7))
try:
EditPerson.EditPerson(self.parent, child, self.parent.db, self.spouse_after_edit)
except:
@ -616,10 +617,9 @@ class FamilyView:
except:
DisplayTrace.DisplayTrace()
def spouse_after_edit(self,epo):
def spouse_after_edit(self,ep,trans):
ap = self.parent.active_person
if epo:
trans = self.parent.db.start_transaction()
self.parent.db.commit_person(epo.person,trans)
n = epo.person.get_primary_name().get_regular_name()
self.parent.db.add_transaction(trans,_("Add Person (%s)") % n)
@ -738,7 +738,7 @@ class FamilyView:
if not iter:
return
id = self.child_model.get_value(iter,2)
id = self.child_model.get_value(iter,7)
child = self.parent.db.get_person(id)
trans = self.parent.db.start_transaction()
@ -785,13 +785,13 @@ class FamilyView:
trans = self.parent.db.start_transaction()
if self.selected_spouse:
self.selected_spouse.remove_family_id(self.family.get_id(),trans)
self.selected_spouse.remove_family_id(self.family.get_id())
self.parent.db.commit_person(self.selected_spouse,trans)
self.parent.db.commit_family(self.family,trans)
if len(self.family.get_child_id_list()) == 0:
self.person.remove_family_id(self.family.get_id(),trans)
self.person.remove_family_id(self.family.get_id())
self.parent.db.commit_person(self.person,trans)
self.parent.db.delete_family(self.family.get_id(),trans)
if len(self.person.get_family_id_list()) > 0:
@ -868,20 +868,20 @@ class FamilyView:
if bd and dd:
n = "%s [%s]\n\t%s %s\n\t%s %s " % (GrampsCfg.nameof(self.person),
self.person.get_id(),
self.person.get_gramps_id(),
_BORN,bd.get_date(),
_DIED,dd.get_date())
elif bd:
n = "%s [%s]\n\t%s %s" % (GrampsCfg.nameof(self.person),
self.person.get_id(),
self.person.get_gramps_id(),
_BORN,bd.get_date())
elif dd:
n = "%s [%s]\n\t%s %s" % (GrampsCfg.nameof(self.person),
self.person.get_id(),
self.person.get_gramps_id(),
_DIED,dd.get_date())
else:
n = "%s [%s]" % (GrampsCfg.nameof(self.person),
self.person.get_id())
self.person.get_gramps_id())
self.ap_model.clear()
self.ap_data.get_selection().set_mode(gtk.SELECTION_NONE)
@ -923,7 +923,7 @@ class FamilyView:
else:
mdate = ""
v = "%s [%s]\n\t%s%s" % (GrampsCfg.nameof(sp),
sp.get_id(),
sp.get_gramps_id(),
const.display_frel(fm.get_relationship()),
mdate)
self.spouse_model.set(iter,0,v)
@ -982,7 +982,7 @@ class FamilyView:
def nameof(self,l,p,mode):
if p:
n = GrampsCfg.nameof(p)
pid = p.get_id()
pid = p.get_gramps_id()
return _("%s: %s [%s]\n\tRelationship: %s") % (l,n,pid,_(mode))
else:
return _("%s: unknown") % (l)
@ -1049,14 +1049,14 @@ class FamilyView:
val = self.parent.db.get_person_display(child.get_id())
i += 1
event = self.parent.db.find_event_from_id(val[3])
event = self.parent.db.find_event_from_id(val[4])
if event:
dval = event.get_date()
else:
dval = u''
self.child_model.set(iter,0,i,1,val[0],2,val[1],3,val[2],
4,dval,5,status,6,val[6])
4,dval,5,status,6,val[6],7,child.get_id())
def build_parents_menu(self,family,event):
"""Builds the menu that allows editing operations on the child list"""
@ -1340,7 +1340,8 @@ class FamilyView:
pname = self.person.get_primary_name()
return (pname.get_surname_prefix(),pname.get_surname())
elif self.family:
f = self.family.get_father_id()
fid = self.family.get_father_id()
f = self.parent.db.get_family_from_id(fid)
if f:
pname = f.get_primary_name()
return (pname.get_surname_prefix(),pname.get_surname())

View File

@ -52,6 +52,15 @@ COLUMN_NAME = 0
COLUMN_NAME_SORT = 8
COLUMN_VIEW = COLUMN_NAME_SORT + 1
COLUMN_BOLD = COLUMN_VIEW + 1
COLUMN_INT_ID = COLUMN_BOLD + 1
_INT_ID_COL= 0
_ID_COL = 1
_GENDER_COL= 2
_NAME_COL = 3
_DEATH_COL = 6
_BIRTH_COL = 7
_FAMILY_COL= 9
#-------------------------------------------------------------------------
#
@ -194,8 +203,8 @@ class PeopleModel(gtk.GenericTreeModel):
self.row_inserted(mypath,self.get_iter(mypath))
def byname(self,f,s):
n1 = self.db.person_map.get(str(f))[2].get_sort_name()
n2 = self.db.person_map.get(str(s))[2].get_sort_name()
n1 = self.db.person_map.get(str(f))[_NAME_COL].get_sort_name()
n2 = self.db.person_map.get(str(s))[_NAME_COL].get_sort_name()
return cmp(n1,n2)
def on_get_flags(self):
@ -203,7 +212,7 @@ class PeopleModel(gtk.GenericTreeModel):
return gtk.TREE_MODEL_ITERS_PERSIST
def on_get_n_columns(self):
return 9
return COLUMN_INT_ID + 1
def on_get_path(self, node):
'''returns the tree path (a tuple of indices at the various
@ -235,7 +244,9 @@ class PeopleModel(gtk.GenericTreeModel):
return None
def on_get_value(self,iter,col):
if col == COLUMN_BOLD:
if col == COLUMN_INT_ID:
return iter
elif col == COLUMN_BOLD:
if self.top_iter2path.has_key(iter):
return pango.WEIGHT_BOLD
else:
@ -318,47 +329,47 @@ class PeopleModel(gtk.GenericTreeModel):
return None
def sort_name(self,data):
return data[2].get_sort_name()
return data[_NAME_COL].get_sort_name()
def column_spouse(self,data):
id = data[0]
if data[8]:
fid = data[8][0]
if data[_FAMILY_COL]:
fid = data[_FAMILY_COL][0]
else:
return u""
d2 = self.db.family_map.get(str(fid))
if fid and d2 :
if d2[1] == id:
return self.db.person_map.get(str(d2[2]))[2].get_name()
return self.db.person_map.get(str(d2[2]))[_NAME_COL].get_name()
else:
return self.db.person_map.get(str(d2[1]))[2].get_name()
return self.db.person_map.get(str(d2[1]))[_NAME_COL].get_name()
else:
return u""
def column_name(self,data):
return data[2].get_name()
return data[_NAME_COL].get_name()
def column_id(self,data):
return data[0]
return data[_ID_COL]
def column_gender(self,data):
return _GENDER[data[1]]
return _GENDER[data[_GENDER_COL]]
def column_birth_day(self,data):
if data[6]:
return self.db.find_event_from_id(data[6]).get_date()
if data[_BIRTH_COL]:
return self.db.find_event_from_id(data[_BIRTH_COL]).get_date()
else:
return u""
def column_death_day(self,data):
if data[5]:
return self.db.find_event_from_id(data[5]).get_date()
if data[_DEATH_COL]:
return self.db.find_event_from_id(data[_DEATH_COL]).get_date()
else:
return u""
def column_birth_place(self,data):
if data[6]:
event = self.db.find_event_from_id(data[6])
if data[_BIRTH_COL]:
event = self.db.find_event_from_id(data[_BIRTH_COL])
if event:
place_id = event.get_place_id()
if place_id:
@ -366,8 +377,8 @@ class PeopleModel(gtk.GenericTreeModel):
return u""
def column_death_place(self,data):
if data[5]:
event = self.db.find_event_from_id(data[5])
if data[_DEATH_COL]:
event = self.db.find_event_from_id(data[_DEATH_COL])
if event:
place_id = event.get_place_id()
if place_id:

View File

@ -130,7 +130,7 @@ class PeopleView:
self.person_tree.set_model(self.sort_model)
def blist(self, store, path, iter, id_list):
id_list.append(self.sort_model.get_value(iter,1))
id_list.append(self.sort_model.get_value(iter,PeopleModel.COLUMN_INT_ID))
def get_selected_objects(self):
mlist = []

View File

@ -30,6 +30,7 @@ import os
import gtk
import shutil
import xml.parsers.expat
import Utils
from gettext import gettext as _
#-------------------------------------------------------------------------
@ -128,8 +129,6 @@ def importData(database, filename, callback=None,cl=0):
ErrorDialog(_("Error reading %s") % filename,
_("The file is probably either corrupt or not a valid GRAMPS database."))
return 0
except ValueError, msg:
pass
except:
if cl:
import traceback
@ -273,6 +272,7 @@ class GrampsParser:
self.note_list = []
self.tlist = []
self.conf = 2
self.gid2id = {}
self.ord = None
self.objref = None
@ -323,6 +323,7 @@ class GrampsParser:
self.func_index = 0
self.func = None
self.witness_comment = ""
self.idswap = {}
self.func_map = {
"address" : (self.start_address, self.stop_address),
@ -407,6 +408,28 @@ class GrampsParser:
"url" : (self.start_url, None)
}
def find_person_by_gramps_id(self,gramps_id):
person = RelLib.Person()
intid = self.gid2id.get(gramps_id)
if intid:
person.unserialize(self.db.person_map.get(intid))
else:
intid = Utils.create_id()
person.set_id(intid)
person.set_gramps_id(gramps_id)
self.db.add_person_as(person,self.trans)
self.gid2id[gramps_id] = intid
return person
def map_gid(self,id):
if self.idswap.get(id):
return self.idswap[id]
else:
if self.db.idtrans.get(str(id)):
self.idswap[id] = self.db.find_next_gid()
else:
self.idswap[id] = id
return self.idswap[id]
def parse(self,file):
self.trans = self.db.start_transaction()
@ -419,8 +442,9 @@ class GrampsParser:
self.db.set_researcher(self.owner)
if self.tempDefault != None:
id = self.tempDefault
if self.db.has_person_id(id) and self.db.get_default_person() == None:
self.db.set_default_person_id(id)
person = self.db.try_to_find_person_from_gramps_id(id)
if person:
self.db.set_default_person_id(person.get_id())
for key in self.func_map.keys():
del self.func_map[key]
@ -450,7 +474,7 @@ class GrampsParser:
self.ord.set_status(int(attrs['val']))
def start_sealed_to(self,attrs):
id = attrs['ref']
id = self.map_gid(attrs['ref'])
self.ord.set_family_id(self.db.find_family_no_map(id,self.trans))
def start_place(self,attrs):
@ -498,7 +522,7 @@ class GrampsParser:
def start_witness(self,attrs):
self.in_witness = 1
if attrs.has_key('ref'):
self.witness = RelLib.Witness(RelLib.Event.ID,attrs['ref'])
self.witness = RelLib.Witness(RelLib.Event.ID,self.map_gid(attrs['ref']))
if attrs.has_key('name'):
self.witness = RelLib.Witness(RelLib.Event.NAME,attrs['name'])
@ -553,16 +577,16 @@ class GrampsParser:
self.address.private = int(attrs["priv"])
def start_bmark(self,attrs):
person = self.db.find_person_no_conflicts(attrs["ref"],
self.pmap,self.trans)
person = self.find_person_by_gramps_id(self.map_gid(attrs["ref"]))
self.db.bookmarks.append(person.get_id())
def start_person(self,attrs):
if self.callback != None and self.count % self.increment == 0:
self.callback(float(self.count)/float(self.entries))
self.count = self.count + 1
self.person = self.db.find_person_no_conflicts(attrs["id"],
self.pmap, self.trans)
self.person = self.find_person_by_gramps_id(self.map_gid(attrs['id']))
if attrs.has_key("complete"):
self.person.set_complete(int(attrs['complete']))
else:
@ -573,16 +597,18 @@ class GrampsParser:
self.tempDefault = attrs["default"]
def start_father(self,attrs):
self.family.set_father_id(attrs["ref"])
person = self.db.try_to_find_person_from_gramps_id(self.map_gid(attrs["ref"]))
self.family.set_father_id(person.get_id())
def start_mother(self,attrs):
self.family.set_mother_id(attrs["ref"])
person = self.db.try_to_find_person_from_gramps_id(self.map_gid(attrs["ref"]))
self.family.set_mother_id(person.get_id())
def start_child(self,attrs):
self.family.add_child_id(attrs["ref"])
person = self.db.try_to_find_person_from_gramps_id(self.map_gid(attrs["ref"]))
self.family.add_child_id(person.get_id())
def start_url(self,attrs):
if not attrs.has_key("href"):
return
try:

View File

@ -45,6 +45,7 @@ import cPickle
from Date import Date, SingleDate, compare_dates, not_too_old
import GrampsCfg
import const
import Utils
#-------------------------------------------------------------------------
#
@ -359,7 +360,7 @@ class Place(SourceNote):
def get_id(self):
"""Returns the gramps ID for the place object"""
return self.id
def set_title(self,name):
"""Sets the title of the place object"""
self.title = name
@ -1145,6 +1146,7 @@ class Person(SourceNote):
"""creates a new Person instance"""
SourceNote.__init__(self)
self.id = gid
self.gid = ""
self.primary_name = Name()
self.event_list = []
self.family_list = []
@ -1170,7 +1172,7 @@ class Person(SourceNote):
self.db = None
def serialize(self):
return (self.id, self.gender,
return (self.id, self.gid, self.gender,
self.primary_name, self.alternate_names, self.nickname,
self.death_id, self.birth_id, self.event_list,
self.family_list, self.parent_family_list,
@ -1184,7 +1186,7 @@ class Person(SourceNote):
self.note)
def unserialize(self,data):
(self.id, self.gender,
(self.id, self.gid, self.gender,
self.primary_name, self.alternate_names, self.nickname,
self.death_id, self.birth_id, self.event_list,
self.family_list, self.parent_family_list,
@ -1211,7 +1213,7 @@ class Person(SourceNote):
bday = self.birth_id
dday = self.death_id
return [ GrampsCfg.display_name(self),
self.id,
self.gid,
gender,
bday,
dday,
@ -1261,6 +1263,14 @@ class Person(SourceNote):
"""adds a URL instance to the list"""
self.urls.append(url)
def set_gramps_id(self,gid):
"""sets the gramps ID for the Person"""
self.gid = str(gid)
def get_gramps_id(self):
"""returns the gramps ID for the Person"""
return self.gid
def set_id(self,gid):
"""sets the gramps ID for the Person"""
self.id = str(gid)
@ -2350,7 +2360,10 @@ except ImportError: # try python2.2
def find_surname(key,data):
return str(data[2].get_surname())
return str(data[3].get_surname())
def find_idmap(key,data):
return str(data[1])
def find_eventname(key,data):
return str(data[1])
@ -2424,11 +2437,15 @@ class GrampsDB:
self.surnames.set_flags(db.DB_DUP)
self.surnames.open(name, "surnames", db.DB_HASH, flags=db.DB_CREATE)
self.idtrans = db.DB(self.env)
self.idtrans.set_flags(db.DB_DUP)
self.idtrans.open(name, "idtrans", db.DB_HASH, flags=db.DB_CREATE)
self.eventnames = db.DB(self.env)
self.eventnames.set_flags(db.DB_DUP)
self.eventnames.open(name, "eventnames", db.DB_HASH, flags=db.DB_CREATE)
self.person_map.associate(self.surnames, find_surname, db.DB_CREATE)
self.person_map.associate(self.idtrans, find_idmap, db.DB_CREATE)
self.event_map.associate(self.eventnames, find_eventname, db.DB_CREATE)
self.undodb = db.DB()
@ -2439,6 +2456,14 @@ class GrampsDB:
self.bookmarks = []
return 1
def find_next_gid(self):
index = self.iprefix % self.pmap_index
while self.idtrans.get(str(index)):
self.pmap_index += 1
index = self.iprefix % self.pmap_index
self.pmap_index += 1
return index
def get_people_view_maps(self):
if self.metadata:
return (self.metadata.get('tp_iter'),
@ -2468,6 +2493,7 @@ class GrampsDB:
self.metadata.close()
self.surnames.close()
self.eventnames.close()
self.idtrans.close()
self.env.close()
self.undodb.close()
@ -2532,22 +2558,22 @@ class GrampsDB:
def get_person_display(self,key):
data = self.person_map.get(str(key))
if data[1] == Person.male:
if data[2] == Person.male:
gender = const.male
elif data[1] == Person.female:
elif data[2] == Person.female:
gender = const.female
else:
gender = const.unknown
return [ data[2].get_name(),
data[0],
return [ data[3].get_name(),
data[1],
gender,
data[7],
data[6],
data[5],
data[2].get_sort_name(),
data[3].get_sort_name(),
data[7],
data[6],
data[5],
GrampsCfg.display_surname(data[2])]
GrampsCfg.display_surname(data[3])]
def commit_person(self,person,transaction):
gid = str(person.get_id())
@ -2913,17 +2939,13 @@ class GrampsDB:
def add_person(self,person,trans):
"""adds a Person to the database, assigning a gramps' ID"""
index = self.iprefix % self.pmap_index
while self.person_map.get(str(index)):
self.pmap_index = self.pmap_index + 1
index = self.iprefix % self.pmap_index
person.set_id(index)
person.set_gramps_id(self.find_next_gid())
person.set_id(Utils.create_id())
if trans != None:
trans.add(PERSON_KEY, person.get_id(),None)
self.person_map.put(str(index),person.serialize())
self.pmap_index = self.pmap_index + 1
self.person_map.put(str(person.get_id()),person.serialize())
self.genderStats.count_person (person, self)
return index
return person.get_id()
def find_person(self,gid,map,trans):
"""finds a Person in the database using the gid and map
@ -2955,7 +2977,6 @@ class GrampsDB:
If no such Person exists, a new Person is added to the database."""
data = self.person_map.get(str(val))
if data:
person = Person()
person.unserialize(data)
@ -2963,6 +2984,18 @@ class GrampsDB:
else:
return None
def try_to_find_person_from_gramps_id(self,val):
"""finds a Person in the database from the passed gramps' ID.
If no such Person exists, a new Person is added to the database."""
data = self.idtrans.get(str(val))
if data:
person = Person()
person.unserialize(cPickle.loads(data))
return person
else:
return None
def find_person_from_id(self,val,trans):
"""finds a Person in the database from the passed gramps' ID.
If no such Person exists, a new Person is added to the database."""
@ -2976,7 +3009,6 @@ class GrampsDB:
if trans != None:
trans.add(PERSON_KEY, val, None)
self.person_map.put(str(val), person.serialize())
self.pmap_index = self.pmap_index+1
# self.genderStats.count_person (person, self)
return person
@ -2988,7 +3020,6 @@ class GrampsDB:
if trans != None:
trans.add(PERSON_KEY, gid, None)
self.person_map.set(str(gid),person.serialize())
self.pmap_index = self.pmap_index+1
# self.genderStats.count_person (person, self)
return gid
@ -3032,7 +3063,6 @@ class GrampsDB:
def add_event_no_map(self,event,index,trans):
"""adds a Source to the database if the gramps' ID is known"""
return
event.set_id(index)
if trans != None:
trans.add(EVENT_KEY,index,None)
@ -3476,26 +3506,6 @@ class GrampsDB:
trans.add(FAMILY_KEY,family_id,old_data)
self.family_map.delete(str(family_id))
def find_person_no_conflicts(self,gid,map,trans):
"""finds a Person in the database using the gid and map
variables to translate between the external ID and gramps'
internal ID. If no such Person exists, a new Person instance
is created.
gid - external ID number
map - map build by findPerson of external to gramp's IDs"""
person = Person()
if map.has_key(gid):
person.unserialize(self.person_map.get(str(map[gid])))
else:
if self.person_map.get(str(gid)):
map[gid] = self.add_person(person,trans)
else:
person.set_id(gid)
map[gid] = self.add_person_as(person,trans)
return person
def find_family_no_conflicts(self,gid,map,trans):
"""finds a Family in the database using the gid and map
variables to translate between the external ID and gramps'

View File

@ -262,7 +262,7 @@ class SelectChild:
self.add_child.scroll_to_cell(path,col,1,0.5,0.0)
def select_function(self,store,path,iter,id_list):
id_list.append(self.refmodel.get_value(iter,1))
id_list.append(self.refmodel.get_value(iter,PeopleModel.COLUMN_INT_ID))
def get_selected_ids(self):
mlist = []
@ -425,8 +425,9 @@ class EditRel:
})
f = self.child.has_family(self.family.get_id())
self.fentry.set_text(_(f[2]))
self.mentry.set_text(_(f[1]))
if f:
self.fentry.set_text(_(f[2]))
self.mentry.set_text(_(f[1]))
self.fdesc.set_use_markup(gtk.TRUE)
self.mdesc.set_use_markup(gtk.TRUE)

View File

@ -28,6 +28,7 @@
import string
import os
import locale
import time
#-------------------------------------------------------------------------
#
@ -53,6 +54,15 @@ import GrampsMime
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Random
#
#-------------------------------------------------------------------------
import random
rand = random.Random(time.time())
#-------------------------------------------------------------------------
#
# modified flag
@ -527,3 +537,7 @@ def unbold_label(label):
label.set_text(text)
label.set_use_markup(0)
def create_id():
return str("%08x%08x" % (
int(time.time()*10000),
rand.randint(0,0x7fffffff)))

View File

@ -142,13 +142,15 @@ dist_pkgdata_DATA = gedcom.xml \
papersize.xml \
tips.xml \
gnome-mime-application-x-gramps.png \
gnome-mime-application-x-gedcom.png \
gnome-mime-application-x-gramps-package.png \
gramps.applications \
gramps.desktop \
gramps.svg \
gramps.keys \
gramps.mime
EXTRA_DIST = $(pkgdata_DATA)
EXTRA_DIST = $(dist_pkgdata_DATA)
all: all-recursive
.SUFFIXES:
@ -460,7 +462,7 @@ install-data-local:
$(INSTALL) -d $(DESTDIR)$(prefix)/share/gnome/apps/Applications
$(INSTALL_DATA) gramps.desktop $(DESTDIR)$(prefix)/share/applications
$(INSTALL) -d $(DESTDIR)$(prefix)/share/icons/gnome/48x48/mimetypes/
$(INSTALL_DATA) gnome-mime-application-x-gramps.png $(DESTDIR)$(prefix)/share/icons/gnome/48x48/mimetypes/
$(INSTALL_DATA) gnome-mime-application-x-*.png $(DESTDIR)$(prefix)/share/icons/gnome/48x48/mimetypes/
$(INSTALL) -d $(DESTDIR)$(prefix)/share/application-registry
$(INSTALL_DATA) gramps.applications $(DESTDIR)$(prefix)/share/application-registry
$(INSTALL) -d $(DESTDIR)$(prefix)/share/mime/packages

View File

@ -906,49 +906,11 @@ class Gramps:
def on_new_clicked(self,obj):
"""Prompt for permission to close the current database"""
QuestionDialog(_('Create a New Database'),
_('Creating a new database will close the existing database, '
'discarding any unsaved changes. You will then be prompted '
'to create a new database'),
_('_Create New Database'),
self.new_database_response,self.topWindow)
def new_database_response(self):
DbPrompter.DbPrompter(self,1,self.topWindow)
def clear_database(self):
"""Clear out the database if permission was granted"""
return
const.personalEvents = const.init_personal_event_list()
const.personalAttributes = const.init_personal_attribute_list()
const.marriageEvents = const.init_marriage_event_list()
const.familyAttributes = const.init_family_attribute_list()
const.familyRelations = const.init_family_relation_list()
self.history = []
self.mhistory = []
self.hindex = -1
self.redraw_histmenu()
self.relationship.set_db(self.db)
self.place_view.change_db(self.db)
self.people_view.change_db(self.db)
self.source_view.change_db(self.db)
self.media_view.change_db(self.db)
if not self.cl:
self.topWindow.set_title("GRAMPS")
self.active_person = None
self.change_active_person(None)
self.people_view.clear()
self.family_view.clear()
self.family_view.load_family()
self.pedigree_view.clear()
self.media_view.load_media()
def tool_callback(self,val):
if val:
@ -1434,7 +1396,7 @@ class Gramps:
else:
if GrampsCfg.status_bar <= 1:
pname = GrampsCfg.nameof(self.active_person)
name = "[%s] %s" % (self.active_person.get_id(),pname)
name = "[%s] %s" % (self.active_person.get_gramps_id(),pname)
else:
name = self.display_relationship()
self.status_text(name)

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
v# $Id$
"Import from GEDCOM"
@ -204,7 +204,6 @@ class GedcomParser:
def __init__(self, dbase, file, window):
self.db = dbase
self.person = None
self.pmap = {}
self.fmap = {}
self.smap = {}
self.nmap = {}
@ -219,6 +218,7 @@ class GedcomParser:
self.broken_conc_list = [ 'FamilyOrigins', 'FTW' ]
self.broken_conc = 0
self.is_ftw = 0
self.idswap = {}
self.f = open(file,"r")
self.filename = file
@ -541,16 +541,18 @@ class GedcomParser:
else:
self.barf(1)
def find_or_create_person(self,id):
if self.pmap.has_key(id):
person = self.db.find_person_from_id(self.pmap[id],self.trans)
elif self.db.has_person_id(id):
person = RelLib.Person()
self.pmap[id] = self.db.add_person(person,self.trans)
def map_gid(self,id):
if self.idswap.get(id):
return self.idswap[id]
else:
person = RelLib.Person(id)
self.db.add_person_as(person,self.trans)
self.pmap[id] = id
if self.db.idtrans.get(str(id)):
self.idswap[id] = self.db.find_next_gid()
else:
self.idswap[id] = id
return self.idswap[id]
def find_or_create_person(self,id):
person = self.db.try_to_find_person_from_gramps_id(self.map_gid(id))
return person
def parse_cause(self,event,level):
@ -1719,9 +1721,12 @@ class GedcomParser:
return source_ref
def resolve_refns(self):
return
prefix = self.db.iprefix
index = 0
new_pmax = self.db.pmap_index
print self.added
for pid in self.added.keys():
index = index + 1
if self.refn.has_key(pid):
@ -1735,6 +1740,7 @@ class GedcomParser:
if not self.db.has_person_id(new_key):
self.db.remove_person_id(pid,self.trans)
person.set_id(new_key)
person.set_gramps_id(new_key)
self.db.add_person(person,self.trans)
else:
tp = self.db.find_person_from_id(new_key,self.trans)
@ -1742,6 +1748,7 @@ class GedcomParser:
if person == tp:
self.db.remove_person_id(pid,self.trans)
person.set_id(new_key)
person.set_gramps_id(new_key)
self.db.add_person_as(person,self.trans)
# give up trying to use the refn as a key
else: