First pass at ZODB support
svn: r994
This commit is contained in:
@@ -39,6 +39,12 @@ import VersionControl
|
|||||||
from intl import gettext
|
from intl import gettext
|
||||||
_ = gettext
|
_ = gettext
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ZODB
|
||||||
|
_zodb = 1
|
||||||
|
except:
|
||||||
|
_zodb = 0
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# DbPrompter
|
# DbPrompter
|
||||||
@@ -60,11 +66,18 @@ class DbPrompter:
|
|||||||
"on_opendb_delete_event": self.open_delete_event,
|
"on_opendb_delete_event": self.open_delete_event,
|
||||||
})
|
})
|
||||||
self.new = opendb.get_widget("new")
|
self.new = opendb.get_widget("new")
|
||||||
|
self.zodb = opendb.get_widget("zodb")
|
||||||
if self.want_new:
|
if self.want_new:
|
||||||
self.new.set_active(1)
|
self.new.set_active(1)
|
||||||
|
if _zodb:
|
||||||
|
self.zodb.show()
|
||||||
|
|
||||||
def open_ok_clicked(self,obj):
|
def open_ok_clicked(self,obj):
|
||||||
if self.new.get_active():
|
if self.new.get_active():
|
||||||
|
self.db.clear_database(0)
|
||||||
|
self.save_as_activate()
|
||||||
|
elif self.zodb.get_active():
|
||||||
|
self.db.clear_database(1)
|
||||||
self.save_as_activate()
|
self.save_as_activate()
|
||||||
else:
|
else:
|
||||||
self.open_activate()
|
self.open_activate()
|
||||||
@@ -110,7 +123,6 @@ class DbPrompter:
|
|||||||
return
|
return
|
||||||
|
|
||||||
Utils.destroy_passed_object(obj)
|
Utils.destroy_passed_object(obj)
|
||||||
self.db.clear_database()
|
|
||||||
|
|
||||||
if self.getoldrev.get_active():
|
if self.getoldrev.get_active():
|
||||||
vc = VersionControl.RcsVersionControl(filename)
|
vc = VersionControl.RcsVersionControl(filename)
|
||||||
|
@@ -249,7 +249,7 @@ class EditPerson:
|
|||||||
self.autoplace = AutoComp.AutoCombo(self.bpcombo,self.pmap.keys())
|
self.autoplace = AutoComp.AutoCombo(self.bpcombo,self.pmap.keys())
|
||||||
self.autodeath = AutoComp.AutoCombo(self.dpcombo,self.pmap.keys(),
|
self.autodeath = AutoComp.AutoCombo(self.dpcombo,self.pmap.keys(),
|
||||||
self.autoplace)
|
self.autoplace)
|
||||||
self.comp = AutoComp.AutoCombo(self.sncombo,const.surnames)
|
self.comp = AutoComp.AutoCombo(self.sncombo,self.db.getSurnames())
|
||||||
|
|
||||||
self.gid.set_text(person.getId())
|
self.gid.set_text(person.getId())
|
||||||
self.gid.set_editable(GrampsCfg.id_edit)
|
self.gid.set_editable(GrampsCfg.id_edit)
|
||||||
@@ -1140,9 +1140,7 @@ class EditPerson:
|
|||||||
|
|
||||||
if surname != name.getSurname():
|
if surname != name.getSurname():
|
||||||
name.setSurname(surname)
|
name.setSurname(surname)
|
||||||
if surname not in const.surnames:
|
self.db.addSurname(name)
|
||||||
const.surnames.append(surname)
|
|
||||||
const.surnames.sort()
|
|
||||||
|
|
||||||
if given != name.getFirstName():
|
if given != name.getFirstName():
|
||||||
name.setFirstName(given)
|
name.setFirstName(given)
|
||||||
|
@@ -84,6 +84,9 @@ class MediaView:
|
|||||||
self.media_list.set_sort_column(self.sort_map[self.sort_col])
|
self.media_list.set_sort_column(self.sort_map[self.sort_col])
|
||||||
self.set_arrow(self.sort_col)
|
self.set_arrow(self.sort_col)
|
||||||
|
|
||||||
|
def change_db(self,db):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
def moveto(self,row):
|
def moveto(self,row):
|
||||||
self.media_list.unselect_all()
|
self.media_list.unselect_all()
|
||||||
self.media_list.select_row(row,0)
|
self.media_list.select_row(row,0)
|
||||||
@@ -260,7 +263,7 @@ class MediaView:
|
|||||||
object = self.media_list.get_row_data(self.media_list.selection[0])
|
object = self.media_list.get_row_data(self.media_list.selection[0])
|
||||||
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
|
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
|
||||||
|
|
||||||
def on_delete_media_clicked(self,obj):
|
def on_delete_clicked(self,obj):
|
||||||
if len(self.media_list.selection) <= 0:
|
if len(self.media_list.selection) <= 0:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@@ -57,7 +57,7 @@ class NameEditor:
|
|||||||
self.type_field = self.top.get_widget("name_type")
|
self.type_field = self.top.get_widget("name_type")
|
||||||
self.note_field = self.top.get_widget("alt_note")
|
self.note_field = self.top.get_widget("alt_note")
|
||||||
slist = self.top.get_widget("alt_surname_list")
|
slist = self.top.get_widget("alt_surname_list")
|
||||||
self.combo = AutoComp.AutoCombo(slist,const.surnames)
|
self.combo = AutoComp.AutoCombo(slist,self.parent.db.getSurnames())
|
||||||
self.priv = self.top.get_widget("priv")
|
self.priv = self.top.get_widget("priv")
|
||||||
|
|
||||||
types = const.NameTypesMap.keys()
|
types = const.NameTypesMap.keys()
|
||||||
@@ -138,9 +138,7 @@ class NameEditor:
|
|||||||
|
|
||||||
if self.name.getSurname() != last:
|
if self.name.getSurname() != last:
|
||||||
self.name.setSurname(last)
|
self.name.setSurname(last)
|
||||||
if last not in const.surnames:
|
self.parent.db.addSurname(last)
|
||||||
const.surnames.append(last)
|
|
||||||
const.surnames.sort()
|
|
||||||
self.parent.lists_changed = 1
|
self.parent.lists_changed = 1
|
||||||
|
|
||||||
if self.name.getSuffix() != suffix:
|
if self.name.getSuffix() != suffix:
|
||||||
|
@@ -93,6 +93,9 @@ class PlaceView:
|
|||||||
self.place_list.set_sort_column(self.sort_map[self.sort_col])
|
self.place_list.set_sort_column(self.sort_map[self.sort_col])
|
||||||
self.place_list.set_sort_type(self.sort_dir)
|
self.place_list.set_sort_type(self.sort_dir)
|
||||||
|
|
||||||
|
def change_db(self,db):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
def load_places(self):
|
def load_places(self):
|
||||||
"""Rebuilds the entire place view. This can be very time consuming
|
"""Rebuilds the entire place view. This can be very time consuming
|
||||||
on large databases, and should only be called when absolutely
|
on large databases, and should only be called when absolutely
|
||||||
@@ -105,23 +108,12 @@ class PlaceView:
|
|||||||
|
|
||||||
self.place_list.freeze()
|
self.place_list.freeze()
|
||||||
self.place_list.clear()
|
self.place_list.clear()
|
||||||
|
|
||||||
self.place_list.set_column_visibility(1,GrampsCfg.id_visible)
|
self.place_list.set_column_visibility(1,GrampsCfg.id_visible)
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
u = string.upper
|
for key in self.db.getPlaceKeys():
|
||||||
for src in self.db.getPlaceMap().values():
|
src = self.db.getPlaceMap()[key]
|
||||||
title = src.get_title()
|
self.place_list.append(src.getDisplayInfo())
|
||||||
id = src.getId()
|
|
||||||
mloc = src.get_main_location()
|
|
||||||
city = mloc.get_city()
|
|
||||||
county = mloc.get_county()
|
|
||||||
state = mloc.get_state()
|
|
||||||
parish = mloc.get_parish()
|
|
||||||
country = mloc.get_country()
|
|
||||||
self.place_list.append([title,id,parish,city,county,state,country,
|
|
||||||
u(title), u(parish), u(city),
|
|
||||||
u(county),u(state), u(country)])
|
|
||||||
self.place_list.set_row_data(index,src)
|
self.place_list.set_row_data(index,src)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
|
||||||
@@ -194,18 +186,7 @@ class PlaceView:
|
|||||||
obj.thaw()
|
obj.thaw()
|
||||||
|
|
||||||
def insert_place(self,place):
|
def insert_place(self,place):
|
||||||
title = place.get_title()
|
self.place_list.append(place.getDisplayInfo())
|
||||||
id = place.getId()
|
|
||||||
mloc = place.get_main_location()
|
|
||||||
city = mloc.get_city()
|
|
||||||
county = mloc.get_county()
|
|
||||||
state = mloc.get_state()
|
|
||||||
parish = mloc.get_parish()
|
|
||||||
country = mloc.get_country()
|
|
||||||
u = string.upper
|
|
||||||
self.place_list.append([title,id,parish,city,county,state,country,
|
|
||||||
u(title), u(parish), u(city),
|
|
||||||
u(county),u(state), u(country)])
|
|
||||||
self.place_list.set_row_data(self.place_list.rows-1,place)
|
self.place_list.set_row_data(self.place_list.rows-1,place)
|
||||||
|
|
||||||
def new_place_after_edit(self,place):
|
def new_place_after_edit(self,place):
|
||||||
@@ -231,7 +212,7 @@ class PlaceView:
|
|||||||
self.place_list.select_row(row,0)
|
self.place_list.select_row(row,0)
|
||||||
self.place_list.moveto(row)
|
self.place_list.moveto(row)
|
||||||
|
|
||||||
def on_delete_place_clicked(self,obj):
|
def on_delete_clicked(self,obj):
|
||||||
if len(obj.selection) == 0:
|
if len(obj.selection) == 0:
|
||||||
return
|
return
|
||||||
elif len(obj.selection) > 1:
|
elif len(obj.selection) > 1:
|
||||||
|
@@ -41,7 +41,7 @@ class QuickAdd:
|
|||||||
self.window.editable_enters(self.xml.get_widget("given"))
|
self.window.editable_enters(self.xml.get_widget("given"))
|
||||||
self.window.editable_enters(self.xml.get_widget("surname"))
|
self.window.editable_enters(self.xml.get_widget("surname"))
|
||||||
self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"),
|
self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"),
|
||||||
const.surnames)
|
self.db.getSurnames())
|
||||||
|
|
||||||
def close(self,obj):
|
def close(self,obj):
|
||||||
surname = self.xml.get_widget("surname").get_text()
|
surname = self.xml.get_widget("surname").get_text()
|
||||||
|
@@ -23,26 +23,75 @@
|
|||||||
__author__ = "Don Allingham"
|
__author__ = "Don Allingham"
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# standard python modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
from re import compile
|
from re import compile
|
||||||
from Date import Date, compare_dates, not_too_old
|
from string import strip, upper
|
||||||
from string import strip
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# GRAMPS modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from Date import Date, compare_dates, not_too_old
|
||||||
|
import sort
|
||||||
|
import const
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Attempt to load the ZODB libraries, otherwise provide alternates
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
try:
|
||||||
|
from ZODB import Persistent
|
||||||
|
from ZODB.PersistentList import PersistentList
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
class Persistent:
|
||||||
|
pass
|
||||||
|
|
||||||
|
from UserList import UserList
|
||||||
|
class PersistentList(UserList):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Confidence levels
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
CONF_VERY_HIGH = 4
|
CONF_VERY_HIGH = 4
|
||||||
CONF_HIGH = 3
|
CONF_HIGH = 3
|
||||||
CONF_NORMAL = 2
|
CONF_NORMAL = 2
|
||||||
CONF_LOW = 1
|
CONF_LOW = 1
|
||||||
CONF_VERY_LOW = 0
|
CONF_VERY_LOW = 0
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# ID regular expression
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
_id_reg = compile("%\d+d")
|
_id_reg = compile("%\d+d")
|
||||||
|
|
||||||
class SourceNote:
|
|
||||||
|
def extlist(lst):
|
||||||
|
return lst[:] # Make a copy.
|
||||||
|
|
||||||
|
def extmap(map):
|
||||||
|
return map
|
||||||
|
|
||||||
|
|
||||||
|
class SourceNote(Persistent):
|
||||||
"""Base class for storing source references and notes"""
|
"""Base class for storing source references and notes"""
|
||||||
|
|
||||||
def __init__(self,source=None):
|
def __init__(self,source=None):
|
||||||
"""Create a new SourceNote, copying from source if not None"""
|
"""Create a new SourceNote, copying from source if not None"""
|
||||||
|
|
||||||
self.source_list = []
|
self.source_list = PersistentList()
|
||||||
|
|
||||||
if source:
|
if source:
|
||||||
if len(source.source_list) > 0:
|
if len(source.source_list) > 0:
|
||||||
@@ -58,10 +107,11 @@ class SourceNote:
|
|||||||
def addSourceRef(self,id) :
|
def addSourceRef(self,id) :
|
||||||
"""Set the source reference"""
|
"""Set the source reference"""
|
||||||
self.source_list.append(id)
|
self.source_list.append(id)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getSourceRefList(self) :
|
def getSourceRefList(self) :
|
||||||
"""Return the source reference"""
|
"""Return the source reference"""
|
||||||
return self.source_list
|
return extlist(self.source_list)
|
||||||
|
|
||||||
def setSourceRefList(self,list) :
|
def setSourceRefList(self,list) :
|
||||||
"""Replaces the source reference"""
|
"""Replaces the source reference"""
|
||||||
@@ -219,14 +269,14 @@ class Place(SourceNote):
|
|||||||
self.lat = source.lat
|
self.lat = source.lat
|
||||||
self.title = source.title
|
self.title = source.title
|
||||||
self.main_loc = Location(source.main_loc)
|
self.main_loc = Location(source.main_loc)
|
||||||
self.alt_loc = []
|
self.alt_loc = PersistentList()
|
||||||
for loc in source.alt_loc:
|
for loc in source.alt_loc:
|
||||||
self.alt_loc = Location(loc)
|
self.alt_loc = Location(loc)
|
||||||
self.id = source.id
|
self.id = source.id
|
||||||
self.urls = []
|
self.urls = PersistentList()
|
||||||
for u in source.urls:
|
for u in source.urls:
|
||||||
self.urls.append(Url(u))
|
self.urls.append(Url(u))
|
||||||
self.photoList = []
|
self.photoList = PersistentList()
|
||||||
for photo in source.photoList:
|
for photo in source.photoList:
|
||||||
self.photoList.append(ObjectRef(photo))
|
self.photoList.append(ObjectRef(photo))
|
||||||
else:
|
else:
|
||||||
@@ -234,14 +284,14 @@ class Place(SourceNote):
|
|||||||
self.lat = ""
|
self.lat = ""
|
||||||
self.title = ""
|
self.title = ""
|
||||||
self.main_loc = None
|
self.main_loc = None
|
||||||
self.alt_loc = []
|
self.alt_loc = PersistentList()
|
||||||
self.id = ""
|
self.id = ""
|
||||||
self.urls = []
|
self.urls = PersistentList()
|
||||||
self.photoList = []
|
self.photoList = PersistentList()
|
||||||
|
|
||||||
def getUrlList(self):
|
def getUrlList(self):
|
||||||
"""Return the list of URLs"""
|
"""Return the list of URLs"""
|
||||||
return self.urls
|
return extlist(self.urls)
|
||||||
|
|
||||||
def setUrlList(self,list):
|
def setUrlList(self,list):
|
||||||
"""Replace the current URL list with the new one"""
|
"""Replace the current URL list with the new one"""
|
||||||
@@ -250,6 +300,7 @@ class Place(SourceNote):
|
|||||||
def addUrl(self,url):
|
def addUrl(self,url):
|
||||||
"""Add a URL to the URL list"""
|
"""Add a URL to the URL list"""
|
||||||
self.urls.append(url)
|
self.urls.append(url)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def setId(self,id):
|
def setId(self,id):
|
||||||
"""Sets the gramps ID for the place object"""
|
"""Sets the gramps ID for the place object"""
|
||||||
@@ -295,7 +346,7 @@ class Place(SourceNote):
|
|||||||
|
|
||||||
def get_alternate_locations(self):
|
def get_alternate_locations(self):
|
||||||
"""Returns a list of alternate location information objects"""
|
"""Returns a list of alternate location information objects"""
|
||||||
return self.alt_loc
|
return extlist(self.alt_loc)
|
||||||
|
|
||||||
def set_alternate_locations(self,list):
|
def set_alternate_locations(self,list):
|
||||||
"""Replaces the current alternate location list with the new one"""
|
"""Replaces the current alternate location list with the new one"""
|
||||||
@@ -305,20 +356,33 @@ class Place(SourceNote):
|
|||||||
"""Adds a Location to the alternate location list"""
|
"""Adds a Location to the alternate location list"""
|
||||||
if loc not in self.alt_loc:
|
if loc not in self.alt_loc:
|
||||||
self.alt_loc.append(loc)
|
self.alt_loc.append(loc)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def addPhoto(self,photo):
|
def addPhoto(self,photo):
|
||||||
"""Adds a Photo object to the place object's image list"""
|
"""Adds a Photo object to the place object's image list"""
|
||||||
self.photoList.append(photo)
|
self.photoList.append(photo)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getPhotoList(self):
|
def getPhotoList(self):
|
||||||
"""Returns the list of Photo objects"""
|
"""Returns the list of Photo objects"""
|
||||||
return self.photoList
|
return extlist(self.photoList)
|
||||||
|
|
||||||
def setPhotoList(self,list):
|
def setPhotoList(self,list):
|
||||||
"""Sets the list of Photo objects"""
|
"""Sets the list of Photo objects"""
|
||||||
self.photoList = list
|
self.photoList = list
|
||||||
|
|
||||||
class Researcher:
|
def getDisplayInfo(self):
|
||||||
|
if self.main_loc:
|
||||||
|
return [self.title,self.id,self.main_loc.parish,self.main_loc.city,
|
||||||
|
self.main_loc.county,self.main_loc.state,self.main_loc.country,
|
||||||
|
upper(self.title), upper(self.main_loc.parish),
|
||||||
|
upper(self.main_loc.city), upper(self.main_loc.county),
|
||||||
|
upper(self.main_loc.state), upper(self.main_loc.country)]
|
||||||
|
else:
|
||||||
|
return [self.title,self.id,'','','','','',
|
||||||
|
upper(self.title), '','','','','']
|
||||||
|
|
||||||
|
class Researcher(Persistent):
|
||||||
"""Contains the information about the owner of the database"""
|
"""Contains the information about the owner of the database"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -383,7 +447,7 @@ class Researcher:
|
|||||||
if email:
|
if email:
|
||||||
self.email = strip(email)
|
self.email = strip(email)
|
||||||
|
|
||||||
class Location:
|
class Location(Persistent):
|
||||||
"""Provides information about a place, including city, county, state,
|
"""Provides information about a place, including city, county, state,
|
||||||
and country. Multiple Location objects can represent the same place,
|
and country. Multiple Location objects can represent the same place,
|
||||||
since names of citys, countys, states, and even countries can change
|
since names of citys, countys, states, and even countries can change
|
||||||
@@ -405,7 +469,7 @@ class Location:
|
|||||||
self.country = ""
|
self.country = ""
|
||||||
|
|
||||||
def is_empty(self):
|
def is_empty(self):
|
||||||
return self.city == "" and self.county == "" and self.state == "" and self.country == ""
|
return self.city=="" and self.county=="" and self.state=="" and self.country==""
|
||||||
|
|
||||||
def set_city(self,data):
|
def set_city(self,data):
|
||||||
"""sets the city name of the Location object"""
|
"""sets the city name of the Location object"""
|
||||||
@@ -447,7 +511,7 @@ class Location:
|
|||||||
"""returns the country name of the Location object"""
|
"""returns the country name of the Location object"""
|
||||||
return self.country
|
return self.country
|
||||||
|
|
||||||
class Note:
|
class Note(Persistent):
|
||||||
"""Provides general text information"""
|
"""Provides general text information"""
|
||||||
|
|
||||||
def __init__(self,text = ""):
|
def __init__(self,text = ""):
|
||||||
@@ -475,7 +539,7 @@ class Photo(SourceNote):
|
|||||||
|
|
||||||
SourceNote.__init__(self,source)
|
SourceNote.__init__(self,source)
|
||||||
|
|
||||||
self.attrlist = []
|
self.attrlist = PersistentList()
|
||||||
if source:
|
if source:
|
||||||
self.path = source.path
|
self.path = source.path
|
||||||
self.mime = source.mime
|
self.mime = source.mime
|
||||||
@@ -534,18 +598,20 @@ class Photo(SourceNote):
|
|||||||
but provides a means for XML users to attach other properties to
|
but provides a means for XML users to attach other properties to
|
||||||
the image"""
|
the image"""
|
||||||
self.attrlist.append(attr)
|
self.attrlist.append(attr)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getAttributeList(self):
|
def getAttributeList(self):
|
||||||
"""returns the property list associated with the image"""
|
"""returns the property list associated with the image"""
|
||||||
return self.attrlist
|
return extlist(self.attrlist)
|
||||||
|
|
||||||
def setAttributeList(self,list):
|
def setAttributeList(self,list):
|
||||||
self.attrlist = list
|
self.attrlist = list
|
||||||
|
|
||||||
class ObjectRef:
|
|
||||||
|
class ObjectRef(Persistent):
|
||||||
"""Object reference class"""
|
"""Object reference class"""
|
||||||
def __init__(self,source=None):
|
def __init__(self,source=None):
|
||||||
self.attrlist = []
|
self.attrlist = PersistentList()
|
||||||
if source:
|
if source:
|
||||||
self.private = source.private
|
self.private = source.private
|
||||||
self.ref = source.ref
|
self.ref = source.ref
|
||||||
@@ -600,15 +666,17 @@ class ObjectRef:
|
|||||||
but provides a means for XML users to attach other properties to
|
but provides a means for XML users to attach other properties to
|
||||||
the image"""
|
the image"""
|
||||||
self.attrlist.append(attr)
|
self.attrlist.append(attr)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getAttributeList(self):
|
def getAttributeList(self):
|
||||||
"""returns the property list associated with the image"""
|
"""returns the property list associated with the image"""
|
||||||
return self.attrlist
|
return extlist(self.attrlist)
|
||||||
|
|
||||||
def setAttributeList(self,list):
|
def setAttributeList(self,list):
|
||||||
"""sets the property list associated with the image"""
|
"""sets the property list associated with the image"""
|
||||||
self.attrlist = list
|
self.attrlist = list
|
||||||
|
|
||||||
|
|
||||||
class Attribute(DataObj):
|
class Attribute(DataObj):
|
||||||
"""Provides a simple key/value pair for describing properties. Used
|
"""Provides a simple key/value pair for describing properties. Used
|
||||||
by the Person and Family objects to store descriptive information."""
|
by the Person and Family objects to store descriptive information."""
|
||||||
@@ -645,7 +713,8 @@ class Address(DataObj):
|
|||||||
"""Provides address information for a person"""
|
"""Provides address information for a person"""
|
||||||
|
|
||||||
def __init__(self,source=None):
|
def __init__(self,source=None):
|
||||||
"""Creates a new Address instance, copying from the source if provided"""
|
"""Creates a new Address instance, copying from the source
|
||||||
|
if provided"""
|
||||||
DataObj.__init__(self,source)
|
DataObj.__init__(self,source)
|
||||||
|
|
||||||
if source:
|
if source:
|
||||||
@@ -726,6 +795,7 @@ class Address(DataObj):
|
|||||||
"""returns the postal code of the Address"""
|
"""returns the postal code of the Address"""
|
||||||
return self.postal
|
return self.postal
|
||||||
|
|
||||||
|
|
||||||
class Name(DataObj):
|
class Name(DataObj):
|
||||||
"""Provides name information about a person. A person may have more
|
"""Provides name information about a person. A person may have more
|
||||||
that one name throughout his or her life."""
|
that one name throughout his or her life."""
|
||||||
@@ -788,8 +858,8 @@ class Name(DataObj):
|
|||||||
return self.Title
|
return self.Title
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
"""returns a name string built from the components of the Name instance,
|
"""returns a name string built from the components of the Name
|
||||||
in the form of Surname, Firstname"""
|
instance, in the form of Surname, Firstname"""
|
||||||
|
|
||||||
if (self.Suffix == ""):
|
if (self.Suffix == ""):
|
||||||
return "%s, %s" % (self.Surname, self.FirstName)
|
return "%s, %s" % (self.Surname, self.FirstName)
|
||||||
@@ -797,15 +867,16 @@ class Name(DataObj):
|
|||||||
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
|
return "%s, %s %s" % (self.Surname, self.FirstName, self.Suffix)
|
||||||
|
|
||||||
def getRegularName(self):
|
def getRegularName(self):
|
||||||
"""returns a name string built from the components of the Name instance,
|
"""returns a name string built from the components of the Name
|
||||||
in the form of Firstname Surname"""
|
instance, in the form of Firstname Surname"""
|
||||||
if (self.Suffix == ""):
|
if (self.Suffix == ""):
|
||||||
return "%s %s" % (self.FirstName, self.Surname)
|
return "%s %s" % (self.FirstName, self.Surname)
|
||||||
else:
|
else:
|
||||||
return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix)
|
return "%s %s, %s" % (self.FirstName, self.Surname, self.Suffix)
|
||||||
|
|
||||||
def are_equal(self,other):
|
def are_equal(self,other):
|
||||||
"""compares to names to see if they are equal, return 0 if they are not"""
|
"""compares to names to see if they are equal, return 0 if they
|
||||||
|
are not"""
|
||||||
if self.FirstName != other.FirstName:
|
if self.FirstName != other.FirstName:
|
||||||
return 0
|
return 0
|
||||||
if self.Surname != other.Surname:
|
if self.Surname != other.Surname:
|
||||||
@@ -828,10 +899,9 @@ class Name(DataObj):
|
|||||||
if not a.are_equal(olist[index]):
|
if not a.are_equal(olist[index]):
|
||||||
return 0
|
return 0
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
class Url:
|
class Url(Persistent):
|
||||||
"""Contains information related to internet Uniform Resource Locators,
|
"""Contains information related to internet Uniform Resource Locators,
|
||||||
allowing gramps to store information about internet resources"""
|
allowing gramps to store information about internet resources"""
|
||||||
|
|
||||||
@@ -880,7 +950,8 @@ class Url:
|
|||||||
return 0
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
class Person:
|
|
||||||
|
class Person(Persistent):
|
||||||
"""Represents an individual person in the gramps database"""
|
"""Represents an individual person in the gramps database"""
|
||||||
|
|
||||||
unknown = 2
|
unknown = 2
|
||||||
@@ -892,18 +963,18 @@ class Person:
|
|||||||
|
|
||||||
self.id = ""
|
self.id = ""
|
||||||
self.PrimaryName = None
|
self.PrimaryName = None
|
||||||
self.EventList = []
|
self.EventList = PersistentList()
|
||||||
self.FamilyList = []
|
self.FamilyList = PersistentList()
|
||||||
self.AltFamilyList = []
|
self.AltFamilyList = PersistentList()
|
||||||
self.photoList = []
|
self.photoList = PersistentList()
|
||||||
self.nickname = ""
|
self.nickname = ""
|
||||||
self.alternateNames = []
|
self.alternateNames = PersistentList()
|
||||||
self.gender = 2
|
self.gender = 2
|
||||||
self.death = None
|
self.death = None
|
||||||
self.birth = None
|
self.birth = None
|
||||||
self.addressList = []
|
self.addressList = PersistentList()
|
||||||
self.attributeList = []
|
self.attributeList = PersistentList()
|
||||||
self.urls = []
|
self.urls = PersistentList()
|
||||||
self.note = None
|
self.note = None
|
||||||
self.paf_uid = ""
|
self.paf_uid = ""
|
||||||
self.position = None
|
self.position = None
|
||||||
@@ -912,8 +983,23 @@ class Person:
|
|||||||
self.lds_endow = None
|
self.lds_endow = None
|
||||||
self.lds_seal = None
|
self.lds_seal = None
|
||||||
|
|
||||||
|
def getDisplayInfo(self):
|
||||||
|
if self.gender == Person.male:
|
||||||
|
gender = const.male
|
||||||
|
elif self.gender == Person.female:
|
||||||
|
gender = const.female
|
||||||
|
else:
|
||||||
|
gender = const.unknown
|
||||||
|
bday = self.getBirth().getDateObj()
|
||||||
|
dday = self.getDeath().getDateObj()
|
||||||
|
return [self.PrimaryName.getName(),self.id,gender,bday.getQuoteDate(),
|
||||||
|
dday.getQuoteDate(),sort.build_sort_name(self.PrimaryName),
|
||||||
|
sort.build_sort_date(bday),sort.build_sort_date(dday)]
|
||||||
|
|
||||||
|
|
||||||
def setPrimaryName(self,name):
|
def setPrimaryName(self,name):
|
||||||
"""sets the primary name of the Person to the specified Name instance"""
|
"""sets the primary name of the Person to the specified
|
||||||
|
Name instance"""
|
||||||
self.PrimaryName = name
|
self.PrimaryName = name
|
||||||
|
|
||||||
def getPrimaryName(self):
|
def getPrimaryName(self):
|
||||||
@@ -932,7 +1018,7 @@ class Person:
|
|||||||
|
|
||||||
def getAlternateNames(self):
|
def getAlternateNames(self):
|
||||||
"""returns the list of alternate Names"""
|
"""returns the list of alternate Names"""
|
||||||
return self.alternateNames
|
return extlist(self.alternateNames)
|
||||||
|
|
||||||
def setAlternateNames(self,list):
|
def setAlternateNames(self,list):
|
||||||
"""changes the list of alternate names to the passed list"""
|
"""changes the list of alternate names to the passed list"""
|
||||||
@@ -941,10 +1027,11 @@ class Person:
|
|||||||
def addAlternateName(self,name):
|
def addAlternateName(self,name):
|
||||||
"""adds an alternate Name instance to the list"""
|
"""adds an alternate Name instance to the list"""
|
||||||
self.alternateNames.append(name)
|
self.alternateNames.append(name)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getUrlList(self):
|
def getUrlList(self):
|
||||||
"""returns the list of URL instances"""
|
"""returns the list of URL instances"""
|
||||||
return self.urls
|
return extlist(self.urls)
|
||||||
|
|
||||||
def setUrlList(self,list):
|
def setUrlList(self,list):
|
||||||
"""sets the list of URL instances to list"""
|
"""sets the list of URL instances to list"""
|
||||||
@@ -953,6 +1040,7 @@ class Person:
|
|||||||
def addUrl(self,url):
|
def addUrl(self,url):
|
||||||
"""adds a URL instance to the list"""
|
"""adds a URL instance to the list"""
|
||||||
self.urls.append(url)
|
self.urls.append(url)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def setId(self,id):
|
def setId(self,id):
|
||||||
"""sets the gramps ID for the Person"""
|
"""sets the gramps ID for the Person"""
|
||||||
@@ -1003,10 +1091,11 @@ class Person:
|
|||||||
def addPhoto(self,photo):
|
def addPhoto(self,photo):
|
||||||
"""adds a Photo instance to the image list"""
|
"""adds a Photo instance to the image list"""
|
||||||
self.photoList.append(photo)
|
self.photoList.append(photo)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getPhotoList(self):
|
def getPhotoList(self):
|
||||||
"""returns the list of Photos"""
|
"""returns the list of Photos"""
|
||||||
return self.photoList
|
return extlist(self.photoList)
|
||||||
|
|
||||||
def setPhotoList(self,list):
|
def setPhotoList(self,list):
|
||||||
"""Sets the list of Photo objects"""
|
"""Sets the list of Photo objects"""
|
||||||
@@ -1015,10 +1104,11 @@ class Person:
|
|||||||
def addEvent(self,event):
|
def addEvent(self,event):
|
||||||
"""adds an Event to the event list"""
|
"""adds an Event to the event list"""
|
||||||
self.EventList.append(event)
|
self.EventList.append(event)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getEventList(self):
|
def getEventList(self):
|
||||||
"""returns the list of Event instances"""
|
"""returns the list of Event instances"""
|
||||||
return self.EventList
|
return extlist(self.EventList)
|
||||||
|
|
||||||
def setEventList(self,list):
|
def setEventList(self,list):
|
||||||
"""sets the event list to the passed list"""
|
"""sets the event list to the passed list"""
|
||||||
@@ -1029,6 +1119,7 @@ class Person:
|
|||||||
families/marriages/partnerships in which the person is a
|
families/marriages/partnerships in which the person is a
|
||||||
parent or spouse"""
|
parent or spouse"""
|
||||||
self.FamilyList.append(family)
|
self.FamilyList.append(family)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def setPreferred(self,family):
|
def setPreferred(self,family):
|
||||||
if family in self.FamilyList:
|
if family in self.FamilyList:
|
||||||
@@ -1038,26 +1129,32 @@ class Person:
|
|||||||
def getFamilyList(self) :
|
def getFamilyList(self) :
|
||||||
"""returns the list of Family instances in which the
|
"""returns the list of Family instances in which the
|
||||||
person is a parent or spouse"""
|
person is a parent or spouse"""
|
||||||
return self.FamilyList
|
return extlist(self.FamilyList)
|
||||||
|
|
||||||
|
def clearFamilyList(self) :
|
||||||
|
self.FamilyList = PersistentList()
|
||||||
|
|
||||||
def removeFamily(self,family):
|
def removeFamily(self,family):
|
||||||
"""removes the specified Family instance from the list
|
"""removes the specified Family instance from the list
|
||||||
of marriages/partnerships"""
|
of marriages/partnerships"""
|
||||||
if family in self.FamilyList:
|
if family in self.FamilyList:
|
||||||
self.FamilyList.remove(family)
|
self.FamilyList.remove(family)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def addAddress(self,address):
|
def addAddress(self,address):
|
||||||
"""adds the Address instance to the list of addresses"""
|
"""adds the Address instance to the list of addresses"""
|
||||||
self.addressList.append(address)
|
self.addressList.append(address)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def removeAddress(self,address):
|
def removeAddress(self,address):
|
||||||
"""removes the Address instance from the list of addresses"""
|
"""removes the Address instance from the list of addresses"""
|
||||||
for address in self.addressList:
|
if address in self.addressList:
|
||||||
self.addressList.remove(address)
|
self.addressList.remove(address)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getAddressList(self):
|
def getAddressList(self):
|
||||||
"""returns the list of addresses"""
|
"""returns the list of addresses"""
|
||||||
return self.addressList
|
return extlist(self.addressList)
|
||||||
|
|
||||||
def setAddressList(self,list):
|
def setAddressList(self,list):
|
||||||
"""sets the address list to the specified list"""
|
"""sets the address list to the specified list"""
|
||||||
@@ -1066,15 +1163,17 @@ class Person:
|
|||||||
def addAttribute(self,attribute):
|
def addAttribute(self,attribute):
|
||||||
"""adds an Attribute instance to the attribute list"""
|
"""adds an Attribute instance to the attribute list"""
|
||||||
self.attributeList.append(attribute)
|
self.attributeList.append(attribute)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def removeAttribute(self,attribute):
|
def removeAttribute(self,attribute):
|
||||||
"""removes the specified Attribute instance from the attribute list"""
|
"""removes the specified Attribute instance from the attribute list"""
|
||||||
for attribute in self.attributeList:
|
if attribute in self.attributeList:
|
||||||
self.attributeList.remove(attribute)
|
self.attributeList.remove(attribute)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getAttributeList(self):
|
def getAttributeList(self):
|
||||||
"""returns the attribute list"""
|
"""returns the attribute list"""
|
||||||
return self.attributeList
|
return extlist(self.attributeList)
|
||||||
|
|
||||||
def setAttributeList(self,list):
|
def setAttributeList(self,list):
|
||||||
"""sets the attribute list to the specified list"""
|
"""sets the attribute list to the specified list"""
|
||||||
@@ -1083,18 +1182,22 @@ class Person:
|
|||||||
def getParentList(self):
|
def getParentList(self):
|
||||||
"""returns the list of alternate Family instances, in which the Person
|
"""returns the list of alternate Family instances, in which the Person
|
||||||
is a child of the family, but not a natural child of both parents"""
|
is a child of the family, but not a natural child of both parents"""
|
||||||
return self.AltFamilyList
|
return extlist(self.AltFamilyList)
|
||||||
|
|
||||||
def addAltFamily(self,family,mrel,frel):
|
def addAltFamily(self,family,mrel,frel):
|
||||||
"""adds a Family to the alternate family list, indicating the
|
"""adds a Family to the alternate family list, indicating the
|
||||||
relationship to the mother (mrel) and the father (frel)"""
|
relationship to the mother (mrel) and the father (frel)"""
|
||||||
self.AltFamilyList.append((family,mrel,frel))
|
self.AltFamilyList.append((family,mrel,frel))
|
||||||
|
|
||||||
|
def clearAltFamilyList(self):
|
||||||
|
self.AltFamilyList = PersistentList()
|
||||||
|
|
||||||
def removeAltFamily(self,family):
|
def removeAltFamily(self,family):
|
||||||
"""removes a Family instance from the alternate family list"""
|
"""removes a Family instance from the alternate family list"""
|
||||||
for f in self.AltFamilyList[:]:
|
for f in self.AltFamilyList[:]:
|
||||||
if f[0] == family:
|
if f[0] == family:
|
||||||
self.AltFamilyList.remove(f)
|
self.AltFamilyList.remove(f)
|
||||||
|
self._p_changed = 1
|
||||||
return f
|
return f
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
@@ -1170,10 +1273,10 @@ class Person:
|
|||||||
if family.Father:
|
if family.Father:
|
||||||
# Don't waste time if the ancestor is already flagged.
|
# Don't waste time if the ancestor is already flagged.
|
||||||
# This will happen when cousins marry.
|
# This will happen when cousins marry.
|
||||||
if not family.Father.ancestor:
|
if not family.Father.getAncestor():
|
||||||
family.Father.setAncestor(value)
|
family.Father.setAncestor(value)
|
||||||
if family.Mother:
|
if family.getMother():
|
||||||
if not family.Mother.ancestor:
|
if not family.Mother.getAncestor():
|
||||||
family.Mother.setAncestor(value)
|
family.Mother.setAncestor(value)
|
||||||
|
|
||||||
def getAncestor(self):
|
def getAncestor(self):
|
||||||
@@ -1330,22 +1433,23 @@ class Event(DataObj):
|
|||||||
"""sets the Date object associated with the Event"""
|
"""sets the Date object associated with the Event"""
|
||||||
self.date = date
|
self.date = date
|
||||||
|
|
||||||
class Family:
|
|
||||||
|
class Family(Persistent):
|
||||||
"""Represents a family unit in the gramps database"""
|
"""Represents a family unit in the gramps database"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""creates a new Family instance"""
|
"""creates a new Family instance"""
|
||||||
self.Father = None
|
self.Father = None
|
||||||
self.Mother = None
|
self.Mother = None
|
||||||
self.Children = []
|
self.Children = PersistentList()
|
||||||
self.Marriage = None
|
self.Marriage = None
|
||||||
self.Divorce = None
|
self.Divorce = None
|
||||||
self.type = "Married"
|
self.type = "Married"
|
||||||
self.EventList = []
|
self.EventList = PersistentList()
|
||||||
self.id = ""
|
self.id = ""
|
||||||
self.photoList = []
|
self.photoList = PersistentList()
|
||||||
self.note = Note()
|
self.note = Note()
|
||||||
self.attributeList = []
|
self.attributeList = PersistentList()
|
||||||
self.position = None
|
self.position = None
|
||||||
self.lds_seal = None
|
self.lds_seal = None
|
||||||
|
|
||||||
@@ -1366,15 +1470,17 @@ class Family:
|
|||||||
def addAttribute(self,attribute) :
|
def addAttribute(self,attribute) :
|
||||||
"""adds an Attribute instance to the attribute list"""
|
"""adds an Attribute instance to the attribute list"""
|
||||||
self.attributeList.append(attribute)
|
self.attributeList.append(attribute)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def removeAttribute(self,attribute):
|
def removeAttribute(self,attribute):
|
||||||
"""removes the specified Attribute instance from the attribute list"""
|
"""removes the specified Attribute instance from the attribute list"""
|
||||||
for attribute in self.attributeList:
|
if attribute in self.attributeList:
|
||||||
self.attributeList.remove(attribute)
|
self.attributeList.remove(attribute)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getAttributeList(self) :
|
def getAttributeList(self) :
|
||||||
"""returns the attribute list"""
|
"""returns the attribute list"""
|
||||||
return self.attributeList
|
return extlist(self.attributeList)
|
||||||
|
|
||||||
def setAttributeList(self,list) :
|
def setAttributeList(self,list) :
|
||||||
"""sets the attribute list to the specified list"""
|
"""sets the attribute list to the specified list"""
|
||||||
@@ -1448,7 +1554,8 @@ class Family:
|
|||||||
to the child list"""
|
to the child list"""
|
||||||
if person not in self.Children:
|
if person not in self.Children:
|
||||||
self.Children.append(person)
|
self.Children.append(person)
|
||||||
if person.ancestor:
|
self._p_changed = 1
|
||||||
|
if person.getAncestor():
|
||||||
if self.Father:
|
if self.Father:
|
||||||
self.Father.setAncestor(1)
|
self.Father.setAncestor(1)
|
||||||
if self.Mother:
|
if self.Mother:
|
||||||
@@ -1458,7 +1565,8 @@ class Family:
|
|||||||
"""removes the specified Person from the child list"""
|
"""removes the specified Person from the child list"""
|
||||||
if person in self.Children:
|
if person in self.Children:
|
||||||
self.Children.remove(person)
|
self.Children.remove(person)
|
||||||
if person.ancestor:
|
self._p_changed = 1
|
||||||
|
if person.getAncestor():
|
||||||
if self.Father:
|
if self.Father:
|
||||||
self.Father.setAncestor(0)
|
self.Father.setAncestor(0)
|
||||||
if self.Mother:
|
if self.Mother:
|
||||||
@@ -1466,7 +1574,7 @@ class Family:
|
|||||||
|
|
||||||
def getChildList(self):
|
def getChildList(self):
|
||||||
"""returns the list of children"""
|
"""returns the list of children"""
|
||||||
return self.Children
|
return extlist(self.Children)
|
||||||
|
|
||||||
def setChildList(self, list):
|
def setChildList(self, list):
|
||||||
"""sets the list of children"""
|
"""sets the list of children"""
|
||||||
@@ -1489,10 +1597,11 @@ class Family:
|
|||||||
def addEvent(self,event):
|
def addEvent(self,event):
|
||||||
"""adds an Event to the event list"""
|
"""adds an Event to the event list"""
|
||||||
self.EventList.append(event)
|
self.EventList.append(event)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getEventList(self) :
|
def getEventList(self) :
|
||||||
"""returns the list of Event instances"""
|
"""returns the list of Event instances"""
|
||||||
return self.EventList
|
return extlist(self.EventList)
|
||||||
|
|
||||||
def setEventList(self,list) :
|
def setEventList(self,list) :
|
||||||
"""sets the event list to the passed list"""
|
"""sets the event list to the passed list"""
|
||||||
@@ -1501,22 +1610,26 @@ class Family:
|
|||||||
def addPhoto(self,photo):
|
def addPhoto(self,photo):
|
||||||
"""Adds a Photo object to the Family instance's image list"""
|
"""Adds a Photo object to the Family instance's image list"""
|
||||||
self.photoList.append(photo)
|
self.photoList.append(photo)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getPhotoList(self):
|
def getPhotoList(self):
|
||||||
"""Returns the list of Photo objects"""
|
"""Returns the list of Photo objects"""
|
||||||
return self.photoList
|
return extlist(self.photoList)
|
||||||
|
|
||||||
def setPhotoList(self,list):
|
def setPhotoList(self,list):
|
||||||
"""Sets the list of Photo objects"""
|
"""Sets the list of Photo objects"""
|
||||||
self.photoList = list
|
self.photoList = list
|
||||||
|
|
||||||
|
def unique_note(self):
|
||||||
|
self.note = Note(self.note.get())
|
||||||
|
|
||||||
def someChildIsAncestor(self):
|
def someChildIsAncestor(self):
|
||||||
for child in self.Children:
|
for child in self.Children:
|
||||||
if (child.ancestor):
|
if (child.getAncestor()):
|
||||||
return 1
|
return 1
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Source:
|
class Source(Persistent):
|
||||||
"""A record of a source of information"""
|
"""A record of a source of information"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -1526,9 +1639,13 @@ class Source:
|
|||||||
self.pubinfo = ""
|
self.pubinfo = ""
|
||||||
self.callno = ""
|
self.callno = ""
|
||||||
self.note = Note()
|
self.note = Note()
|
||||||
self.photoList = []
|
self.photoList = PersistentList()
|
||||||
self.id = ""
|
self.id = ""
|
||||||
|
|
||||||
|
def getDisplayInfo(self):
|
||||||
|
return [self.title,self.id,self.author,upper(self.title),
|
||||||
|
upper(self.author)]
|
||||||
|
|
||||||
def setId(self,newId):
|
def setId(self,newId):
|
||||||
"""sets the gramps' ID for the Source instance"""
|
"""sets the gramps' ID for the Source instance"""
|
||||||
self.id = str(newId)
|
self.id = str(newId)
|
||||||
@@ -1540,10 +1657,11 @@ class Source:
|
|||||||
def addPhoto(self,photo):
|
def addPhoto(self,photo):
|
||||||
"""Adds a Photo object to the Source instance's image list"""
|
"""Adds a Photo object to the Source instance's image list"""
|
||||||
self.photoList.append(photo)
|
self.photoList.append(photo)
|
||||||
|
self._p_changed = 1
|
||||||
|
|
||||||
def getPhotoList(self):
|
def getPhotoList(self):
|
||||||
"""Returns the list of Photo objects"""
|
"""Returns the list of Photo objects"""
|
||||||
return self.photoList
|
return extlist(self.photoList)
|
||||||
|
|
||||||
def setPhotoList(self,list):
|
def setPhotoList(self,list):
|
||||||
"""Sets the list of Photo objects"""
|
"""Sets the list of Photo objects"""
|
||||||
@@ -1602,7 +1720,7 @@ class Source:
|
|||||||
of the Source"""
|
of the Source"""
|
||||||
return self.callno
|
return self.callno
|
||||||
|
|
||||||
class SourceRef:
|
class SourceRef(Persistent):
|
||||||
"""Source reference, containing detailed information about how a
|
"""Source reference, containing detailed information about how a
|
||||||
referenced source relates to it"""
|
referenced source relates to it"""
|
||||||
|
|
||||||
@@ -1699,11 +1817,15 @@ class SourceRef:
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class GrampsDB:
|
class GrampsDB(Persistent):
|
||||||
"""Gramps database object"""
|
"""Gramps database object"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""creates a new GrampsDB"""
|
"""creates a new GrampsDB"""
|
||||||
|
self.surnames = PersistentList()
|
||||||
|
self.personTable = {}
|
||||||
|
self.placeTable = {}
|
||||||
|
self.sourceTable = {}
|
||||||
self.iprefix = "I%d"
|
self.iprefix = "I%d"
|
||||||
self.sprefix = "S%d"
|
self.sprefix = "S%d"
|
||||||
self.oprefix = "O%d"
|
self.oprefix = "O%d"
|
||||||
@@ -1715,6 +1837,18 @@ class GrampsDB:
|
|||||||
self.placeMap = {}
|
self.placeMap = {}
|
||||||
self.new()
|
self.new()
|
||||||
|
|
||||||
|
def get_base(self):
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def need_autosave(self):
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def getPersonKeys(self):
|
||||||
|
return self.personTable.keys()
|
||||||
|
|
||||||
|
def getPersonDisplay(self,key):
|
||||||
|
return self.personTable[key]
|
||||||
|
|
||||||
def set_iprefix(self,val):
|
def set_iprefix(self,val):
|
||||||
if _id_reg.search(val):
|
if _id_reg.search(val):
|
||||||
self.iprefix = val
|
self.iprefix = val
|
||||||
@@ -1756,10 +1890,11 @@ class GrampsDB:
|
|||||||
self.familyMap = {}
|
self.familyMap = {}
|
||||||
|
|
||||||
for p in self.personMap.values():
|
for p in self.personMap.values():
|
||||||
p.AltFamilyList = []
|
p.clearAltFamilyList()
|
||||||
p.FamilyList = []
|
p.clearFamilyList()
|
||||||
self.personMap = {}
|
|
||||||
|
|
||||||
|
self.surnames = PersistentList()
|
||||||
|
self.personMap = {}
|
||||||
self.sourceMap = {}
|
self.sourceMap = {}
|
||||||
self.placeMap = {}
|
self.placeMap = {}
|
||||||
self.objectMap = {}
|
self.objectMap = {}
|
||||||
@@ -1770,13 +1905,21 @@ class GrampsDB:
|
|||||||
self.omapIndex = 0
|
self.omapIndex = 0
|
||||||
self.default = None
|
self.default = None
|
||||||
self.owner = Researcher()
|
self.owner = Researcher()
|
||||||
self.bookmarks = []
|
self.bookmarks = PersistentList()
|
||||||
self.path = ""
|
self.path = ""
|
||||||
self.place2title = {}
|
self.place2title = {}
|
||||||
|
|
||||||
|
def getSurnames(self):
|
||||||
|
return self.surnames
|
||||||
|
|
||||||
|
def addSurname(self,name):
|
||||||
|
if name and name not in self.surnames:
|
||||||
|
self.surnames.append(name)
|
||||||
|
self.surnames.sort()
|
||||||
|
|
||||||
def getBookmarks(self):
|
def getBookmarks(self):
|
||||||
"""returns the list of Person instances in the bookmarks"""
|
"""returns the list of Person instances in the bookmarks"""
|
||||||
return self.bookmarks
|
return extlist(self.bookmarks)
|
||||||
|
|
||||||
def clean_bookmarks(self):
|
def clean_bookmarks(self):
|
||||||
"""cleans up the bookmark list, removing empty slots"""
|
"""cleans up the bookmark list, removing empty slots"""
|
||||||
@@ -1809,7 +1952,7 @@ class GrampsDB:
|
|||||||
|
|
||||||
def getPersonMap(self):
|
def getPersonMap(self):
|
||||||
"""returns a map of gramps's IDs to Person instances"""
|
"""returns a map of gramps's IDs to Person instances"""
|
||||||
return self.personMap
|
return extmap(self.personMap)
|
||||||
|
|
||||||
def setPersonMap(self,map):
|
def setPersonMap(self,map):
|
||||||
"""sets the map of gramps's IDs to Person instances"""
|
"""sets the map of gramps's IDs to Person instances"""
|
||||||
@@ -1817,7 +1960,7 @@ class GrampsDB:
|
|||||||
|
|
||||||
def getPlaceMap(self):
|
def getPlaceMap(self):
|
||||||
"""returns a map of gramps's IDs to Place instances"""
|
"""returns a map of gramps's IDs to Place instances"""
|
||||||
return self.placeMap
|
return extmap(self.placeMap)
|
||||||
|
|
||||||
def setPlaceMap(self,map):
|
def setPlaceMap(self,map):
|
||||||
"""sets the map of gramps's IDs to Place instances"""
|
"""sets the map of gramps's IDs to Place instances"""
|
||||||
@@ -1825,7 +1968,7 @@ class GrampsDB:
|
|||||||
|
|
||||||
def getFamilyMap(self):
|
def getFamilyMap(self):
|
||||||
"""returns a map of gramps's IDs to Family instances"""
|
"""returns a map of gramps's IDs to Family instances"""
|
||||||
return self.familyMap
|
return extmap(self.familyMap)
|
||||||
|
|
||||||
def setFamilyMap(self,map):
|
def setFamilyMap(self,map):
|
||||||
"""sets the map of gramps's IDs to Family instances"""
|
"""sets the map of gramps's IDs to Family instances"""
|
||||||
@@ -1833,7 +1976,8 @@ class GrampsDB:
|
|||||||
|
|
||||||
def getSourceMap(self):
|
def getSourceMap(self):
|
||||||
"""returns a map of gramps's IDs to Source instances"""
|
"""returns a map of gramps's IDs to Source instances"""
|
||||||
return self.sourceMap
|
return extmap(self.sourceMap)
|
||||||
|
|
||||||
|
|
||||||
def getObjectMap(self):
|
def getObjectMap(self):
|
||||||
"""returns a map of gramps's IDs to Object instances"""
|
"""returns a map of gramps's IDs to Object instances"""
|
||||||
@@ -1895,6 +2039,12 @@ class GrampsDB:
|
|||||||
map[family.getRelationship()] = 1
|
map[family.getRelationship()] = 1
|
||||||
return map.keys()
|
return map.keys()
|
||||||
|
|
||||||
|
def removePerson(self,id):
|
||||||
|
del self.personMap[id]
|
||||||
|
|
||||||
|
def addPersonAs(self,person):
|
||||||
|
self.personMap[person.getId()] = person
|
||||||
|
|
||||||
def addPerson(self,person):
|
def addPerson(self,person):
|
||||||
"""adds a Person to the database, assigning a gramps' ID"""
|
"""adds a Person to the database, assigning a gramps' ID"""
|
||||||
index = self.iprefix % self.pmapIndex
|
index = self.iprefix % self.pmapIndex
|
||||||
@@ -2054,6 +2204,12 @@ class GrampsDB:
|
|||||||
self.lmapIndex = self.lmapIndex + 1
|
self.lmapIndex = self.lmapIndex + 1
|
||||||
return index
|
return index
|
||||||
|
|
||||||
|
def removePlace(self,id):
|
||||||
|
del self.placeMap[id]
|
||||||
|
|
||||||
|
def addPlaceAs(self,place):
|
||||||
|
self.placeMap[place.getId()] = place
|
||||||
|
|
||||||
def findPlace(self,idVal,map):
|
def findPlace(self,idVal,map):
|
||||||
"""finds a Place in the database using the idVal and map
|
"""finds a Place in the database using the idVal and map
|
||||||
variables to translate between the external ID and gramps'
|
variables to translate between the external ID and gramps'
|
||||||
@@ -2092,6 +2248,18 @@ class GrampsDB:
|
|||||||
self.lmapIndex = self.lmapIndex + 1
|
self.lmapIndex = self.lmapIndex + 1
|
||||||
return place
|
return place
|
||||||
|
|
||||||
|
def getPlaceKeys(self):
|
||||||
|
return self.placeTable.keys()
|
||||||
|
|
||||||
|
def getPlaceDisplay(self,key):
|
||||||
|
return self.placeTable[key]
|
||||||
|
|
||||||
|
def getSourceKeys(self):
|
||||||
|
return self.sourceTable.keys()
|
||||||
|
|
||||||
|
def getSourceDisplay(self,key):
|
||||||
|
return self.sourceTable[key]
|
||||||
|
|
||||||
def newFamily(self):
|
def newFamily(self):
|
||||||
"""adds a Family to the database, assigning a gramps' ID"""
|
"""adds a Family to the database, assigning a gramps' ID"""
|
||||||
index = self.fprefix % self.fmapIndex
|
index = self.fprefix % self.fmapIndex
|
||||||
|
@@ -244,7 +244,7 @@ class NewChild:
|
|||||||
self.surname = self.xml.get_widget("surname")
|
self.surname = self.xml.get_widget("surname")
|
||||||
self.given = self.xml.get_widget("childGiven")
|
self.given = self.xml.get_widget("childGiven")
|
||||||
if GrampsCfg.autocomp:
|
if GrampsCfg.autocomp:
|
||||||
self.comp = AutoComp.AutoEntry(self.surname,const.surnames)
|
self.comp = AutoComp.AutoEntry(self.surname,self.db.getSurnames())
|
||||||
|
|
||||||
self.surname.set_text(self.update_surname(2))
|
self.surname.set_text(self.update_surname(2))
|
||||||
|
|
||||||
|
@@ -71,13 +71,16 @@ class SourceView:
|
|||||||
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
|
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
|
||||||
self.source_list.connect('click-column',self.click_column)
|
self.source_list.connect('click-column',self.click_column)
|
||||||
|
|
||||||
self.sort_col,self.sort_dir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING)
|
self.scol,self.sdir = GrampsCfg.get_sort_cols("source",3,GTK.SORT_ASCENDING)
|
||||||
if self.sort_col >= len(self.sort_arrow):
|
if self.scol >= len(self.sort_arrow):
|
||||||
self.sort_col = 0
|
self.scol = 0
|
||||||
|
|
||||||
self.source_list.set_sort_type(self.sort_dir)
|
self.source_list.set_sort_type(self.sdir)
|
||||||
self.source_list.set_sort_column(self.sort_map[self.sort_col])
|
self.source_list.set_sort_column(self.sort_map[self.scol])
|
||||||
self.set_arrow(self.sort_col)
|
self.set_arrow(self.scol)
|
||||||
|
|
||||||
|
def change_db(self,db):
|
||||||
|
self.db = db
|
||||||
|
|
||||||
def moveto(self,row):
|
def moveto(self,row):
|
||||||
self.source_list.unselect_all()
|
self.source_list.unselect_all()
|
||||||
@@ -91,7 +94,7 @@ class SourceView:
|
|||||||
|
|
||||||
a = self.sort_arrow[column]
|
a = self.sort_arrow[column]
|
||||||
a.show()
|
a.show()
|
||||||
if self.sort_dir == GTK.SORT_ASCENDING:
|
if self.sdir == GTK.SORT_ASCENDING:
|
||||||
a.set(GTK.ARROW_DOWN,2)
|
a.set(GTK.ARROW_DOWN,2)
|
||||||
else:
|
else:
|
||||||
a.set(GTK.ARROW_UP,2)
|
a.set(GTK.ARROW_UP,2)
|
||||||
@@ -107,20 +110,20 @@ class SourceView:
|
|||||||
data = obj.get_row_data(obj.selection[0])
|
data = obj.get_row_data(obj.selection[0])
|
||||||
|
|
||||||
obj.freeze()
|
obj.freeze()
|
||||||
if new_col == self.sort_col:
|
if new_col == self.scol:
|
||||||
if self.sort_dir == GTK.SORT_ASCENDING:
|
if self.sdir == GTK.SORT_ASCENDING:
|
||||||
self.sort_dir = GTK.SORT_DESCENDING
|
self.sdir = GTK.SORT_DESCENDING
|
||||||
else:
|
else:
|
||||||
self.sort_dir = GTK.SORT_ASCENDING
|
self.sdir = GTK.SORT_ASCENDING
|
||||||
else:
|
else:
|
||||||
self.sort_dir = GTK.SORT_ASCENDING
|
self.sdir = GTK.SORT_ASCENDING
|
||||||
|
|
||||||
self.set_arrow(column)
|
self.set_arrow(column)
|
||||||
|
|
||||||
obj.set_sort_type(self.sort_dir)
|
obj.set_sort_type(self.sdir)
|
||||||
obj.set_sort_column(new_col)
|
obj.set_sort_column(new_col)
|
||||||
self.sort_col = new_col
|
self.scol = new_col
|
||||||
GrampsCfg.save_sort_cols("source",self.sort_col,self.sort_dir)
|
GrampsCfg.save_sort_cols("source",self.scol,self.sdir)
|
||||||
obj.sort()
|
obj.sort()
|
||||||
if data:
|
if data:
|
||||||
row = obj.find_row_from_data(data)
|
row = obj.find_row_from_data(data)
|
||||||
@@ -139,13 +142,9 @@ class SourceView:
|
|||||||
self.source_list.set_column_visibility(1,GrampsCfg.id_visible)
|
self.source_list.set_column_visibility(1,GrampsCfg.id_visible)
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
for src in self.db.getSourceMap().values():
|
for key in self.db.getSourceKeys():
|
||||||
id = src.getId()
|
src = self.db.getSourceMap()[key]
|
||||||
title = src.getTitle()
|
self.source_list.append(src.getDisplayInfo())
|
||||||
author = src.getAuthor()
|
|
||||||
stitle = string.upper(title)
|
|
||||||
sauthor = string.upper(author)
|
|
||||||
self.source_list.append([title,id,author,stitle,sauthor])
|
|
||||||
self.source_list.set_row_data(index,src)
|
self.source_list.set_row_data(index,src)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
|
||||||
@@ -156,17 +155,18 @@ class SourceView:
|
|||||||
self.source_list.sort()
|
self.source_list.sort()
|
||||||
self.source_list.thaw()
|
self.source_list.thaw()
|
||||||
|
|
||||||
def on_button_press_event(self,obj,event):
|
def button_press(self,obj,event):
|
||||||
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
||||||
if len(obj.selection) > 0:
|
if len(obj.selection) > 0:
|
||||||
index = obj.selection[0]
|
index = obj.selection[0]
|
||||||
source = obj.get_row_data(index)
|
source = obj.get_row_data(index)
|
||||||
EditSource.EditSource(source,self.db,self.update_display_after_edit)
|
EditSource.EditSource(source,self.db,
|
||||||
|
self.update_display_after_edit)
|
||||||
|
|
||||||
def on_add_source_clicked(self,obj):
|
def on_add_source_clicked(self,obj):
|
||||||
EditSource.EditSource(Source(),self.db,self.new_source_after_edit)
|
EditSource.EditSource(Source(),self.db,self.new_source_after_edit)
|
||||||
|
|
||||||
def on_delete_source_clicked(self,obj):
|
def on_delete_clicked(self,obj):
|
||||||
if len(obj.selection) == 0:
|
if len(obj.selection) == 0:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -228,7 +228,8 @@ class SourceView:
|
|||||||
if len(obj.selection) > 0:
|
if len(obj.selection) > 0:
|
||||||
index = obj.selection[0]
|
index = obj.selection[0]
|
||||||
source = obj.get_row_data(index)
|
source = obj.get_row_data(index)
|
||||||
EditSource.EditSource(source,self.db,self.update_display_after_edit)
|
EditSource.EditSource(source,self.db,
|
||||||
|
self.update_display_after_edit)
|
||||||
|
|
||||||
def new_source_after_edit(self,source):
|
def new_source_after_edit(self,source):
|
||||||
self.db.addSource(source)
|
self.db.addSource(source)
|
||||||
|
@@ -429,20 +429,6 @@ def thumb_path(dir,mobj):
|
|||||||
else:
|
else:
|
||||||
return find_icon(type)
|
return find_icon(type)
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Common setup code for a combo box for inputting a surname.
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def attach_surnames(combo):
|
|
||||||
if len(const.surnames) > 0:
|
|
||||||
# Surnames are always sorted
|
|
||||||
combo.set_popdown_strings(const.surnames)
|
|
||||||
combo.disable_activate()
|
|
||||||
combo.entry.set_text("")
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Sets up a delayed (0.005 sec) handler for text completion. Text
|
# Sets up a delayed (0.005 sec) handler for text completion. Text
|
||||||
|
@@ -157,14 +157,14 @@ class XmlWriter:
|
|||||||
date = string.split(time.ctime(time.time()))
|
date = string.split(time.ctime(time.time()))
|
||||||
owner = self.db.getResearcher()
|
owner = self.db.getResearcher()
|
||||||
personList = self.db.getPersonMap().values()
|
personList = self.db.getPersonMap().values()
|
||||||
personList.sort(sortById)
|
#personList.sort(sortById)
|
||||||
familyList = self.db.getFamilyMap().values()
|
familyList = self.db.getFamilyMap().values()
|
||||||
familyList.sort(sortById)
|
#familyList.sort(sortById)
|
||||||
sourceList = self.db.getSourceMap().values()
|
sourceList = self.db.getSourceMap().values()
|
||||||
placeList = self.db.getPlaceMap().values()
|
placeList = self.db.getPlaceMap().values()
|
||||||
placeList.sort(sortById)
|
#placeList.sort(sortById)
|
||||||
objList = self.db.getObjectMap().values()
|
objList = self.db.getObjectMap().values()
|
||||||
objList.sort(sortById)
|
#objList.sort(sortById)
|
||||||
|
|
||||||
total = len(personList) + len(familyList) + len(placeList) + len(sourceList)
|
total = len(personList) + len(familyList) + len(placeList) + len(sourceList)
|
||||||
|
|
||||||
|
@@ -106,7 +106,8 @@ comments = _("GRAMPS (Genealogical Research and Analysis "
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
picWidth = 275.0
|
picWidth = 275.0
|
||||||
thumbScale = 96.0
|
thumbScale = 96.0
|
||||||
indexFile = "data.gramps"
|
xmlFile = "data.gramps"
|
||||||
|
zodbFile = "gramps.zodb"
|
||||||
male = _("male")
|
male = _("male")
|
||||||
female = _("female")
|
female = _("female")
|
||||||
unknown = _("unknown")
|
unknown = _("unknown")
|
||||||
|
@@ -2364,7 +2364,7 @@
|
|||||||
</signal>
|
</signal>
|
||||||
<signal>
|
<signal>
|
||||||
<name>button_press_event</name>
|
<name>button_press_event</name>
|
||||||
<handler>on_child_list_button_press_event</handler>
|
<handler>on_child_list_button_press</handler>
|
||||||
<last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time>
|
<last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time>
|
||||||
</signal>
|
</signal>
|
||||||
<signal>
|
<signal>
|
||||||
@@ -2797,7 +2797,7 @@
|
|||||||
</signal>
|
</signal>
|
||||||
<signal>
|
<signal>
|
||||||
<name>button_press_event</name>
|
<name>button_press_event</name>
|
||||||
<handler>on_source_list_button_press_event</handler>
|
<handler>on_source_list_button_press</handler>
|
||||||
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
|
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
|
||||||
</signal>
|
</signal>
|
||||||
<columns>5</columns>
|
<columns>5</columns>
|
||||||
@@ -7428,7 +7428,24 @@ Unknown
|
|||||||
<name>new</name>
|
<name>new</name>
|
||||||
<border_width>5</border_width>
|
<border_width>5</border_width>
|
||||||
<can_focus>True</can_focus>
|
<can_focus>True</can_focus>
|
||||||
<label>Create a New Database</label>
|
<label>Create a New XML Database</label>
|
||||||
|
<active>False</active>
|
||||||
|
<draw_indicator>True</draw_indicator>
|
||||||
|
<group>open</group>
|
||||||
|
<child>
|
||||||
|
<padding>0</padding>
|
||||||
|
<expand>False</expand>
|
||||||
|
<fill>False</fill>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
|
||||||
|
<widget>
|
||||||
|
<class>GtkRadioButton</class>
|
||||||
|
<name>zodb</name>
|
||||||
|
<border_width>5</border_width>
|
||||||
|
<visible>False</visible>
|
||||||
|
<can_focus>True</can_focus>
|
||||||
|
<label>Create a New ZODB Database</label>
|
||||||
<active>False</active>
|
<active>False</active>
|
||||||
<draw_indicator>True</draw_indicator>
|
<draw_indicator>True</draw_indicator>
|
||||||
<group>open</group>
|
<group>open</group>
|
||||||
|
@@ -60,7 +60,6 @@ from MediaView import MediaView
|
|||||||
|
|
||||||
from QuestionDialog import QuestionDialog
|
from QuestionDialog import QuestionDialog
|
||||||
|
|
||||||
import ReadXML
|
|
||||||
import Filter
|
import Filter
|
||||||
import const
|
import const
|
||||||
import Plugins
|
import Plugins
|
||||||
@@ -73,7 +72,14 @@ import EditPerson
|
|||||||
import Marriage
|
import Marriage
|
||||||
import Find
|
import Find
|
||||||
import VersionControl
|
import VersionControl
|
||||||
import WriteXML
|
|
||||||
|
from GrampsXML import GrampsXML
|
||||||
|
try:
|
||||||
|
from GrampsZODB import GrampsZODB
|
||||||
|
USE_ZODB = 1
|
||||||
|
except:
|
||||||
|
USE_ZODB = 0
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -100,12 +106,11 @@ class Gramps:
|
|||||||
self.c_gender = 3
|
self.c_gender = 3
|
||||||
self.c_id = 2
|
self.c_id = 2
|
||||||
self.c_name = 1
|
self.c_name = 1
|
||||||
self.c_sort_col = self.c_birth_order
|
self.c_scol = self.c_birth_order
|
||||||
self.c_sort_dir = GTK.SORT_ASCENDING
|
self.c_sdir = GTK.SORT_ASCENDING
|
||||||
self.sort_col = 0
|
self.scol = 0
|
||||||
self.sort_dir = GTK.SORT_ASCENDING
|
self.sdir = GTK.SORT_ASCENDING
|
||||||
self.id2col = {}
|
self.id2col = {}
|
||||||
self.alt2col = {}
|
|
||||||
|
|
||||||
gtk.rc_parse(const.gtkrcFile)
|
gtk.rc_parse(const.gtkrcFile)
|
||||||
|
|
||||||
@@ -114,9 +119,12 @@ class Gramps:
|
|||||||
"This account is not meant for normal application use.")
|
"This account is not meant for normal application use.")
|
||||||
gnome.ui.GnomeWarningDialog(msg)
|
gnome.ui.GnomeWarningDialog(msg)
|
||||||
|
|
||||||
self.database = GrampsDB()
|
# This will never contain data - It will be replaced by either
|
||||||
|
# a GrampsXML or GrampsZODB
|
||||||
|
|
||||||
(self.sort_col,self.sort_dir) = GrampsCfg.get_sort_cols("person",self.sort_col,self.sort_dir)
|
self.db = GrampsDB()
|
||||||
|
|
||||||
|
(self.scol,self.sdir) = GrampsCfg.get_sort_cols("person",self.scol,self.sdir)
|
||||||
|
|
||||||
GrampsCfg.loadConfig(self.full_update)
|
GrampsCfg.loadConfig(self.full_update)
|
||||||
self.init_interface()
|
self.init_interface()
|
||||||
@@ -125,14 +133,14 @@ class Gramps:
|
|||||||
self.col_arr = [ self.nameArrow, self.idArrow, self.genderArrow,
|
self.col_arr = [ self.nameArrow, self.idArrow, self.genderArrow,
|
||||||
self.dateArrow, self.deathArrow]
|
self.dateArrow, self.deathArrow]
|
||||||
|
|
||||||
self.change_sort(self.sort_col,self.sort_dir==GTK.SORT_DESCENDING)
|
self.change_sort(self.scol,self.sdir==GTK.SORT_DESCENDING)
|
||||||
self.set_sort_arrow(self.sort_col,self.sort_dir)
|
self.set_sort_arrow(self.scol,self.sdir)
|
||||||
|
|
||||||
self.database.set_iprefix(GrampsCfg.iprefix)
|
self.db.set_iprefix(GrampsCfg.iprefix)
|
||||||
self.database.set_oprefix(GrampsCfg.oprefix)
|
self.db.set_oprefix(GrampsCfg.oprefix)
|
||||||
self.database.set_fprefix(GrampsCfg.fprefix)
|
self.db.set_fprefix(GrampsCfg.fprefix)
|
||||||
self.database.set_sprefix(GrampsCfg.sprefix)
|
self.db.set_sprefix(GrampsCfg.sprefix)
|
||||||
self.database.set_pprefix(GrampsCfg.pprefix)
|
self.db.set_pprefix(GrampsCfg.pprefix)
|
||||||
|
|
||||||
if arg != None:
|
if arg != None:
|
||||||
if string.upper(arg[-3:]) == "GED":
|
if string.upper(arg[-3:]) == "GED":
|
||||||
@@ -145,11 +153,11 @@ class Gramps:
|
|||||||
import DbPrompter
|
import DbPrompter
|
||||||
DbPrompter.DbPrompter(self,0)
|
DbPrompter.DbPrompter(self,0)
|
||||||
|
|
||||||
if GrampsCfg.autosave_int != 0:
|
if self.db.need_autosave() and GrampsCfg.autosave_int != 0:
|
||||||
Utils.enable_autosave(self.autosave_database,
|
Utils.enable_autosave(self.autosave_database,
|
||||||
GrampsCfg.autosave_int)
|
GrampsCfg.autosave_int)
|
||||||
|
|
||||||
self.database.setResearcher(GrampsCfg.get_researcher())
|
self.db.setResearcher(GrampsCfg.get_researcher())
|
||||||
|
|
||||||
def init_interface(self):
|
def init_interface(self):
|
||||||
"""Initializes the GLADE interface, and gets references to the
|
"""Initializes the GLADE interface, and gets references to the
|
||||||
@@ -214,9 +222,9 @@ class Gramps:
|
|||||||
self.statusbar,
|
self.statusbar,
|
||||||
self.change_active_person,
|
self.change_active_person,
|
||||||
self.load_person)
|
self.load_person)
|
||||||
self.place_view = PlaceView(self.database,self.gtop,self.update_display)
|
self.place_view = PlaceView(self.db,self.gtop,self.update_display)
|
||||||
self.source_view = SourceView(self.database,self.gtop,self.update_display)
|
self.source_view = SourceView(self.db,self.gtop,self.update_display)
|
||||||
self.media_view = MediaView(self.database,self.gtop,self.update_display)
|
self.media_view = MediaView(self.db,self.gtop,self.update_display)
|
||||||
|
|
||||||
self.gtop.signal_autoconnect({
|
self.gtop.signal_autoconnect({
|
||||||
"delete_event" : self.delete_event,
|
"delete_event" : self.delete_event,
|
||||||
@@ -237,7 +245,7 @@ class Gramps:
|
|||||||
"on_apply_filter_clicked" : self.on_apply_filter_clicked,
|
"on_apply_filter_clicked" : self.on_apply_filter_clicked,
|
||||||
"on_arrow_left_clicked" : self.pedigree_view.on_show_child_menu,
|
"on_arrow_left_clicked" : self.pedigree_view.on_show_child_menu,
|
||||||
"on_canvas1_event" : self.pedigree_view.on_canvas1_event,
|
"on_canvas1_event" : self.pedigree_view.on_canvas1_event,
|
||||||
"on_child_list_button_press_event" : self.on_child_list_button_press_event,
|
"on_child_list_button_press" : self.on_child_list_button_press,
|
||||||
"on_child_list_select_row" : self.on_child_list_select_row,
|
"on_child_list_select_row" : self.on_child_list_select_row,
|
||||||
"on_child_list_click_column" : self.on_child_list_click_column,
|
"on_child_list_click_column" : self.on_child_list_click_column,
|
||||||
"on_child_list_row_move" : self.on_child_list_row_move,
|
"on_child_list_row_move" : self.on_child_list_row_move,
|
||||||
@@ -246,9 +254,9 @@ class Gramps:
|
|||||||
"on_default_person_activate" : self.on_default_person_activate,
|
"on_default_person_activate" : self.on_default_person_activate,
|
||||||
"on_delete_parents_clicked" : self.on_delete_parents_clicked,
|
"on_delete_parents_clicked" : self.on_delete_parents_clicked,
|
||||||
"on_delete_person_clicked" : self.on_delete_person_clicked,
|
"on_delete_person_clicked" : self.on_delete_person_clicked,
|
||||||
"on_delete_place_clicked" : self.place_view.on_delete_place_clicked,
|
"on_delete_place_clicked" : self.place_view.on_delete_clicked,
|
||||||
"on_delete_source_clicked" : self.source_view.on_delete_source_clicked,
|
"on_delete_source_clicked" : self.source_view.on_delete_clicked,
|
||||||
"on_delete_media_clicked" : self.media_view.on_delete_media_clicked,
|
"on_delete_media_clicked" : self.media_view.on_delete_clicked,
|
||||||
"on_delete_sp_clicked" : self.on_delete_sp_clicked,
|
"on_delete_sp_clicked" : self.on_delete_sp_clicked,
|
||||||
"on_edit_active_person" : self.load_active_person,
|
"on_edit_active_person" : self.load_active_person,
|
||||||
"on_edit_selected_people" : self.load_selected_people,
|
"on_edit_selected_people" : self.load_selected_people,
|
||||||
@@ -294,7 +302,7 @@ class Gramps:
|
|||||||
"on_save_activate" : self.on_save_activate,
|
"on_save_activate" : self.on_save_activate,
|
||||||
"on_save_as_activate" : self.on_save_as_activate,
|
"on_save_as_activate" : self.on_save_as_activate,
|
||||||
"on_show_plugin_status" : self.on_show_plugin_status,
|
"on_show_plugin_status" : self.on_show_plugin_status,
|
||||||
"on_source_list_button_press_event" : self.source_view.on_button_press_event,
|
"on_source_list_button_press" : self.source_view.button_press,
|
||||||
"on_sources_activate" : self.on_sources_activate,
|
"on_sources_activate" : self.on_sources_activate,
|
||||||
"on_swap_clicked" : self.on_swap_clicked,
|
"on_swap_clicked" : self.on_swap_clicked,
|
||||||
"on_tools_clicked" : self.on_tools_clicked,
|
"on_tools_clicked" : self.on_tools_clicked,
|
||||||
@@ -337,16 +345,16 @@ class Gramps:
|
|||||||
"""Display the find box"""
|
"""Display the find box"""
|
||||||
if self.notebook.get_current_page() == 4:
|
if self.notebook.get_current_page() == 4:
|
||||||
Find.FindPlace(self.place_view.place_list,self.find_goto_place,
|
Find.FindPlace(self.place_view.place_list,self.find_goto_place,
|
||||||
self.database.getPlaceMap().values())
|
self.db.getPlaceMap().values())
|
||||||
elif self.notebook.get_current_page() == 3:
|
elif self.notebook.get_current_page() == 3:
|
||||||
Find.FindSource(self.source_view.source_list,self.find_goto_source,
|
Find.FindSource(self.source_view.source_list,self.find_goto_source,
|
||||||
self.database.getSourceMap().values())
|
self.db.getSourceMap().values())
|
||||||
elif self.notebook.get_current_page() == 5:
|
elif self.notebook.get_current_page() == 5:
|
||||||
Find.FindMedia(self.media_view.media_list,self.find_goto_media,
|
Find.FindMedia(self.media_view.media_list,self.find_goto_media,
|
||||||
self.database.getObjectMap().values())
|
self.db.getObjectMap().values())
|
||||||
else:
|
else:
|
||||||
Find.FindPerson(self.person_list,self.find_goto_to,
|
Find.FindPerson(self.person_list,self.find_goto_to,
|
||||||
self.database.getPersonMap().values())
|
self.db.getPersonMap().values())
|
||||||
|
|
||||||
def on_findname_activate(self,obj):
|
def on_findname_activate(self,obj):
|
||||||
"""Display the find box"""
|
"""Display the find box"""
|
||||||
@@ -393,7 +401,9 @@ class Gramps:
|
|||||||
import MergeData
|
import MergeData
|
||||||
(p1,x) = self.person_list.get_row_data(self.person_list.selection[0])
|
(p1,x) = self.person_list.get_row_data(self.person_list.selection[0])
|
||||||
(p2,x) = self.person_list.get_row_data(self.person_list.selection[1])
|
(p2,x) = self.person_list.get_row_data(self.person_list.selection[1])
|
||||||
MergeData.MergePeople(self.database,p1,p2,self.merge_update,
|
p1 = self.db.getPersonMap()[p1]
|
||||||
|
p2 = self.db.getPersonMap()[p2]
|
||||||
|
MergeData.MergePeople(self.db,p1,p2,self.merge_update,
|
||||||
self.update_after_edit)
|
self.update_after_edit)
|
||||||
elif page == 4:
|
elif page == 4:
|
||||||
self.place_view.merge()
|
self.place_view.merge()
|
||||||
@@ -464,7 +474,7 @@ class Gramps:
|
|||||||
|
|
||||||
def delete_family_from(self,person):
|
def delete_family_from(self,person):
|
||||||
person.removeFamily(self.active_family)
|
person.removeFamily(self.active_family)
|
||||||
self.database.deleteFamily(self.active_family)
|
self.db.deleteFamily(self.active_family)
|
||||||
flist = self.active_person.getFamilyList()
|
flist = self.active_person.getFamilyList()
|
||||||
if len(flist) > 0:
|
if len(flist) > 0:
|
||||||
self.active_family = flist[0][0]
|
self.active_family = flist[0][0]
|
||||||
@@ -477,7 +487,7 @@ class Gramps:
|
|||||||
def add_new_new_relationship(self,obj):
|
def add_new_new_relationship(self,obj):
|
||||||
import AddSpouse
|
import AddSpouse
|
||||||
Utils.destroy_passed_object(self.addornew)
|
Utils.destroy_passed_object(self.addornew)
|
||||||
AddSpouse.AddSpouse(self.database,self.active_person,
|
AddSpouse.AddSpouse(self.db,self.active_person,
|
||||||
self.load_family,self.redisplay_person_list)
|
self.load_family,self.redisplay_person_list)
|
||||||
|
|
||||||
def on_add_sp_clicked(self,obj):
|
def on_add_sp_clicked(self,obj):
|
||||||
@@ -493,18 +503,18 @@ class Gramps:
|
|||||||
})
|
})
|
||||||
self.addornew = top.get_widget('add_or_new')
|
self.addornew = top.get_widget('add_or_new')
|
||||||
else:
|
else:
|
||||||
AddSpouse.AddSpouse(self.database,self.active_person,
|
AddSpouse.AddSpouse(self.db,self.active_person,
|
||||||
self.load_family,self.redisplay_person_list)
|
self.load_family,self.redisplay_person_list)
|
||||||
def add_new_choose_spouse(self,obj):
|
def add_new_choose_spouse(self,obj):
|
||||||
import AddSpouse
|
import AddSpouse
|
||||||
Utils.destroy_passed_object(self.addornew)
|
Utils.destroy_passed_object(self.addornew)
|
||||||
AddSpouse.SetSpouse(self.database,self.active_person,self.active_family,
|
AddSpouse.SetSpouse(self.db,self.active_person,self.active_family,
|
||||||
self.load_family, self.redisplay_person_list)
|
self.load_family, self.redisplay_person_list)
|
||||||
|
|
||||||
def on_edit_sp_clicked(self,obj):
|
def on_edit_sp_clicked(self,obj):
|
||||||
"""Edit the marriage information for the current family"""
|
"""Edit the marriage information for the current family"""
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
Marriage.Marriage(self.active_family,self.database,self.new_after_edit)
|
Marriage.Marriage(self.active_family,self.db,self.new_after_edit)
|
||||||
|
|
||||||
def on_delete_sp_clicked(self,obj):
|
def on_delete_sp_clicked(self,obj):
|
||||||
"""Delete the currently selected spouse from the family"""
|
"""Delete the currently selected spouse from the family"""
|
||||||
@@ -523,7 +533,7 @@ class Gramps:
|
|||||||
|
|
||||||
if len(self.active_family.getChildList()) == 0:
|
if len(self.active_family.getChildList()) == 0:
|
||||||
self.active_person.removeFamily(self.active_family)
|
self.active_person.removeFamily(self.active_family)
|
||||||
self.database.deleteFamily(self.active_family)
|
self.db.deleteFamily(self.active_family)
|
||||||
if len(self.active_person.getFamilyList()) > 0:
|
if len(self.active_person.getFamilyList()) > 0:
|
||||||
self.load_family(self.active_person.getFamilyList()[0])
|
self.load_family(self.active_person.getFamilyList()[0])
|
||||||
else:
|
else:
|
||||||
@@ -568,14 +578,14 @@ class Gramps:
|
|||||||
"""Select an existing child to add to the active family"""
|
"""Select an existing child to add to the active family"""
|
||||||
import SelectChild
|
import SelectChild
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
SelectChild.SelectChild(self.database,self.active_family,
|
SelectChild.SelectChild(self.db,self.active_family,
|
||||||
self.active_person,self.load_family)
|
self.active_person,self.load_family)
|
||||||
|
|
||||||
def on_add_new_child_clicked(self,obj):
|
def on_add_new_child_clicked(self,obj):
|
||||||
"""Create a new child to add to the existing family"""
|
"""Create a new child to add to the existing family"""
|
||||||
import SelectChild
|
import SelectChild
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
SelectChild.NewChild(self.database,self.active_family,
|
SelectChild.NewChild(self.db,self.active_family,
|
||||||
self.active_person,self.update_after_newchild,
|
self.active_person,self.update_after_newchild,
|
||||||
self.update_after_edit,
|
self.update_after_edit,
|
||||||
GrampsCfg.lastnamegen)
|
GrampsCfg.lastnamegen)
|
||||||
@@ -583,7 +593,7 @@ class Gramps:
|
|||||||
def on_choose_parents_clicked(self,obj):
|
def on_choose_parents_clicked(self,obj):
|
||||||
import ChooseParents
|
import ChooseParents
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
ChooseParents.ChooseParents(self.database,self.active_person,
|
ChooseParents.ChooseParents(self.db,self.active_person,
|
||||||
self.active_parents,self.load_family,
|
self.active_parents,self.load_family,
|
||||||
self.full_update)
|
self.full_update)
|
||||||
|
|
||||||
@@ -600,7 +610,7 @@ class Gramps:
|
|||||||
self.clear_database()
|
self.clear_database()
|
||||||
DbPrompter.DbPrompter(self,1)
|
DbPrompter.DbPrompter(self,1)
|
||||||
|
|
||||||
def clear_database(self):
|
def clear_database(self,zodb=1):
|
||||||
"""Clear out the database if permission was granted"""
|
"""Clear out the database if permission was granted"""
|
||||||
const.personalEvents = const.init_personal_event_list()
|
const.personalEvents = const.init_personal_event_list()
|
||||||
const.personalAttributes = const.init_personal_attribute_list()
|
const.personalAttributes = const.init_personal_attribute_list()
|
||||||
@@ -608,7 +618,15 @@ class Gramps:
|
|||||||
const.familyAttributes = const.init_family_attribute_list()
|
const.familyAttributes = const.init_family_attribute_list()
|
||||||
const.familyRelations = const.init_family_relation_list()
|
const.familyRelations = const.init_family_relation_list()
|
||||||
|
|
||||||
self.database.new()
|
if zodb:
|
||||||
|
self.db = GrampsZODB()
|
||||||
|
else:
|
||||||
|
self.db = GrampsXML()
|
||||||
|
|
||||||
|
self.place_view.change_db(self.db)
|
||||||
|
self.source_view.change_db(self.db)
|
||||||
|
self.media_view.change_db(self.db)
|
||||||
|
|
||||||
self.topWindow.set_title("GRAMPS")
|
self.topWindow.set_title("GRAMPS")
|
||||||
self.active_person = None
|
self.active_person = None
|
||||||
self.active_father = None
|
self.active_father = None
|
||||||
@@ -617,7 +635,6 @@ class Gramps:
|
|||||||
self.active_child = None
|
self.active_child = None
|
||||||
self.active_spouse = None
|
self.active_spouse = None
|
||||||
self.id2col = {}
|
self.id2col = {}
|
||||||
self.alt2col = {}
|
|
||||||
|
|
||||||
Utils.clearModified()
|
Utils.clearModified()
|
||||||
Utils.clear_timer()
|
Utils.clear_timer()
|
||||||
@@ -636,7 +653,6 @@ class Gramps:
|
|||||||
def full_update(self):
|
def full_update(self):
|
||||||
"""Brute force display update, updating all the pages"""
|
"""Brute force display update, updating all the pages"""
|
||||||
self.id2col = {}
|
self.id2col = {}
|
||||||
self.alt2col = {}
|
|
||||||
self.person_list.clear()
|
self.person_list.clear()
|
||||||
self.notebook.set_show_tabs(GrampsCfg.usetabs)
|
self.notebook.set_show_tabs(GrampsCfg.usetabs)
|
||||||
self.child_list.set_column_visibility(self.c_details,GrampsCfg.show_detail)
|
self.child_list.set_column_visibility(self.c_details,GrampsCfg.show_detail)
|
||||||
@@ -671,12 +687,12 @@ class Gramps:
|
|||||||
|
|
||||||
def on_tools_clicked(self,obj):
|
def on_tools_clicked(self,obj):
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
Plugins.ToolPlugins(self.database,self.active_person,
|
Plugins.ToolPlugins(self.db,self.active_person,
|
||||||
self.tool_callback)
|
self.tool_callback)
|
||||||
|
|
||||||
def on_reports_clicked(self,obj):
|
def on_reports_clicked(self,obj):
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
Plugins.ReportPlugins(self.database,self.active_person)
|
Plugins.ReportPlugins(self.db,self.active_person)
|
||||||
|
|
||||||
def on_ok_button1_clicked(self,obj):
|
def on_ok_button1_clicked(self,obj):
|
||||||
|
|
||||||
@@ -692,7 +708,7 @@ class Gramps:
|
|||||||
|
|
||||||
if getoldrev.get_active():
|
if getoldrev.get_active():
|
||||||
vc = VersionControl.RcsVersionControl(filename)
|
vc = VersionControl.RcsVersionControl(filename)
|
||||||
VersionControl.RevisionSelect(self.database,filename,vc,
|
VersionControl.RevisionSelect(self.db,filename,vc,
|
||||||
self.load_revision)
|
self.load_revision)
|
||||||
else:
|
else:
|
||||||
self.auto_save_load(filename)
|
self.auto_save_load(filename)
|
||||||
@@ -727,12 +743,12 @@ class Gramps:
|
|||||||
import ReadGedcom
|
import ReadGedcom
|
||||||
|
|
||||||
self.topWindow.set_title("%s - GRAMPS" % filename)
|
self.topWindow.set_title("%s - GRAMPS" % filename)
|
||||||
ReadGedcom.importData(self.database,filename)
|
ReadGedcom.importData(self.db,filename)
|
||||||
self.full_update()
|
self.full_update()
|
||||||
|
|
||||||
def read_file(self,filename):
|
def read_file(self,filename):
|
||||||
base = os.path.basename(filename)
|
base = os.path.basename(filename)
|
||||||
if base == const.indexFile:
|
if base == const.xmlFile:
|
||||||
filename = os.path.dirname(filename)
|
filename = os.path.dirname(filename)
|
||||||
elif base == "autosave.gramps":
|
elif base == "autosave.gramps":
|
||||||
filename = os.path.dirname(filename)
|
filename = os.path.dirname(filename)
|
||||||
@@ -746,7 +762,7 @@ class Gramps:
|
|||||||
if filename[-1] == '/':
|
if filename[-1] == '/':
|
||||||
filename = filename[:-1]
|
filename = filename[:-1]
|
||||||
name = os.path.basename(filename)
|
name = os.path.basename(filename)
|
||||||
self.topWindow.set_title("%s - %s" % (name,_("GRAMPS")))
|
self.topWindow.set_title("%s - GRAMPS" % name)
|
||||||
else:
|
else:
|
||||||
self.statusbar.set_status("")
|
self.statusbar.set_status("")
|
||||||
GrampsCfg.save_last_file("")
|
GrampsCfg.save_last_file("")
|
||||||
@@ -787,26 +803,26 @@ class Gramps:
|
|||||||
return
|
return
|
||||||
|
|
||||||
old_file = filename
|
old_file = filename
|
||||||
filename = filename + os.sep + const.indexFile
|
filename = "%s/%s" % (filename,self.db.get_base())
|
||||||
try:
|
try:
|
||||||
WriteXML.exportData(self.database,filename,self.load_progress)
|
self.db.save(filename,self.load_progress)
|
||||||
except (OSError,IOError), msg:
|
except (OSError,IOError), msg:
|
||||||
emsg = _("Could not create %s") % filename + "\n" + str(msg)
|
emsg = _("Could not create %s") % filename + "\n" + str(msg)
|
||||||
gnome.ui.GnomeErrorDialog(emsg)
|
gnome.ui.GnomeErrorDialog(emsg)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.database.setSavePath(old_file)
|
self.db.setSavePath(old_file)
|
||||||
GrampsCfg.save_last_file(old_file)
|
GrampsCfg.save_last_file(old_file)
|
||||||
|
|
||||||
if GrampsCfg.usevc:
|
if GrampsCfg.usevc:
|
||||||
vc = VersionControl.RcsVersionControl(path)
|
vc = VersionControl.RcsVersionControl(path)
|
||||||
vc.checkin(filename,comment,not GrampsCfg.uncompress)
|
vc.checkin(filename,comment,not GrampsCfg.uncompress)
|
||||||
|
|
||||||
filename = self.database.getSavePath()
|
filename = self.db.getSavePath()
|
||||||
if filename[-1] == '/':
|
if filename[-1] == '/':
|
||||||
filename = filename[:-1]
|
filename = filename[:-1]
|
||||||
name = os.path.basename(filename)
|
name = os.path.basename(filename)
|
||||||
self.topWindow.set_title("%s - %s" % (name,_("GRAMPS")))
|
self.topWindow.set_title("%s - GRAMPS" % name)
|
||||||
self.statusbar.set_status("")
|
self.statusbar.set_status("")
|
||||||
self.statusbar.set_progress(0)
|
self.statusbar.set_progress(0)
|
||||||
if os.path.exists(autosave):
|
if os.path.exists(autosave):
|
||||||
@@ -817,18 +833,18 @@ class Gramps:
|
|||||||
|
|
||||||
def autosave_database(self):
|
def autosave_database(self):
|
||||||
|
|
||||||
path = self.database.getSavePath()
|
path = self.db.getSavePath()
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
|
|
||||||
filename = os.path.normpath(path)
|
filename = os.path.normpath(path)
|
||||||
Utils.clear_timer()
|
Utils.clear_timer()
|
||||||
|
|
||||||
filename = "%s/autosave.gramps" % (self.database.getSavePath())
|
filename = "%s/autosave.gramps" % (self.db.getSavePath())
|
||||||
|
|
||||||
self.statusbar.set_status(_("autosaving..."));
|
self.statusbar.set_status(_("autosaving..."));
|
||||||
try:
|
try:
|
||||||
WriteXML.quick_write(self.database,filename,self.quick_progress)
|
self.db.save(filename,self.quick_progress)
|
||||||
self.statusbar.set_status(_("autosave complete"));
|
self.statusbar.set_status(_("autosave complete"));
|
||||||
except (IOError,OSError),msg:
|
except (IOError,OSError),msg:
|
||||||
self.statusbar.set_status("%s - %s" % (_("autosave failed"),msg))
|
self.statusbar.set_status("%s - %s" % (_("autosave failed"),msg))
|
||||||
@@ -845,7 +861,7 @@ class Gramps:
|
|||||||
else:
|
else:
|
||||||
for p in self.person_list.selection:
|
for p in self.person_list.selection:
|
||||||
(person,x) = self.person_list.get_row_data(p)
|
(person,x) = self.person_list.get_row_data(p)
|
||||||
self.load_person(person)
|
self.load_person(self.db.getPersonMap()[person])
|
||||||
|
|
||||||
def load_active_person(self,obj):
|
def load_active_person(self,obj):
|
||||||
self.load_person(self.active_person)
|
self.load_person(self.active_person)
|
||||||
@@ -864,7 +880,7 @@ class Gramps:
|
|||||||
|
|
||||||
def load_new_person(self,obj):
|
def load_new_person(self,obj):
|
||||||
self.active_person = Person()
|
self.active_person = Person()
|
||||||
EditPerson.EditPerson(self.active_person,self.database,
|
EditPerson.EditPerson(self.active_person,self.db,
|
||||||
self.new_after_edit)
|
self.new_after_edit)
|
||||||
|
|
||||||
def on_delete_person_clicked(self,obj):
|
def on_delete_person_clicked(self,obj):
|
||||||
@@ -880,8 +896,8 @@ class Gramps:
|
|||||||
gnome.ui.GnomeErrorDialog(msg)
|
gnome.ui.GnomeErrorDialog(msg)
|
||||||
|
|
||||||
def delete_person_response(self):
|
def delete_person_response(self):
|
||||||
personmap = self.database.getPersonMap()
|
personmap = self.db.getPersonMap()
|
||||||
familymap = self.database.getPersonMap()
|
familymap = self.db.getPersonMap()
|
||||||
|
|
||||||
for family in self.active_person.getFamilyList():
|
for family in self.active_person.getFamilyList():
|
||||||
if self.active_person.getGender == Person.male:
|
if self.active_person.getGender == Person.male:
|
||||||
@@ -903,7 +919,7 @@ class Gramps:
|
|||||||
if family:
|
if family:
|
||||||
family.removeChild(self.active_person)
|
family.removeChild(self.active_person)
|
||||||
|
|
||||||
del personmap[self.active_person.getId()]
|
self.db.removePerson(self.active_person.getId())
|
||||||
self.remove_from_person_list(self.active_person)
|
self.remove_from_person_list(self.active_person)
|
||||||
self.person_list.sort()
|
self.person_list.sort()
|
||||||
self.update_display(0)
|
self.update_display(0)
|
||||||
@@ -912,16 +928,17 @@ class Gramps:
|
|||||||
def remove_from_person_list(self,person):
|
def remove_from_person_list(self,person):
|
||||||
|
|
||||||
self.person_list.freeze()
|
self.person_list.freeze()
|
||||||
if self.id2col.has_key(person):
|
pid = person.getId()
|
||||||
for id in [self.id2col[person]] + self.alt2col[person]:
|
if self.id2col.has_key(pid):
|
||||||
|
for id in self.id2col[pid]:
|
||||||
row = self.person_list.find_row_from_data(id)
|
row = self.person_list.find_row_from_data(id)
|
||||||
self.person_list.remove(row)
|
self.person_list.remove(row)
|
||||||
|
|
||||||
del self.id2col[person]
|
del self.id2col[pid]
|
||||||
del self.alt2col[person]
|
|
||||||
|
|
||||||
if row > self.person_list.rows:
|
if row > self.person_list.rows:
|
||||||
(self.active_person,x) = self.person_list.get_row_data(row)
|
(p,x) = self.person_list.get_row_data(row)
|
||||||
|
self.active_person = self.db.getPersonMap()[p]
|
||||||
self.person_list.thaw()
|
self.person_list.thaw()
|
||||||
|
|
||||||
def merge_update(self,p1,p2):
|
def merge_update(self,p1,p2):
|
||||||
@@ -939,7 +956,8 @@ class Gramps:
|
|||||||
|
|
||||||
def on_person_list_select_row(self,obj,row,b,c):
|
def on_person_list_select_row(self,obj,row,b,c):
|
||||||
if row == obj.selection[0]:
|
if row == obj.selection[0]:
|
||||||
(person,x) = obj.get_row_data(row)
|
(id,x) = obj.get_row_data(row)
|
||||||
|
person = self.db.getPersonMap()[id]
|
||||||
self.change_active_person(person)
|
self.change_active_person(person)
|
||||||
|
|
||||||
def on_person_list_click_column(self,obj,column):
|
def on_person_list_click_column(self,obj,column):
|
||||||
@@ -964,28 +982,30 @@ class Gramps:
|
|||||||
arrow.show()
|
arrow.show()
|
||||||
|
|
||||||
self.person_list.set_sort_column(self.col_map[column])
|
self.person_list.set_sort_column(self.col_map[column])
|
||||||
self.person_list.set_sort_type(self.sort_dir)
|
self.person_list.set_sort_type(self.sdir)
|
||||||
|
|
||||||
self.sort_person_list()
|
self.sort_person_list()
|
||||||
|
|
||||||
if change:
|
if change:
|
||||||
if self.sort_col == column:
|
if self.scol == column:
|
||||||
if self.sort_dir == GTK.SORT_DESCENDING:
|
if self.sdir == GTK.SORT_DESCENDING:
|
||||||
self.sort_dir = GTK.SORT_ASCENDING
|
self.sdir = GTK.SORT_ASCENDING
|
||||||
arrow.set(GTK.ARROW_DOWN,2)
|
arrow.set(GTK.ARROW_DOWN,2)
|
||||||
else:
|
else:
|
||||||
self.sort_dir = GTK.SORT_DESCENDING
|
self.sdir = GTK.SORT_DESCENDING
|
||||||
arrow.set(GTK.ARROW_UP,2)
|
arrow.set(GTK.ARROW_UP,2)
|
||||||
else:
|
else:
|
||||||
self.sort_dir = GTK.SORT_ASCENDING
|
self.sdir = GTK.SORT_ASCENDING
|
||||||
arrow.set(GTK.ARROW_DOWN,2)
|
arrow.set(GTK.ARROW_DOWN,2)
|
||||||
self.sort_col = column
|
self.scol = column
|
||||||
|
|
||||||
if self.id2col.has_key(self.active_person):
|
if self.active_person:
|
||||||
data = self.id2col[self.active_person]
|
pid = self.active_person.getId()
|
||||||
|
if self.id2col.has_key(pid):
|
||||||
|
data = self.id2col[pid]
|
||||||
row = self.person_list.find_row_from_data(data)
|
row = self.person_list.find_row_from_data(data)
|
||||||
self.person_list.moveto(row)
|
self.person_list.moveto(row)
|
||||||
GrampsCfg.save_sort_cols("person",self.sort_col,self.sort_dir)
|
GrampsCfg.save_sort_cols("person",self.scol,self.sdir)
|
||||||
|
|
||||||
def sort_person_list(self):
|
def sort_person_list(self):
|
||||||
self.person_list.freeze()
|
self.person_list.freeze()
|
||||||
@@ -1015,7 +1035,7 @@ class Gramps:
|
|||||||
self.goto_active_person()
|
self.goto_active_person()
|
||||||
self.person_list.thaw()
|
self.person_list.thaw()
|
||||||
|
|
||||||
def on_child_list_button_press_event(self,obj,event):
|
def on_child_list_button_press(self,obj,event):
|
||||||
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
||||||
self.load_person(self.active_child)
|
self.load_person(self.active_child)
|
||||||
|
|
||||||
@@ -1023,9 +1043,12 @@ class Gramps:
|
|||||||
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
|
||||||
self.load_person(self.active_person)
|
self.load_person(self.active_person)
|
||||||
|
|
||||||
def goto_active_person(self,):
|
def goto_active_person(self):
|
||||||
if self.id2col.has_key(self.active_person):
|
if not self.active_person:
|
||||||
pos = self.id2col[self.active_person]
|
return
|
||||||
|
id = self.active_person.getId()
|
||||||
|
if self.id2col.has_key(id):
|
||||||
|
pos = self.id2col[id]
|
||||||
column = self.person_list.find_row_from_data(pos)
|
column = self.person_list.find_row_from_data(pos)
|
||||||
if column != -1:
|
if column != -1:
|
||||||
self.person_list.unselect_all()
|
self.person_list.unselect_all()
|
||||||
@@ -1037,6 +1060,7 @@ class Gramps:
|
|||||||
self.person_list.select_row(0,0)
|
self.person_list.select_row(0,0)
|
||||||
self.person_list.moveto(0)
|
self.person_list.moveto(0)
|
||||||
(person,x) = self.person_list.get_row_data(0)
|
(person,x) = self.person_list.get_row_data(0)
|
||||||
|
person = self.db.getPersonMap()[person]
|
||||||
self.change_active_person(person)
|
self.change_active_person(person)
|
||||||
|
|
||||||
def change_active_person(self,person):
|
def change_active_person(self,person):
|
||||||
@@ -1062,7 +1086,8 @@ class Gramps:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def on_child_list_select_row(self,obj,row,b,c):
|
def on_child_list_select_row(self,obj,row,b,c):
|
||||||
self.active_child = obj.get_row_data(row)
|
id = obj.get_row_data(row)
|
||||||
|
self.active_child = id #self.db.getPersonMap()[id]
|
||||||
|
|
||||||
def on_child_list_click_column(self,clist,column):
|
def on_child_list_click_column(self,clist,column):
|
||||||
"""Called when the user selects a column header on the self.person_list
|
"""Called when the user selects a column header on the self.person_list
|
||||||
@@ -1082,8 +1107,9 @@ class Gramps:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.sort_child_list(clist)
|
self.sort_child_list(clist)
|
||||||
if self.id2col.has_key(self.active_child):
|
if self.active_child and self.id2col.has_key(self.active_child.getId()):
|
||||||
row = clist.find_row_from_data(self.id2col[self.active_child])
|
row = clist.find_row_from_data(self.id2col[
|
||||||
|
self.active_child.getId()])
|
||||||
clist.moveto(row)
|
clist.moveto(row)
|
||||||
|
|
||||||
def child_change_sort(self,clist,column,arrow):
|
def child_change_sort(self,clist,column,arrow):
|
||||||
@@ -1093,19 +1119,19 @@ class Gramps:
|
|||||||
self.cGenderArrow.hide()
|
self.cGenderArrow.hide()
|
||||||
arrow.show()
|
arrow.show()
|
||||||
|
|
||||||
if self.c_sort_col == column:
|
if self.c_scol == column:
|
||||||
if self.c_sort_dir == GTK.SORT_DESCENDING:
|
if self.c_sdir == GTK.SORT_DESCENDING:
|
||||||
self.c_sort_dir = GTK.SORT_ASCENDING
|
self.c_sdir = GTK.SORT_ASCENDING
|
||||||
arrow.set(GTK.ARROW_DOWN,2)
|
arrow.set(GTK.ARROW_DOWN,2)
|
||||||
else:
|
else:
|
||||||
self.c_sort_dir = GTK.SORT_DESCENDING
|
self.c_sdir = GTK.SORT_DESCENDING
|
||||||
arrow.set(GTK.ARROW_UP,2)
|
arrow.set(GTK.ARROW_UP,2)
|
||||||
else:
|
else:
|
||||||
self.c_sort_dir = GTK.SORT_ASCENDING
|
self.c_sdir = GTK.SORT_ASCENDING
|
||||||
self.c_sort_col = column
|
self.c_scol = column
|
||||||
clist.set_sort_type(self.c_sort_dir)
|
clist.set_sort_type(self.c_sdir)
|
||||||
clist.set_sort_column(self.c_sort_col)
|
clist.set_sort_column(self.c_scol)
|
||||||
clist.set_reorderable(self.c_sort_col == self.c_birth_order)
|
clist.set_reorderable(self.c_scol == self.c_birth_order)
|
||||||
|
|
||||||
def sort_child_list(self,clist):
|
def sort_child_list(self,clist):
|
||||||
clist.freeze()
|
clist.freeze()
|
||||||
@@ -1128,7 +1154,8 @@ class Gramps:
|
|||||||
rows = clist.rows
|
rows = clist.rows
|
||||||
for i in range(0,rows):
|
for i in range(0,rows):
|
||||||
clist.set_background(i,(evenbg,oddbg)[i%2])
|
clist.set_background(i,(evenbg,oddbg)[i%2])
|
||||||
person = clist.get_row_data(i)
|
id = clist.get_row_data(i)
|
||||||
|
person = self.db.getPersonMap()[id]
|
||||||
if (person.getAncestor()):
|
if (person.getAncestor()):
|
||||||
clist.set_foreground(i,ancestorfg)
|
clist.set_foreground(i,ancestorfg)
|
||||||
else:
|
else:
|
||||||
@@ -1159,7 +1186,7 @@ class Gramps:
|
|||||||
|
|
||||||
# This function deals with ascending order lists. Convert if
|
# This function deals with ascending order lists. Convert if
|
||||||
# necessary.
|
# necessary.
|
||||||
if (self.c_sort_dir == GTK.SORT_DESCENDING):
|
if (self.c_sdir == GTK.SORT_DESCENDING):
|
||||||
clist_order.reverse()
|
clist_order.reverse()
|
||||||
max_index = len(clist_order) - 1
|
max_index = len(clist_order) - 1
|
||||||
fm = max_index - fm
|
fm = max_index - fm
|
||||||
@@ -1189,7 +1216,7 @@ class Gramps:
|
|||||||
|
|
||||||
# Convert the original list back to whatever ordering is being
|
# Convert the original list back to whatever ordering is being
|
||||||
# used by the clist itself.
|
# used by the clist itself.
|
||||||
if (self.c_sort_dir == GTK.SORT_DESCENDING):
|
if (self.c_sdir == GTK.SORT_DESCENDING):
|
||||||
clist_order.reverse()
|
clist_order.reverse()
|
||||||
|
|
||||||
# Update the clist indices so any change of sorting works
|
# Update the clist indices so any change of sorting works
|
||||||
@@ -1219,7 +1246,7 @@ class Gramps:
|
|||||||
|
|
||||||
def on_revert_activate(self,obj):
|
def on_revert_activate(self,obj):
|
||||||
|
|
||||||
if self.database.getSavePath() != "":
|
if self.db.getSavePath() != "":
|
||||||
msg = _("Do you wish to abandon your changes and "
|
msg = _("Do you wish to abandon your changes and "
|
||||||
"revert to the last saved database?")
|
"revert to the last saved database?")
|
||||||
|
|
||||||
@@ -1238,8 +1265,8 @@ class Gramps:
|
|||||||
const.familyAttributes = const.init_family_attribute_list()
|
const.familyAttributes = const.init_family_attribute_list()
|
||||||
const.familyRelations = const.init_family_relation_list()
|
const.familyRelations = const.init_family_relation_list()
|
||||||
|
|
||||||
file = self.database.getSavePath()
|
file = self.db.getSavePath()
|
||||||
self.database.new()
|
self.db.new()
|
||||||
self.active_person = None
|
self.active_person = None
|
||||||
self.active_father = None
|
self.active_father = None
|
||||||
self.active_family = None
|
self.active_family = None
|
||||||
@@ -1247,7 +1274,6 @@ class Gramps:
|
|||||||
self.active_child = None
|
self.active_child = None
|
||||||
self.active_spouse = None
|
self.active_spouse = None
|
||||||
self.id2col = {}
|
self.id2col = {}
|
||||||
self.alt2col = {}
|
|
||||||
self.read_file(file)
|
self.read_file(file)
|
||||||
Utils.clearModified()
|
Utils.clearModified()
|
||||||
Utils.clear_timer()
|
Utils.clear_timer()
|
||||||
@@ -1265,26 +1291,26 @@ class Gramps:
|
|||||||
def on_save_activate(self,obj):
|
def on_save_activate(self,obj):
|
||||||
"""Saves the file, first prompting for a comment if revision
|
"""Saves the file, first prompting for a comment if revision
|
||||||
control needs it"""
|
control needs it"""
|
||||||
if not self.database.getSavePath():
|
if not self.db.getSavePath():
|
||||||
self.on_save_as_activate(obj)
|
self.on_save_as_activate(obj)
|
||||||
else:
|
else:
|
||||||
if GrampsCfg.usevc and GrampsCfg.vc_comment:
|
if GrampsCfg.usevc and GrampsCfg.vc_comment:
|
||||||
self.display_comment_box(self.database.getSavePath())
|
self.display_comment_box(self.db.getSavePath())
|
||||||
else:
|
else:
|
||||||
msg = _("No Comment Provided")
|
msg = _("No Comment Provided")
|
||||||
self.save_file(self.database.getSavePath(),msg)
|
self.save_file(self.db.getSavePath(),msg)
|
||||||
|
|
||||||
def on_save_activate_quit(self):
|
def on_save_activate_quit(self):
|
||||||
"""Saves the file, first prompting for a comment if revision
|
"""Saves the file, first prompting for a comment if revision
|
||||||
control needs it"""
|
control needs it"""
|
||||||
if not self.database.getSavePath():
|
if not self.db.getSavePath():
|
||||||
self.on_save_as_activate(None)
|
self.on_save_as_activate(None)
|
||||||
else:
|
else:
|
||||||
if GrampsCfg.usevc and GrampsCfg.vc_comment:
|
if GrampsCfg.usevc and GrampsCfg.vc_comment:
|
||||||
self.display_comment_box(self.database.getSavePath())
|
self.display_comment_box(self.db.getSavePath())
|
||||||
else:
|
else:
|
||||||
msg = _("No Comment Provided")
|
msg = _("No Comment Provided")
|
||||||
self.save_file(self.database.getSavePath(),msg)
|
self.save_file(self.db.getSavePath(),msg)
|
||||||
|
|
||||||
def display_comment_box(self,filename):
|
def display_comment_box(self,filename):
|
||||||
"""Displays a dialog box, prompting for a revison control comment"""
|
"""Displays a dialog box, prompting for a revison control comment"""
|
||||||
@@ -1377,9 +1403,9 @@ class Gramps:
|
|||||||
def new_after_edit(self,epo,plist):
|
def new_after_edit(self,epo,plist):
|
||||||
if epo:
|
if epo:
|
||||||
if epo.person.getId() == "":
|
if epo.person.getId() == "":
|
||||||
self.database.addPerson(epo.person)
|
self.db.addPerson(epo.person)
|
||||||
else:
|
else:
|
||||||
self.database.addPersonNoMap(epo.person,epo.person.getId())
|
self.db.addPersonNoMap(epo.person,epo.person.getId())
|
||||||
self.change_active_person(epo.person)
|
self.change_active_person(epo.person)
|
||||||
self.redisplay_person_list(epo.person)
|
self.redisplay_person_list(epo.person)
|
||||||
for p in plist:
|
for p in plist:
|
||||||
@@ -1401,46 +1427,19 @@ class Gramps:
|
|||||||
|
|
||||||
def redisplay_person_list(self,person):
|
def redisplay_person_list(self,person):
|
||||||
pos = (person,0)
|
pos = (person,0)
|
||||||
self.id2col[person] = pos
|
self.id2col[person.getId()] = pos
|
||||||
self.alt2col[person] = []
|
|
||||||
gname = Utils.phonebook_from_name
|
gname = Utils.phonebook_from_name
|
||||||
|
bsn = sort.build_sort_name
|
||||||
|
bsd = sort.build_sort_date
|
||||||
|
|
||||||
if self.DataFilter.compare(person):
|
if self.DataFilter.compare(person):
|
||||||
if person.getGender() == Person.male:
|
self.person_list.insert(0,person.getDisplayInfo())
|
||||||
gender = const.male
|
|
||||||
elif person.getGender() == Person.female:
|
|
||||||
gender = const.female
|
|
||||||
else:
|
|
||||||
gender = const.unknown
|
|
||||||
bday = person.getBirth().getDateObj()
|
|
||||||
dday = person.getDeath().getDateObj()
|
|
||||||
name = person.getPrimaryName()
|
|
||||||
self.person_list.insert(0,[gname(name,0),person.getId(),
|
|
||||||
gender,bday.getQuoteDate(),
|
|
||||||
dday.getQuoteDate(),
|
|
||||||
sort.build_sort_name(name),
|
|
||||||
sort.build_sort_date(bday),
|
|
||||||
sort.build_sort_date(dday)])
|
|
||||||
|
|
||||||
self.person_list.set_row_data(0,pos)
|
self.person_list.set_row_data(0,pos)
|
||||||
|
|
||||||
if GrampsCfg.hide_altnames == 0:
|
|
||||||
for name in person.getAlternateNames():
|
|
||||||
pos2 = (person,0)
|
|
||||||
self.alt2col[person].append(pos2)
|
|
||||||
self.person_list.insert(0,[gname(name,1),person.getId(),
|
|
||||||
gender,bday.getQuoteDate(),
|
|
||||||
dday.getQuoteDate(),
|
|
||||||
sort.build_sort_name(name),
|
|
||||||
sort.build_sort_date(bday),
|
|
||||||
sort.build_sort_date(dday)])
|
|
||||||
|
|
||||||
self.person_list.set_row_data(0,pos2)
|
|
||||||
self.sort_person_list()
|
self.sort_person_list()
|
||||||
|
|
||||||
def load_person(self,person):
|
def load_person(self,person):
|
||||||
if person:
|
if person:
|
||||||
EditPerson.EditPerson(person,self.database,
|
EditPerson.EditPerson(person, self.db, self.update_after_edit)
|
||||||
self.update_after_edit)
|
|
||||||
|
|
||||||
def build_spouse_dropdown(self):
|
def build_spouse_dropdown(self):
|
||||||
mymap = {}
|
mymap = {}
|
||||||
@@ -1669,9 +1668,9 @@ class Gramps:
|
|||||||
self.active_child = None
|
self.active_child = None
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
self.child_list.set_sort_type(self.c_sort_dir)
|
self.child_list.set_sort_type(self.c_sdir)
|
||||||
self.child_list.set_sort_column(self.c_sort_col)
|
self.child_list.set_sort_column(self.c_scol)
|
||||||
self.child_list.set_reorderable(self.c_sort_col == self.c_birth_order)
|
self.child_list.set_reorderable(self.c_scol == self.c_birth_order)
|
||||||
|
|
||||||
if family:
|
if family:
|
||||||
if self.active_person == family.getFather():
|
if self.active_person == family.getFather():
|
||||||
@@ -1679,7 +1678,7 @@ class Gramps:
|
|||||||
else:
|
else:
|
||||||
self.active_spouse = family.getFather()
|
self.active_spouse = family.getFather()
|
||||||
|
|
||||||
child_list = family.getChildList()
|
child_list = list(family.getChildList())
|
||||||
child_list.sort(sort.by_birthdate)
|
child_list.sort(sort.by_birthdate)
|
||||||
|
|
||||||
attr = ""
|
attr = ""
|
||||||
@@ -1714,13 +1713,11 @@ class Gramps:
|
|||||||
if len(child.getPhotoList()) > 0:
|
if len(child.getPhotoList()) > 0:
|
||||||
attr = attr + "P"
|
attr = attr + "P"
|
||||||
|
|
||||||
self.child_list.append(["%2d"%(i+1),
|
self.child_list.append(["%2d" % (i+1),
|
||||||
GrampsCfg.nameof(child),
|
GrampsCfg.nameof(child),
|
||||||
child.getId(),
|
child.getId(), gender,
|
||||||
gender,
|
|
||||||
Utils.birthday(child),
|
Utils.birthday(child),
|
||||||
status,
|
status, attr])
|
||||||
attr])
|
|
||||||
self.child_list.set_row_data(i,child)
|
self.child_list.set_row_data(i,child)
|
||||||
i=i+1
|
i=i+1
|
||||||
if i != 0:
|
if i != 0:
|
||||||
@@ -1747,57 +1744,50 @@ class Gramps:
|
|||||||
gtk.threads_leave()
|
gtk.threads_leave()
|
||||||
|
|
||||||
def post_load(self,name):
|
def post_load(self,name):
|
||||||
self.database.setSavePath(name)
|
self.db.setSavePath(name)
|
||||||
res = self.database.getResearcher()
|
res = self.db.getResearcher()
|
||||||
owner = GrampsCfg.get_researcher()
|
owner = GrampsCfg.get_researcher()
|
||||||
|
|
||||||
if res.getName() == "" and owner.getName() != "":
|
if res.getName() == "" and owner.getName() != "":
|
||||||
self.database.setResearcher(owner)
|
self.db.setResearcher(owner)
|
||||||
Utils.modified()
|
Utils.modified()
|
||||||
|
|
||||||
self.setup_bookmarks()
|
self.setup_bookmarks()
|
||||||
|
|
||||||
mylist = self.database.getPersonEventTypes()
|
# mylist = self.db.getPersonEventTypes()
|
||||||
for type in mylist:
|
# for type in mylist:
|
||||||
ntype = const.display_pevent(type)
|
# ntype = const.display_pevent(type)
|
||||||
if ntype not in const.personalEvents:
|
# if ntype not in const.personalEvents:
|
||||||
const.personalEvents.append(ntype)
|
# const.personalEvents.append(ntype)
|
||||||
|
#
|
||||||
mylist = self.database.getFamilyEventTypes()
|
# mylist = self.db.getFamilyEventTypes()
|
||||||
for type in mylist:
|
# for type in mylist:
|
||||||
ntype = const.display_fevent(type)
|
# ntype = const.display_fevent(type)
|
||||||
if ntype not in const.marriageEvents:
|
# if ntype not in const.marriageEvents:
|
||||||
const.marriageEvents.append(ntype)
|
# const.marriageEvents.append(ntype)
|
||||||
|
#
|
||||||
mylist = self.database.getPersonAttributeTypes()
|
# mylist = self.db.getPersonAttributeTypes()
|
||||||
for type in mylist:
|
# for type in mylist:
|
||||||
ntype = const.display_pattr(type)
|
# ntype = const.display_pattr(type)
|
||||||
if ntype not in const.personalAttributes:
|
# if ntype not in const.personalAttributes:
|
||||||
const.personalAttributes.append(ntype)
|
# const.personalAttributes.append(ntype)
|
||||||
|
#
|
||||||
mylist = self.database.getFamilyAttributeTypes()
|
# mylist = self.db.getFamilyAttributeTypes()
|
||||||
for type in mylist:
|
# for type in mylist:
|
||||||
if type not in const.familyAttributes:
|
# if type not in const.familyAttributes:
|
||||||
const.familyAttributes.append(type)
|
# const.familyAttributes.append(type)
|
||||||
|
#
|
||||||
mylist = self.database.getFamilyRelationTypes()
|
# mylist = self.db.getFamilyRelationTypes()
|
||||||
for type in mylist:
|
# for type in mylist:
|
||||||
if type not in const.familyRelations:
|
# if type not in const.familyRelations:
|
||||||
const.familyRelations.append(type)
|
# const.familyRelations.append(type)
|
||||||
|
#
|
||||||
GrampsCfg.save_last_file(name)
|
GrampsCfg.save_last_file(name)
|
||||||
self.gtop.get_widget("filter").set_text("")
|
self.gtop.get_widget("filter").set_text("")
|
||||||
|
|
||||||
person = self.database.getDefaultPerson()
|
person = self.db.getDefaultPerson()
|
||||||
if person:
|
if person:
|
||||||
self.active_person = person
|
self.active_person = person
|
||||||
for person in self.database.getPersonMap().values():
|
|
||||||
if self.active_person == None:
|
|
||||||
self.active_person = person
|
|
||||||
lastname = person.getPrimaryName().getSurname()
|
|
||||||
if lastname and lastname not in const.surnames:
|
|
||||||
const.surnames.append(lastname)
|
|
||||||
const.surnames.sort()
|
|
||||||
|
|
||||||
self.statusbar.set_progress(1.0)
|
self.statusbar.set_progress(1.0)
|
||||||
self.full_update()
|
self.full_update()
|
||||||
@@ -1805,19 +1795,25 @@ class Gramps:
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def load_database(self,name):
|
def load_database(self,name):
|
||||||
filename = "%s/%s" % (name,const.indexFile)
|
filename = "%s/%s" % (name,const.xmlFile)
|
||||||
if ReadXML.loadData(self.database,filename,self.load_progress) == 0:
|
if not os.path.isfile(filename):
|
||||||
|
filename = "%s/%s" % (name,const.zodbFile)
|
||||||
|
self.clear_database(1)
|
||||||
|
else:
|
||||||
|
self.clear_database(0)
|
||||||
|
|
||||||
|
if self.db.load(filename,self.load_progress) == 0:
|
||||||
return 0
|
return 0
|
||||||
return self.post_load(name)
|
return self.post_load(name)
|
||||||
|
|
||||||
def load_revision(self,f,name,revision):
|
def load_revision(self,f,name,revision):
|
||||||
filename = "%s/%s" % (name,const.indexFile)
|
filename = "%s/%s" % (name,self.db.get_base())
|
||||||
if ReadXML.loadRevision(self.database,f,filename,revision,self.load_progress) == 0:
|
if ReadXML.loadRevision(self.db,f,filename,revision,self.load_progress) == 0:
|
||||||
return 0
|
return 0
|
||||||
return self.post_load(name)
|
return self.post_load(name)
|
||||||
|
|
||||||
def setup_bookmarks(self):
|
def setup_bookmarks(self):
|
||||||
self.bookmarks = Bookmarks.Bookmarks(self.database.getBookmarks(),
|
self.bookmarks = Bookmarks.Bookmarks(self.db.getBookmarks(),
|
||||||
self.gtop.get_widget("jump_to"),
|
self.gtop.get_widget("jump_to"),
|
||||||
self.bookmark_callback)
|
self.bookmark_callback)
|
||||||
|
|
||||||
@@ -1831,67 +1827,32 @@ class Gramps:
|
|||||||
gname = Utils.phonebook_from_name
|
gname = Utils.phonebook_from_name
|
||||||
|
|
||||||
self.person_list.set_column_visibility(1,GrampsCfg.id_visible)
|
self.person_list.set_column_visibility(1,GrampsCfg.id_visible)
|
||||||
new_alt2col = {}
|
|
||||||
|
|
||||||
bsn = sort.build_sort_name
|
i = 0
|
||||||
bsd = sort.build_sort_date
|
for key in self.db.getPersonKeys():
|
||||||
for person in self.database.getPersonMap().values():
|
i = i + 1
|
||||||
|
person = self.db.getPersonMap()[key]
|
||||||
if datacomp(person):
|
if datacomp(person):
|
||||||
if self.id2col.has_key(person):
|
if self.id2col.has_key(key):
|
||||||
new_alt2col[person] = self.alt2col[person]
|
|
||||||
continue
|
continue
|
||||||
pos = (person,0)
|
pos = (key,0)
|
||||||
self.id2col[person] = pos
|
self.id2col[key] = pos
|
||||||
new_alt2col[person] = []
|
|
||||||
|
|
||||||
if person.getGender() == Person.male:
|
self.person_list.insert(0,self.db.getPersonDisplay(key))
|
||||||
gender = const.male
|
|
||||||
elif person.getGender() == Person.female:
|
|
||||||
gender = const.female
|
|
||||||
else:
|
|
||||||
gender = const.unknown
|
|
||||||
|
|
||||||
name = person.getPrimaryName()
|
|
||||||
bday = person.getBirth().getDateObj()
|
|
||||||
dday = person.getDeath().getDateObj()
|
|
||||||
sort_bday = bsd(bday)
|
|
||||||
sort_dday = bsd(dday)
|
|
||||||
qbday = bday.getQuoteDate()
|
|
||||||
qdday = dday.getQuoteDate()
|
|
||||||
pid = person.getId()
|
|
||||||
|
|
||||||
values = [gname(name,0), pid, gender, qbday, qdday,
|
|
||||||
bsn(name), sort_bday, sort_dday ]
|
|
||||||
self.person_list.insert(0,values)
|
|
||||||
self.person_list.set_row_data(0,pos)
|
self.person_list.set_row_data(0,pos)
|
||||||
|
|
||||||
if GrampsCfg.hide_altnames:
|
|
||||||
continue
|
|
||||||
|
|
||||||
for name in person.getAlternateNames():
|
|
||||||
pos = (person,1)
|
|
||||||
new_alt2col[person].append(pos)
|
|
||||||
|
|
||||||
values = [gname(name,1), pid, gender, qbday, qdday,
|
|
||||||
bsn(name), sort_bday, sort_dday]
|
|
||||||
self.person_list.insert(0,values)
|
|
||||||
self.person_list.set_row_data(0,pos)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if self.id2col.has_key(person):
|
if self.id2col.has_key(key):
|
||||||
pid = self.id2col[person]
|
del self.id2col[key]
|
||||||
del self.id2col[person]
|
|
||||||
|
|
||||||
for id in [pid] + self.alt2col[person]:
|
for id in [key]:
|
||||||
row = self.person_list.find_row_from_data(id)
|
row = self.person_list.find_row_from_data(id)
|
||||||
self.person_list.remove(row)
|
self.person_list.remove(row)
|
||||||
|
|
||||||
self.alt2col = new_alt2col
|
|
||||||
self.person_list.thaw()
|
self.person_list.thaw()
|
||||||
self.sort_person_list()
|
self.sort_person_list()
|
||||||
|
|
||||||
def on_home_clicked(self,obj):
|
def on_home_clicked(self,obj):
|
||||||
temp = self.database.getDefaultPerson()
|
temp = self.db.getDefaultPerson()
|
||||||
if temp:
|
if temp:
|
||||||
self.change_active_person(temp)
|
self.change_active_person(temp)
|
||||||
self.update_display(0)
|
self.update_display(0)
|
||||||
@@ -1921,7 +1882,7 @@ class Gramps:
|
|||||||
_('Do not change Home Person'))
|
_('Do not change Home Person'))
|
||||||
|
|
||||||
def set_person(self):
|
def set_person(self):
|
||||||
self.database.setDefaultPerson(self.active_person)
|
self.db.setDefaultPerson(self.active_person)
|
||||||
Utils.modified()
|
Utils.modified()
|
||||||
|
|
||||||
def family_up_clicked(self,obj):
|
def family_up_clicked(self,obj):
|
||||||
@@ -1969,25 +1930,25 @@ class Gramps:
|
|||||||
def export_callback(self,obj,plugin_function):
|
def export_callback(self,obj,plugin_function):
|
||||||
"""Call the export plugin, with the active person and database"""
|
"""Call the export plugin, with the active person and database"""
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
plugin_function(self.database,self.active_person)
|
plugin_function(self.db,self.active_person)
|
||||||
|
|
||||||
def import_callback(self,obj,plugin_function):
|
def import_callback(self,obj,plugin_function):
|
||||||
"""Call the import plugin"""
|
"""Call the import plugin"""
|
||||||
plugin_function(self.database,self.active_person,self.tool_callback)
|
plugin_function(self.db,self.active_person,self.tool_callback)
|
||||||
self.topWindow.set_title("Gramps - " + self.database.getSavePath())
|
self.topWindow.set_title("%s - GRAMPS" % self.db.getSavePath())
|
||||||
|
|
||||||
def on_preferences_activate(self,obj):
|
def on_preferences_activate(self,obj):
|
||||||
GrampsCfg.display_preferences_box(self.database)
|
GrampsCfg.display_preferences_box(self.db)
|
||||||
|
|
||||||
def menu_report(self,obj,task):
|
def menu_report(self,obj,task):
|
||||||
"""Call the report plugin selected from the menus"""
|
"""Call the report plugin selected from the menus"""
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
task(self.database,self.active_person)
|
task(self.db,self.active_person)
|
||||||
|
|
||||||
def menu_tools(self,obj,task):
|
def menu_tools(self,obj,task):
|
||||||
"""Call the tool plugin selected from the menus"""
|
"""Call the tool plugin selected from the menus"""
|
||||||
if self.active_person:
|
if self.active_person:
|
||||||
task(self.database,self.active_person,self.tool_callback)
|
task(self.db,self.active_person,self.tool_callback)
|
||||||
|
|
||||||
def on_main_key_release_event(self,obj,event):
|
def on_main_key_release_event(self,obj,event):
|
||||||
"""Respond to the insert and delete buttons in the person list"""
|
"""Respond to the insert and delete buttons in the person list"""
|
||||||
|
@@ -81,7 +81,7 @@ class Merge:
|
|||||||
self.person_list = database.getPersonMap().values()[:]
|
self.person_list = database.getPersonMap().values()[:]
|
||||||
|
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
self.glade_file = base + os.sep + "merge.glade"
|
self.glade_file = "%s/%s" % (base,"merge.glade")
|
||||||
top = GladeXML(self.glade_file,"dialog")
|
top = GladeXML(self.glade_file,"dialog")
|
||||||
|
|
||||||
my_menu = GtkMenu()
|
my_menu = GtkMenu()
|
||||||
|
@@ -423,7 +423,7 @@ class GedcomParser:
|
|||||||
self.update(self.people_obj,str(self.indi_count))
|
self.update(self.people_obj,str(self.indi_count))
|
||||||
self.indi_count = self.indi_count + 1
|
self.indi_count = self.indi_count + 1
|
||||||
self.person = self.db.findPerson(matches[1],self.pmap)
|
self.person = self.db.findPerson(matches[1],self.pmap)
|
||||||
self.added[self.person] = 1
|
self.added[self.person.getId()] = self.person
|
||||||
self.parse_individual()
|
self.parse_individual()
|
||||||
elif matches[2] in ["SUBM","SUBN"]:
|
elif matches[2] in ["SUBM","SUBN"]:
|
||||||
self.ignore_sub_junk(1)
|
self.ignore_sub_junk(1)
|
||||||
@@ -618,6 +618,7 @@ class GedcomParser:
|
|||||||
name.setFirstName(names[0])
|
name.setFirstName(names[0])
|
||||||
if names[2]:
|
if names[2]:
|
||||||
name.setSurname(names[2])
|
name.setSurname(names[2])
|
||||||
|
self.db.addSurname(names[2])
|
||||||
if names[4]:
|
if names[4]:
|
||||||
name.setSuffix(names[4])
|
name.setSuffix(names[4])
|
||||||
if name_cnt == 0:
|
if name_cnt == 0:
|
||||||
@@ -638,6 +639,7 @@ class GedcomParser:
|
|||||||
aka.setFirstName(names[0])
|
aka.setFirstName(names[0])
|
||||||
if names[2]:
|
if names[2]:
|
||||||
aka.setSurname(names[2])
|
aka.setSurname(names[2])
|
||||||
|
self.db.addSurname(names[2])
|
||||||
if names[4]:
|
if names[4]:
|
||||||
aka.setSuffix(names[4])
|
aka.setSuffix(names[4])
|
||||||
self.person.addAlternateName(aka)
|
self.person.addAlternateName(aka)
|
||||||
@@ -765,7 +767,7 @@ class GedcomParser:
|
|||||||
self.person.getPrimaryName().addSourceRef(source_ref)
|
self.person.getPrimaryName().addSourceRef(source_ref)
|
||||||
elif matches[1] == "REFN":
|
elif matches[1] == "REFN":
|
||||||
if intRE.match(matches[2]):
|
if intRE.match(matches[2]):
|
||||||
self.refn[self.person] = int(matches[2])
|
self.refn[self.person.getId()] = int(matches[2])
|
||||||
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
|
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
|
||||||
self.ignore_sub_junk(2)
|
self.ignore_sub_junk(2)
|
||||||
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
|
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
|
||||||
@@ -1028,6 +1030,7 @@ class GedcomParser:
|
|||||||
elif matches[1] == "FAMC":
|
elif matches[1] == "FAMC":
|
||||||
ord.setFamily(self.db.findFamily(matches[2],self.fmap))
|
ord.setFamily(self.db.findFamily(matches[2],self.fmap))
|
||||||
elif matches[1] == "PLAC":
|
elif matches[1] == "PLAC":
|
||||||
|
try:
|
||||||
val = matches[2]
|
val = matches[2]
|
||||||
if self.placemap.has_key(val):
|
if self.placemap.has_key(val):
|
||||||
place = self.placemap[val]
|
place = self.placemap[val]
|
||||||
@@ -1038,6 +1041,8 @@ class GedcomParser:
|
|||||||
self.placemap[val] = place
|
self.placemap[val] = place
|
||||||
ord.setPlace(place)
|
ord.setPlace(place)
|
||||||
self.ignore_sub_junk(level+1)
|
self.ignore_sub_junk(level+1)
|
||||||
|
except NameError:
|
||||||
|
print 'please fix the val NameError'
|
||||||
elif matches[1] == "SOUR":
|
elif matches[1] == "SOUR":
|
||||||
source_ref = SourceRef()
|
source_ref = SourceRef()
|
||||||
if matches[2] and matches[2][0] != "@":
|
if matches[2] and matches[2][0] != "@":
|
||||||
@@ -1432,6 +1437,7 @@ class GedcomParser:
|
|||||||
aka.setFirstName(names[0])
|
aka.setFirstName(names[0])
|
||||||
if names[2]:
|
if names[2]:
|
||||||
aka.setSurname(names[2])
|
aka.setSurname(names[2])
|
||||||
|
self.db.addSurname(names[2])
|
||||||
if names[4]:
|
if names[4]:
|
||||||
aka.setSuffix(names[4])
|
aka.setSuffix(names[4])
|
||||||
self.person.addAlternateName(aka)
|
self.person.addAlternateName(aka)
|
||||||
@@ -1443,6 +1449,7 @@ class GedcomParser:
|
|||||||
pass
|
pass
|
||||||
elif matches[1] == "SURN":
|
elif matches[1] == "SURN":
|
||||||
name.setSurname(matches[2])
|
name.setSurname(matches[2])
|
||||||
|
self.db.addSurname(matches[2])
|
||||||
elif matches[1] == "TITL":
|
elif matches[1] == "TITL":
|
||||||
name.setSuffix(matches[2])
|
name.setSuffix(matches[2])
|
||||||
elif matches[1] == "NSFX":
|
elif matches[1] == "NSFX":
|
||||||
@@ -1458,6 +1465,7 @@ class GedcomParser:
|
|||||||
else:
|
else:
|
||||||
name = Name()
|
name = Name()
|
||||||
name.setSurname(lname[-1])
|
name.setSurname(lname[-1])
|
||||||
|
self.db.addSurname(lname[-1])
|
||||||
name.setFirstName(string.join(lname[0:l-1]))
|
name.setFirstName(string.join(lname[0:l-1]))
|
||||||
self.person.addAlternateName(name)
|
self.person.addAlternateName(name)
|
||||||
elif matches[1] == "SOUR":
|
elif matches[1] == "SOUR":
|
||||||
@@ -1707,35 +1715,34 @@ class GedcomParser:
|
|||||||
|
|
||||||
def resolve_refns(self):
|
def resolve_refns(self):
|
||||||
prefix = self.db.iprefix
|
prefix = self.db.iprefix
|
||||||
pmap = self.db.getPersonMap()
|
|
||||||
renamed = []
|
renamed = []
|
||||||
index = 0
|
index = 0
|
||||||
new_pmax = self.db.pmapIndex
|
new_pmax = self.db.pmapIndex
|
||||||
for person in self.added.keys():
|
pmap = self.db.getPersonMap()
|
||||||
|
for pid, person in self.added.items():
|
||||||
index = index + 1
|
index = index + 1
|
||||||
if self.refn.has_key(person):
|
if self.refn.has_key(pid):
|
||||||
val = self.refn[person]
|
val = self.refn[pid]
|
||||||
new_key = prefix % val
|
new_key = prefix % val
|
||||||
new_pmax = max(new_pmax,val)
|
new_pmax = max(new_pmax,val)
|
||||||
|
|
||||||
# new ID is not used
|
# new ID is not used
|
||||||
if not pmap.has_key(new_key):
|
if not pmap.has_key(new_key):
|
||||||
del pmap[person.getId()]
|
self.db.removePerson(person.getId())
|
||||||
pmap[new_key] = person
|
|
||||||
person.setId(new_key)
|
person.setId(new_key)
|
||||||
|
self.db.addPersonAs(person)
|
||||||
else:
|
else:
|
||||||
tp = pmap[new_key]
|
tp = pmap[new_key]
|
||||||
# same person, just change it
|
# same person, just change it
|
||||||
if person == tp:
|
if person == tp:
|
||||||
del pmap[person.getId()]
|
self.db.removePerson(person.getId())
|
||||||
pmap[new_key] = person
|
|
||||||
person.setId(new_key)
|
person.setId(new_key)
|
||||||
|
self.db.addPersonAs(person)
|
||||||
# person currently using it was just added, change it
|
# person currently using it was just added, change it
|
||||||
elif self.added.has_key(tp):
|
elif self.added.has_key(tp.getId()):
|
||||||
del pmap[person.getId()]
|
self.db.removePerson(person.getId())
|
||||||
pmap[new_key] = person
|
|
||||||
person.setId(new_key)
|
person.setId(new_key)
|
||||||
self.db.addPerson(tp)
|
self.db.addPersonAs(person)
|
||||||
|
|
||||||
self.db.pmapIndex = new_pmax
|
self.db.pmapIndex = new_pmax
|
||||||
|
|
||||||
|
@@ -44,7 +44,10 @@ def build_sort_name(n):
|
|||||||
"""Builds a name from a RelLib.Name instance that is suitable for
|
"""Builds a name from a RelLib.Name instance that is suitable for
|
||||||
use as a sort key in a GtkCList. The name is converted to upper case
|
use as a sort key in a GtkCList. The name is converted to upper case
|
||||||
to provide for case-insenstive sorting"""
|
to provide for case-insenstive sorting"""
|
||||||
|
if n.Surname:
|
||||||
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
|
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
|
||||||
|
else:
|
||||||
|
return "%s" % chr(255)
|
||||||
|
|
||||||
def build_sort_date(n):
|
def build_sort_date(n):
|
||||||
"""Builds a date from a Date.Date instance that is suitable for
|
"""Builds a date from a Date.Date instance that is suitable for
|
||||||
|
Reference in New Issue
Block a user