Start of new type classes

svn: r6340
This commit is contained in:
Don Allingham 2006-04-14 04:36:25 +00:00
parent 5982941741
commit 2532be9de8
34 changed files with 462 additions and 164 deletions

View File

@ -1,4 +1,36 @@
2006-04-13 Don Allingham <don@gramps-project.org> 2006-04-13 Don Allingham <don@gramps-project.org>
* src/DataViews/_FamilyView.py: Type class support
* src/DataViews/_PedigreeView.py: Type class support
* src/GrampsDb/_ReadGedcom.py: Type class support
* src/GrampsDb/_ReadXML.py: Type class support
* src/GrampsDb/_DbUtils.py: Type class support
* src/GrampsDb/_ConstXML.py: Type class support
* src/GrampsDb/_WriteXML.py: Type class support
* src/GrampsDb/_GrampsBSDDB.py: Type class support
* src/RelLib/__init__.py: Type class support
* src/RelLib/_Person.py: Type class support
* src/RelLib/_ChildRef.py: Type class support
* src/RelLib/_Name.py: Type class support
* src/Editors/_EditPerson.py: Type class support
* src/Editors/_EditName.py: Type class support
* src/Editors/_EditFamily.py: Type class support
* src/plugins/DumpGenderStats.py: Type class support
* src/plugins/ChangeNames.py: Type class support
* src/plugins/TestcaseGenerator.py: Type class support
* src/plugins/GraphViz.py: Type class support
* src/plugins/Check.py: Type class support
* src/plugins/NavWebPage.py: Type class support
* src/plugins/ChangeTypes.py: Type class support
* src/plugins/summary.glade: Type class support
* src/plugins/PatchNames.py: Type class support
* src/DisplayTabs.py: Type class support
* src/GrampsWidgets.py: Type class support
* src/Utils.py: Type class support
* src/ScratchPad.py: Type class support
* src/GenericFilter.py: Type class support
* src/RelLib/ChildRefType.py: Type class support
* src/RelLib/GrampsType.py: Type class support
* src/RelLib/NameType.py: Type class support
* src/GrampsDb/_ReadGedcom.py: handle ASSO tag * src/GrampsDb/_ReadGedcom.py: handle ASSO tag
* src/GrampsDb/_GedTokens.py: handle ASSO tag * src/GrampsDb/_GedTokens.py: handle ASSO tag
* example/gedcom/sample.ged: add ASSO tag * example/gedcom/sample.ged: add ASSO tag

View File

@ -701,8 +701,8 @@ class FamilyView(PageView.PersonNavView):
if family: if family:
person = self.dbstate.db.get_person_from_handle(self.dbstate.active.handle) person = self.dbstate.db.get_person_from_handle(self.dbstate.active.handle)
GrampsDb.add_child_to_family(family, child, GrampsDb.add_child_to_family(family, child,
(RelLib.ChildRef.CHILD_BIRTH,'') RelLib.ChildRef(),
(RelLib.ChildRef.CHILD_BIRTH,'')) RelLib.ChildRef())
def add_parent_family(self, obj, event, handle): def add_parent_family(self, obj, event, handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:

View File

@ -1127,8 +1127,8 @@ class PedigreeView(PageView.PersonNavView):
if family != None: if family != None:
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
if child_ref.ref == person.handle: if child_ref.ref == person.handle:
mrel = child_ref.mrel != RelLib.ChildRef.CHILD_BIRTH mrel = child_ref.mrel != RelLib.ChildRefType.BIRTH
frel = child_ref.frel != RelLib.ChildRef.CHILD_BIRTH frel = child_ref.frel != RelLib.ChildRefType.BIRTH
lst[index] = (person,val,family) lst[index] = (person,val,family)
father_handle = family.get_father_handle() father_handle = family.get_father_handle()

View File

@ -1890,10 +1890,10 @@ class ChildModel(gtk.ListStore):
return self.family.get_child_ref_list() return self.family.get_child_ref_list()
def column_father_rel(self, data): def column_father_rel(self, data):
return Utils.format_child_relation(data.get_father_relation()) return str(data.get_father_relation())
def column_mother_rel(self, data): def column_mother_rel(self, data):
return Utils.format_child_relation(data.get_mother_relation()) return str(data.get_mother_relation())
def column_birth_day(self, data): def column_birth_day(self, data):
event_ref = data.get_birth_ref() event_ref = data.get_birth_ref()
@ -2053,13 +2053,10 @@ class NameModel(gtk.ListStore):
for obj in obj_list: for obj in obj_list:
self.append(row=[ self.append(row=[
NameDisplay.displayer.display_name(obj), NameDisplay.displayer.display_name(obj),
self.type_name(obj), str(obj.get_type()),
obj, obj,
]) ])
def type_name(self, obj):
return Utils.format_name_type(obj.get_type())
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# AddressModel # AddressModel

View File

@ -155,15 +155,22 @@ class ChildEmbedList(EmbeddedList):
if not pair[0]: if not pair[0]:
continue continue
name = self._column_names[pair[1]][0] name = self._column_names[pair[1]][0]
if pair[1] == 4 or pair[1] == 5: if pair[1] == 4:
render = TypeCellRenderer(Utils.child_relations) render = TypeCellRenderer(RelLib.ChildRefType().get_map())
render.connect('edited',self.frel_edited)
column = gtk.TreeViewColumn(name, render, text=pair[1]) column = gtk.TreeViewColumn(name, render, text=pair[1])
column.set_min_width(100)
elif pair[1] == 5:
render = TypeCellRenderer(RelLib.ChildRefType().get_map())
render.connect('edited',self.mrel_edited)
column = gtk.TreeViewColumn(name, render, text=pair[1])
column.set_min_width(100)
else: else:
render = gtk.CellRendererText() render = gtk.CellRendererText()
column = gtk.TreeViewColumn(name, render, text=pair[1]) column = gtk.TreeViewColumn(name, render, text=pair[1])
column.set_min_width(50)
column.set_resizable(True) column.set_resizable(True)
column.set_min_width(40)
column.set_sort_column_id(self._column_names[pair[1]][1]) column.set_sort_column_id(self._column_names[pair[1]][1])
self.columns.append(column) self.columns.append(column)
self.tree.append_column(column) self.tree.append_column(column)
@ -177,6 +184,17 @@ class ChildEmbedList(EmbeddedList):
""" """
return len(self.family.get_child_ref_list()) == 0 return len(self.family.get_child_ref_list()) == 0
def mrel_edited(self, renderer, index, value):
ref = self.family.get_child_ref_list()[int(index)]
new_type = RelLib.ChildRefType(value)
print "Before", str(new_type)
ref.set_mother_relation(new_type)
print "After", str(ref.get_mother_relation())
def frel_edited(self, renderer, index, value):
ref = self.family.get_child_ref_list()[int(index)]
ref.set_father_relation(RelLib.ChildRefType(value))
def get_data(self): def get_data(self):
""" """
Normally, get_data returns a list. However, we return family Normally, get_data returns a list. However, we return family
@ -848,8 +866,8 @@ class EditFamily(EditPrimary):
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
person.add_parent_family_handle( person.add_parent_family_handle(
self.obj.handle, self.obj.handle,
(RelLib.ChildRef.CHILD_BIRTH,''), RelLib.ChildRefType(),
(RelLib.ChildRef.CHILD_BIRTH,''), RelLib.ChildRefType(),
) )
self.db.commit_person(person,trans) self.db.commit_person(person,trans)

View File

@ -144,9 +144,10 @@ class EditName(EditSecondary):
self.top.get_widget("date_stat"), self.top.get_widget("date_stat"),
self.obj.get_date_object(),self.window) self.obj.get_date_object(),self.window)
self.obj_combo = MonitoredType( self.obj_combo = MonitoredDataType(
self.top.get_widget("name_type"), self.obj.set_type, self.top.get_widget("name_type"),
self.obj.get_type, dict(Utils.name_types), RelLib.Name.CUSTOM) self.obj.set_type,
self.obj.get_type)
self.privacy = PrivacyButton( self.privacy = PrivacyButton(
self.top.get_widget("priv"), self.obj) self.top.get_widget("priv"), self.obj)

View File

@ -169,12 +169,10 @@ class EditPerson(EditPrimary):
), ),
self.db.readonly) self.db.readonly)
self.ntype_field = GrampsWidgets.MonitoredType( self.ntype_field = GrampsWidgets.MonitoredDataType(
self.top.get_widget("ntype"), self.top.get_widget("ntype"),
self.pname.set_type, self.pname.set_type,
self.pname.get_type, self.pname.get_type,
dict(Utils.name_types),
RelLib.Name.CUSTOM,
self.db.readonly) self.db.readonly)
self.marker = GrampsWidgets.MonitoredType( self.marker = GrampsWidgets.MonitoredType(

View File

@ -1448,8 +1448,8 @@ class HaveAltFamilies(Rule):
def apply(self,db,person): def apply(self,db,person):
for (fam,rel1,rel2) in person.get_parent_family_handle_list(): for (fam,rel1,rel2) in person.get_parent_family_handle_list():
if rel1 == RelLib.ChildRef.CHILD_ADOPTED \ if rel1 == RelLib.ChildRefType.CHILD_ADOPTED \
or rel2 == RelLib.ChildRef.CHILD_ADOPTED: or rel2 == RelLib.ChildRefType.CHILD_ADOPTED:
return True return True
return False return False

View File

@ -33,12 +33,12 @@ import RelLib
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
child_relations = ( child_relations = (
(RelLib.ChildRef.CHILD_BIRTH , "Birth"), (RelLib.ChildRefType.BIRTH , "Birth"),
(RelLib.ChildRef.CHILD_ADOPTED , "Adopted"), (RelLib.ChildRefType.ADOPTED , "Adopted"),
(RelLib.ChildRef.CHILD_STEPCHILD , "Stepchild"), (RelLib.ChildRefType.STEPCHILD , "Stepchild"),
(RelLib.ChildRef.CHILD_SPONSORED , "Sponsored"), (RelLib.ChildRefType.SPONSORED , "Sponsored"),
(RelLib.ChildRef.CHILD_FOSTER , "Foster"), (RelLib.ChildRefType.FOSTER , "Foster"),
(RelLib.ChildRef.CHILD_UNKNOWN , "Unknown"), (RelLib.ChildRefType.UNKNOWN , "Unknown"),
) )
events = ( events = (
@ -111,10 +111,10 @@ family_relations = (
) )
name_types = ( name_types = (
(RelLib.Name.UNKNOWN , "Unknown"), (RelLib.NameType.UNKNOWN , "Unknown"),
(RelLib.Name.AKA , "Also Known As"), (RelLib.NameType.AKA , "Also Known As"),
(RelLib.Name.BIRTH , "Birth Name"), (RelLib.NameType.BIRTH , "Birth Name"),
(RelLib.Name.MARRIED , "Married Name"), (RelLib.NameType.MARRIED , "Married Name"),
) )
source_media_types = ( source_media_types = (
@ -175,11 +175,11 @@ url_types = (
# mapping from the tuple collection to the appropriate CUSTOM integer # mapping from the tuple collection to the appropriate CUSTOM integer
custom_types = { custom_types = {
child_relations : RelLib.ChildRef.CHILD_CUSTOM, child_relations : RelLib.ChildRefType.CUSTOM,
events : RelLib.Event.CUSTOM, events : RelLib.Event.CUSTOM,
attributes : RelLib.Attribute.CUSTOM, attributes : RelLib.Attribute.CUSTOM,
family_relations : RelLib.Family.CUSTOM, family_relations : RelLib.Family.CUSTOM,
name_types : RelLib.Name.CUSTOM, name_types : RelLib.NameType.CUSTOM,
source_media_types : RelLib.RepoRef.CUSTOM, source_media_types : RelLib.RepoRef.CUSTOM,
event_roles : RelLib.EventRef.CUSTOM, event_roles : RelLib.EventRef.CUSTOM,
repository_types : RelLib.Repository.CUSTOM, repository_types : RelLib.Repository.CUSTOM,

View File

@ -119,8 +119,8 @@ def remove_child_from_family(db, person_handle, family_handle, trans=None):
def add_child_to_family(db, family, child, def add_child_to_family(db, family, child,
mrel=(RelLib.ChildRef.CHILD_BIRTH,''), mrel=RelLib.ChildRefType(),
frel=(RelLib.ChildRef.CHILD_BIRTH,''), frel=RelLib.ChildRefType(),
trans=None): trans=None):
family.add_child_handle(child.handle) family.add_child_handle(child.handle)

View File

@ -1401,20 +1401,20 @@ class GrampsBSDDB(GrampsDbBase):
# In all Name instances, convert type from string to a tuple # In all Name instances, convert type from string to a tuple
name_conversion = { name_conversion = {
"Also Known As" : (Name.AKA,""), "Also Known As" : (NameType.AKA,""),
"Birth Name" : (Name.BIRTH,""), "Birth Name" : (NameType.BIRTH,""),
"Married Name" : (Name.MARRIED,""), "Married Name" : (NameType.MARRIED,""),
"Other Name" : (Name.CUSTOM,_("Other Name")), "Other Name" : (NameType.CUSTOM,_("Other Name")),
} }
for name in [person.primary_name] + person.alternate_names: for name in [person.primary_name] + person.alternate_names:
old_type = name.type old_type = name.type
if old_type: if old_type:
if name_conversion.has_key(old_type): if name_conversion.has_key(old_type):
new_type = name_conversion[old_type] new_type = NameType(name_conversion[old_type])
else: else:
new_type = (Name.CUSTOM,old_type) new_type = NameType((NameType.CUSTOM,old_type))
else: else:
new_type = (Name.UNKNOWN,"") new_type = NameType((NameType.UNKNOWN,""))
name.type = new_type name.type = new_type
# Change parent_family_list into list of handles # Change parent_family_list into list of handles

View File

@ -120,6 +120,10 @@ ANSEL = 1
UNICODE = 2 UNICODE = 2
UPDATE = 25 UPDATE = 25
_TYPE_BIRTH = RelLib.ChildRefType()
_TYPE_ADOPT = RelLib.ChildRefType(RelLib.ChildRefType.ADOPTED)
_TYPE_FOSTER = RelLib.ChildRefType(RelLib.ChildRefType.FOSTER)
file_systems = { file_systems = {
'VFAT' : _('Windows 9x file system'), 'VFAT' : _('Windows 9x file system'),
'FAT' : _('Windows 9x file system'), 'FAT' : _('Windows 9x file system'),
@ -128,16 +132,17 @@ file_systems = {
"SMBFS" : _('Networked Windows file system') "SMBFS" : _('Networked Windows file system')
} }
rel_types = ((RelLib.ChildRef.CHILD_BIRTH,''), rel_types = (RelLib.ChildRefType.BIRTH,
(RelLib.ChildRef.CHILD_UNKNOWN,''), RelLib.ChildRefType.UNKNOWN,
(RelLib.ChildRef.CHILD_NONE,'')) RelLib.ChildRefType.NONE,
)
pedi_type = { pedi_type = {
'birth' : (RelLib.ChildRef.CHILD_BIRTH,''), 'birth' : RelLib.ChildRefType(),
'natural': (RelLib.ChildRef.CHILD_BIRTH,''), 'natural': RelLib.ChildRefType(),
'step' : (RelLib.ChildRef.CHILD_ADOPTED,''), 'step' : _TYPE_ADOPT,
'adopted': (RelLib.ChildRef.CHILD_ADOPTED,''), 'adopted': _TYPE_ADOPT,
'foster' : (RelLib.ChildRef.CHILD_FOSTER,''), 'foster' : _TYPE_FOSTER,
} }
lds_status = { lds_status = {
@ -1046,8 +1051,8 @@ class GedcomParser:
self.barf(level+1) self.barf(level+1)
def parse_ftw_relations(self,level): def parse_ftw_relations(self,level):
mrel = (RelLib.ChildRef.CHILD_BIRTH,'') mrel = RelLib.ChildRefType()
frel = (RelLib.ChildRef.CHILD_BIRTH,'') frel = RelLib.ChildRefType()
while True: while True:
matches = self.get_next() matches = self.get_next()
@ -1056,17 +1061,17 @@ class GedcomParser:
return (mrel,frel) return (mrel,frel)
# FTW # FTW
elif matches[1] == TOKEN__FREL: elif matches[1] == TOKEN__FREL:
frel = pedi_type.get(matches[2].lower(),(RelLib.ChildRef.CHILD_BIRTH,'')) frel = pedi_type.get(matches[2].lower(),_TYPE_BIRTH)
# FTW # FTW
elif matches[1] == TOKEN__MREL: elif matches[1] == TOKEN__MREL:
mrel = pedi_type.get(matches[2].lower(),(RelLib.ChildRef.CHILD_BIRTH,'')) mrel = pedi_type.get(matches[2].lower(),_TYPE_BIRTH)
elif matches[1] == TOKEN_ADOP: elif matches[1] == TOKEN_ADOP:
mrel = (RelLib.ChildRef.CHILD_ADOPTED,'') mrel = _TYPE_ADOPT
frel = (RelLib.ChildRef.CHILD_ADOPTED,'') frel = _TYPE_ADOPT
# Legacy # Legacy
elif matches[1] == TOKEN__STAT: elif matches[1] == TOKEN__STAT:
mrel = (RelLib.ChildRef.CHILD_BIRTH,'') mrel = _TYPE_BIRTH
frel = (RelLib.ChildRef.CHILD_BIRTH,'') frel = _TYPE_BIRTH
# Legacy _PREF # Legacy _PREF
elif matches[1][0] == TOKEN_UNKNOWN: elif matches[1][0] == TOKEN_UNKNOWN:
pass pass
@ -1226,7 +1231,7 @@ class GedcomParser:
return None return None
def parse_famc_type(self,level,person): def parse_famc_type(self,level,person):
ftype = (RelLib.ChildRef.CHILD_BIRTH,'') ftype = _TYPE_BIRTH
note = "" note = ""
while True: while True:
matches = self.get_next() matches = self.get_next()
@ -1528,7 +1533,7 @@ class GedcomParser:
if self.person.get_main_parents_family_handle() == handle: if self.person.get_main_parents_family_handle() == handle:
self.person.set_main_parent_family_handle(None) self.person.set_main_parent_family_handle(None)
self.person.add_parent_family_handle(handle) self.person.add_parent_family_handle(handle)
if mrel[0] != RelLib.ChildRef.BIRTH or frel[0] != RelLib.ChildRef.BIRTH: if mrel != RelLib.ChildRefType.BIRTH or frel != RelLib.ChildRefType.BIRTH:
print "NOT FIXED YET" print "NOT FIXED YET"
elif matches[1] == TOKEN_PLAC: elif matches[1] == TOKEN_PLAC:
val = matches[2] val = matches[2]
@ -1555,8 +1560,8 @@ class GedcomParser:
self.barf(level+1) self.barf(level+1)
def parse_adopt_famc(self,level): def parse_adopt_famc(self,level):
mrel = RelLib.ChildRef.CHILD_ADOPTED mrel = _TYPE_ADOPT
frel = RelLib.ChildRef.CHILD_ADOPTED frel = _TYPE_ADOPT
while True: while True:
matches = self.get_next() matches = self.get_next()
if int(matches[0]) < level: if int(matches[0]) < level:
@ -1564,9 +1569,9 @@ class GedcomParser:
return (mrel,frel) return (mrel,frel)
elif matches[1] == TOKEN_ADOP: elif matches[1] == TOKEN_ADOP:
if matches[2] == "HUSB": if matches[2] == "HUSB":
mrel = RelLib.ChildRef.CHILD_BIRTH mrel = _TYPE_BIRTH
elif matches[2] == "WIFE": elif matches[2] == "WIFE":
frel = RelLib.ChildRef.CHILD_BIRTH frel = _TYPE_BIRTH
else: else:
self.barf(level+1) self.barf(level+1)
return None return None
@ -2117,7 +2122,7 @@ class GedcomParser:
if f[0] == handle: if f[0] == handle:
break break
else: else:
if ftype in rel_types: if int(ftype) in rel_types:
state.person.add_parent_family_handle(handle) state.person.add_parent_family_handle(handle)
else: else:
if state.person.get_main_parents_family_handle() == handle: if state.person.get_main_parents_family_handle() == handle:

View File

@ -917,8 +917,8 @@ class GrampsParser:
frel = _ConstXML.tuple_from_xml(_ConstXML.child_relations, frel = _ConstXML.tuple_from_xml(_ConstXML.child_relations,
attrs.get('frel','Birth')) attrs.get('frel','Birth'))
if mrel[0] != RelLib.ChildRef.CHILD_BIRTH or \ if mrel != RelLib.ChildRefType.CHILD_BIRTH or \
frel[0] != RelLib.ChildRef.CHILD_BIRTH: frel != RelLib.ChildRefType.CHILD_BIRTH:
childref = RelLib.ChildRef() childref = RelLib.ChildRef()
childref.ref = self.person.handle childref.ref = self.person.handle
childref.set_mother_relation(mrel) childref.set_mother_relation(mrel)

View File

@ -424,12 +424,12 @@ class XmlWriter:
else: else:
continue continue
if mval[0] != RelLib.ChildRef.CHILD_BIRTH: if mval != RelLib.ChildRefType.BIRTH:
mrel=' mrel="%s"' % _ConstXML.str_for_xml( mrel=' mrel="%s"' % _ConstXML.str_for_xml(
_ConstXML.child_relations,mval) _ConstXML.child_relations,mval)
else: else:
mrel='' mrel=''
if fval[0] != RelLib.ChildRef.CHILD_BIRTH: if fval != RelLib.ChildRefType.BIRTH:
frel=' frel="%s"' % _ConstXML.str_for_xml( frel=' frel="%s"' % _ConstXML.str_for_xml(
_ConstXML.child_relations,fval) _ConstXML.child_relations,fval)
else: else:

View File

@ -343,6 +343,39 @@ class MonitoredType:
def on_change(self, obj): def on_change(self, obj):
self.set_val(self.sel.get_values()) self.set_val(self.sel.get_values())
class MonitoredDataType:
def __init__(self, obj, set_val, get_val, readonly=False, custom_values=None):
self.set_val = set_val
self.get_val = get_val
self.obj = obj
val = get_val()
if val:
default = int(val)
else:
default = None
self.sel = AutoComp.StandardCustomSelector(
get_val().get_map(),
obj,
get_val().get_custom(),
default,
additional=custom_values)
self.set_val(self.sel.get_values())
self.obj.set_sensitive(not readonly)
self.obj.connect('changed', self.on_change)
def update(self):
if self.get_val():
self.sel.set_values(self.get_val())
def on_change(self, obj):
self.set_val(self.sel.get_values())
class MonitoredMenu: class MonitoredMenu:
def __init__(self, obj, set_val, get_val, mapping, def __init__(self, obj, set_val, get_val, mapping,

View File

@ -18,6 +18,7 @@ pkgdata_PYTHON = \
_EventRef.py\ _EventRef.py\
_Family.py\ _Family.py\
_GenderStats.py\ _GenderStats.py\
_GrampsType.py\
__init__.py\ __init__.py\
_LdsOrdBase.py\ _LdsOrdBase.py\
_LdsOrd.py\ _LdsOrd.py\
@ -27,6 +28,7 @@ pkgdata_PYTHON = \
_MediaObject.py\ _MediaObject.py\
_MediaRef.py\ _MediaRef.py\
_Name.py\ _Name.py\
_NameType.py\
_NoteBase.py\ _NoteBase.py\
_Note.py\ _Note.py\
_Person.py\ _Person.py\
@ -47,7 +49,8 @@ pkgdata_PYTHON = \
_Witness.py\ _Witness.py\
_SourceBase.py\ _SourceBase.py\
_RefBase.py\ _RefBase.py\
_ChildRef.py _ChildRef.py\
_ChildRefType.py
pkgpyexecdir = @pkgpyexecdir@/RelLib pkgpyexecdir = @pkgpyexecdir@/RelLib
pkgpythondir = @pkgpythondir@/RelLib pkgpythondir = @pkgpythondir@/RelLib

View File

@ -34,6 +34,7 @@ from _PrivacyBase import PrivacyBase
from _SourceBase import SourceBase from _SourceBase import SourceBase
from _NoteBase import NoteBase from _NoteBase import NoteBase
from _RefBase import RefBase from _RefBase import RefBase
from _ChildRefType import ChildRefType
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -49,15 +50,6 @@ class ChildRef(BaseObject,PrivacyBase,SourceBase,NoteBase,RefBase):
Examples would be: godparent, friend, etc. Examples would be: godparent, friend, etc.
""" """
CHILD_NONE = 0
CHILD_BIRTH = 1
CHILD_ADOPTED = 2
CHILD_STEPCHILD = 3
CHILD_SPONSORED = 4
CHILD_FOSTER = 5
CHILD_UNKNOWN = 6
CHILD_CUSTOM = 7
def __init__(self,source=None): def __init__(self,source=None):
BaseObject.__init__(self) BaseObject.__init__(self)
PrivacyBase.__init__(self,source) PrivacyBase.__init__(self,source)
@ -68,22 +60,25 @@ class ChildRef(BaseObject,PrivacyBase,SourceBase,NoteBase,RefBase):
self.frel = source.frel self.frel = source.frel
self.mrel = source.mrel self.mrel = source.mrel
else: else:
self.frel = (ChildRef.CHILD_BIRTH,'') self.frel = ChildRefType()
self.mrel = (ChildRef.CHILD_BIRTH,'') self.mrel = ChildRefType()
def serialize(self): def serialize(self):
return (PrivacyBase.serialize(self), return (PrivacyBase.serialize(self),
SourceBase.serialize(self), SourceBase.serialize(self),
NoteBase.serialize(self), NoteBase.serialize(self),
RefBase.serialize(self), RefBase.serialize(self),
self.frel,self.mrel) self.frel.serialize(),
self.mrel.serialize())
def unserialize(self,data): def unserialize(self,data):
(privacy,source_list,note,ref,self.frel,self.mrel) = data (privacy,source_list,note,ref,frel,mrel) = data
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self,note)
RefBase.unserialize(self,ref) RefBase.unserialize(self,ref)
self.frel.unserialize(frel)
self.mrel.unserialize(mrel)
return self return self
def get_text_data_list(self): def get_text_data_list(self):
@ -93,7 +88,7 @@ class ChildRef(BaseObject,PrivacyBase,SourceBase,NoteBase,RefBase):
@return: Returns the list of all textual attributes of the object. @return: Returns the list of all textual attributes of the object.
@rtype: list @rtype: list
""" """
return [self.rel] return [self.rel, str(self.frel), str(mrel)]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -132,6 +127,7 @@ class ChildRef(BaseObject,PrivacyBase,SourceBase,NoteBase,RefBase):
def set_mother_relation(self,rel): def set_mother_relation(self,rel):
"""Sets relation between the person and mother""" """Sets relation between the person and mother"""
assert(isinstance(rel,ChildRefType))
self.mrel = rel self.mrel = rel
def get_mother_relation(self): def get_mother_relation(self):
@ -140,6 +136,7 @@ class ChildRef(BaseObject,PrivacyBase,SourceBase,NoteBase,RefBase):
def set_father_relation(self,frel): def set_father_relation(self,frel):
"""Sets relation between the person and father""" """Sets relation between the person and father"""
assert(isinstance(frel,ChildRefType))
self.frel = frel self.frel = frel
def get_father_relation(self): def get_father_relation(self):

View File

@ -0,0 +1,56 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from _GrampsType import GrampsType, init_map
from gettext import gettext as _
class ChildRefType(GrampsType):
NONE = 0
BIRTH = 1
ADOPTED = 2
STEPCHILD = 3
SPONSORED = 4
FOSTER = 5
UNKNOWN = 6
CUSTOM = 7
_CUSTOM = CUSTOM
_DEFAULT = BIRTH
_I2SMAP = {
NONE : _("None"),
BIRTH : _("Birth"),
ADOPTED : _("Adopted"),
STEPCHILD : _("Stepchild"),
SPONSORED : _("Sponsored"),
FOSTER : _("Foster"),
UNKNOWN : _("Unknown"),
CUSTOM : _("Custom"),
}
_S2IMAP = init_map(_I2SMAP)
def __init__(self, value=None):
GrampsType.__init__(self, value)

View File

@ -0,0 +1,96 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from gettext import gettext as _
def init_map(data):
new_data = {}
for i in data.keys():
new_data[data[i]] = i
return new_data
class GrampsType:
_CUSTOM = 0
_DEFAULT = 0
_I2SMAP = {}
_S2IMAP = init_map(_I2SMAP)
def __init__(self, value=None):
self.set(value)
def set(self, value):
if type(value) == tuple:
self.val = value[0]
self.string = value[1]
elif type(value) == int:
self.val = value
self.string = ''
elif type(value) == str:
self.val = self._S2IMAP.get(value,self._CUSTOM)
if self.val == self._CUSTOM:
self.string = value
else:
self.string = ''
else:
self.val = self._DEFAULT
self.string = ''
def serialize(self):
return (self.val, self.string)
def unserialize(self, data):
self.val, self.string = data
def __str__(self):
if self.val == self._CUSTOM:
return self.string
else:
return self._I2SMAP.get(self.val,_('UNKNOWN'))
def __int__(self):
return self.val
def get_map(self):
return self._I2SMAP
def get_custom(self):
return self._CUSTOM
def __cmp__(self, value):
if type(value) == int:
return cmp(self.val,value)
elif type(value) == str:
if self.val == self._CUSTOM:
return cmp(self.string,value)
else:
return cmp(self._I2SMAP.get(self.val),value)
elif type(value) == tuple:
return cmp((self.val,self.string),value)
else:
if value.val == self._CUSTOM:
return cmp(self.string,value.string)
else:
return cmp(self.val,value.val)

View File

@ -41,6 +41,7 @@ from _PrivacyBase import PrivacyBase
from _SourceBase import SourceBase from _SourceBase import SourceBase
from _NoteBase import NoteBase from _NoteBase import NoteBase
from _DateBase import DateBase from _DateBase import DateBase
from _NameType import NameType
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -60,20 +61,15 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
PTFN = 3 # patronymic last name PTFN = 3 # patronymic last name
FN = 4 # first name FN = 4 # first name
UNKNOWN = -1
CUSTOM = 0
AKA = 1
BIRTH = 2
MARRIED = 3
def __init__(self,source=None,data=None): def __init__(self,source=None,data=None):
"""creates a new Name instance, copying from the source if provided""" """creates a new Name instance, copying from the source if provided"""
BaseObject.__init__(self) BaseObject.__init__(self)
if data: if data:
(privacy,source_list,note,date, (privacy,source_list,note,date,
self.first_name,self.surname,self.suffix,self.title, self.first_name,self.surname,self.suffix,self.title,
self.type,self.prefix,self.patronymic,self.sname, name_type,self.prefix,self.patronymic,self.sname,
self.group_as,self.sort_as,self.display_as) = data self.group_as,self.sort_as,self.display_as) = data
self.type = NameType(name_type)
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self,note)
@ -103,7 +99,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
self.surname = "" self.surname = ""
self.suffix = "" self.suffix = ""
self.title = "" self.title = ""
self.type = (Name.BIRTH,"") self.type = NameType()
self.prefix = "" self.prefix = ""
self.patronymic = "" self.patronymic = ""
self.sname = '@' self.sname = '@'
@ -117,14 +113,15 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
NoteBase.serialize(self), NoteBase.serialize(self),
DateBase.serialize(self), DateBase.serialize(self),
self.first_name,self.surname,self.suffix,self.title, self.first_name,self.surname,self.suffix,self.title,
self.type,self.prefix,self.patronymic,self.sname, self.type.serialize(),self.prefix,self.patronymic,self.sname,
self.group_as,self.sort_as,self.display_as) self.group_as,self.sort_as,self.display_as)
def unserialize(self,data): def unserialize(self,data):
(privacy,source_list,note,date, (privacy,source_list,note,date,
self.first_name,self.surname,self.suffix,self.title, self.first_name,self.surname,self.suffix,self.title,
self.type,self.prefix,self.patronymic,self.sname, name_type,self.prefix,self.patronymic,self.sname,
self.group_as,self.sort_as,self.display_as) = data self.group_as,self.sort_as,self.display_as) = data
self.type = NameType(name_type)
PrivacyBase.unserialize(self,privacy) PrivacyBase.unserialize(self,privacy)
SourceBase.unserialize(self,source_list) SourceBase.unserialize(self,source_list)
NoteBase.unserialize(self,note) NoteBase.unserialize(self,note)
@ -139,7 +136,7 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
@rtype: list @rtype: list
""" """
return [self.first_name,self.surname,self.suffix,self.title, return [self.first_name,self.surname,self.suffix,self.title,
self.type[1],self.prefix,self.patronymic] str(self.type),self.prefix,self.patronymic]
def get_text_data_child_list(self): def get_text_data_child_list(self):
""" """
@ -237,15 +234,10 @@ class Name(BaseObject,PrivacyBase,SourceBase,NoteBase,DateBase):
def set_type(self,the_type): def set_type(self,the_type):
"""sets the type of the Name instance""" """sets the type of the Name instance"""
if not type(the_type) == tuple: if type(the_type) == tuple:
if the_type in [self.UNKNOWN,self.CUSTOM,self.AKA,self.BIRTH,self.MARRIED]: self.type = NameType(the_type)
warn( "set_type now takes a tuple", DeprecationWarning, 2) else:
# Wrapper for old API self.type = the_type
# remove when transitition done.
the_type = (the_type,'')
else:
assert type(the_type) == tuple
self.type = the_type
def get_type(self): def get_type(self):
"""returns the type of the Name instance""" """returns the type of the Name instance"""

View File

@ -0,0 +1,48 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _Name.py 6326 2006-04-13 11:21:33Z loshawlos $
from _GrampsType import GrampsType
from gettext import gettext as _
class NameType(GrampsType):
UNKNOWN = -1
CUSTOM = 0
AKA = 1
BIRTH = 2
MARRIED = 3
_CUSTOM = CUSTOM
_DEFAULT = BIRTH
_I2SMAP = {
UNKNOWN : _("Unknown"),
CUSTOM : _("Custom"),
AKA : _("Also Known As"),
BIRTH : _("Birth Name"),
MARRIED : _("Married Name"),
}
def __init__(self, value=None):
GrampsType.__init__(self, value)

View File

@ -45,9 +45,11 @@ from _AddressBase import AddressBase
from _LdsOrdBase import LdsOrdBase from _LdsOrdBase import LdsOrdBase
from _UrlBase import UrlBase from _UrlBase import UrlBase
from _Name import Name from _Name import Name
from _NameType import NameType
from _EventRef import EventRef from _EventRef import EventRef
from _LdsOrd import LdsOrd from _LdsOrd import LdsOrd
from _PersonRef import PersonRef from _PersonRef import PersonRef
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Person class # Person class

View File

@ -36,12 +36,14 @@ from _EventRef import EventRef
from _LdsOrd import LdsOrd from _LdsOrd import LdsOrd
from _MediaRef import MediaRef from _MediaRef import MediaRef
from _Name import Name from _Name import Name
from _NameType import NameType
from _Note import Note from _Note import Note
from _RepoRef import RepoRef from _RepoRef import RepoRef
from _SourceRef import SourceRef from _SourceRef import SourceRef
from _Url import Url from _Url import Url
from _Witness import Witness from _Witness import Witness
from _ChildRef import ChildRef from _ChildRef import ChildRef
from _ChildRefType import ChildRefType
# Primary objects # Primary objects
from _PrimaryObject import PrimaryObject from _PrimaryObject import PrimaryObject
@ -57,3 +59,7 @@ from _Repository import Repository
# These are actually metadata # These are actually metadata
from _GenderStats import GenderStats from _GenderStats import GenderStats
from _Researcher import Researcher from _Researcher import Researcher
# Type classes
from _GrampsType import GrampsType
from _EventType import PersonEventType

View File

@ -470,11 +470,7 @@ class ScratchPadName(ScratchPadGrampsTypeWrapper):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj)
self._type = _("Name") self._type = _("Name")
self._title = self._obj.get_name() self._title = self._obj.get_name()
value = self._obj.get_type() self._value = str(self._obj.get_type())
if value == RelLib.Name.CUSTOM:
self._value = value[1]
else:
self._value = Utils.name_types[value[0]]
def tooltip(self): def tooltip(self):
global escape global escape

View File

@ -71,20 +71,20 @@ gender = {
def format_gender( type): def format_gender( type):
return gender.get(type[0],_("Invalid")) return gender.get(type[0],_("Invalid"))
child_relations = { # child_relations = {
RelLib.ChildRef.CHILD_NONE : _("None"), # RelLib.ChildRef.CHILD_NONE : _("None"),
RelLib.ChildRef.CHILD_BIRTH : _("Birth"), # RelLib.ChildRef.CHILD_BIRTH : _("Birth"),
RelLib.ChildRef.CHILD_ADOPTED : _("Adopted"), # RelLib.ChildRef.CHILD_ADOPTED : _("Adopted"),
RelLib.ChildRef.CHILD_STEPCHILD : _("Stepchild"), # RelLib.ChildRef.CHILD_STEPCHILD : _("Stepchild"),
RelLib.ChildRef.CHILD_SPONSORED : _("Sponsored"), # RelLib.ChildRef.CHILD_SPONSORED : _("Sponsored"),
RelLib.ChildRef.CHILD_FOSTER : _("Foster"), # RelLib.ChildRef.CHILD_FOSTER : _("Foster"),
RelLib.ChildRef.CHILD_UNKNOWN : _("Unknown"), # RelLib.ChildRef.CHILD_UNKNOWN : _("Unknown"),
RelLib.ChildRef.CHILD_CUSTOM : _("Custom"), # RelLib.ChildRef.CHILD_CUSTOM : _("Custom"),
} # }
def format_child_relation( type): # def format_child_relation( type):
if type[0] == RelLib.ChildRef.CHILD_CUSTOM: # if type[0] == RelLib.ChildRef.CHILD_CUSTOM:
return type[1] # return type[1]
return child_relations.get(type[0],_("Invalid id %d ('%s')")%type) # return child_relations.get(type[0],_("Invalid id %d ('%s')")%type)
confidence = { confidence = {
RelLib.SourceRef.CONF_VERY_HIGH : _("Very High"), RelLib.SourceRef.CONF_VERY_HIGH : _("Very High"),
@ -225,17 +225,18 @@ family_rel_descriptions = {
"a man and woman"), "a man and woman"),
} }
name_types = { # name_types = {
RelLib.Name.UNKNOWN : _("Unknown"), # RelLib.NameType.UNKNOWN : _("Unknown"),
RelLib.Name.CUSTOM : _("Custom"), # RelLib.NameType.CUSTOM : _("Custom"),
RelLib.Name.AKA : _("Also Known As"), # RelLib.NameType.AKA : _("Also Known As"),
RelLib.Name.BIRTH : _("Birth Name"), # RelLib.NameType.BIRTH : _("Birth Name"),
RelLib.Name.MARRIED : _("Married Name"), # RelLib.NameType.MARRIED : _("Married Name"),
} # }
def format_name_type( type): # def format_name_type( type):
if type[0] == RelLib.Name.CUSTOM: # assert(False)
return type[1] # if type[0] == RelLib.Name.CUSTOM:
return name_types.get(type[0],_("Invalid id %d ('%s')")%type) # return type[1]
# return name_types.get(type[0],_("Invalid id %d ('%s')")%type)
web_types = { web_types = {
RelLib.Url.UNKNOWN : _("Unknown"), RelLib.Url.UNKNOWN : _("Unknown"),
@ -1228,6 +1229,7 @@ class ProgressMeter:
""" """
Specify the title and the current pass header. Specify the title and the current pass header.
""" """
self.old_val = -1
self.ptop = gtk.Dialog() self.ptop = gtk.Dialog()
self.ptop.connect('delete_event',self.warn) self.ptop.connect('delete_event',self.warn)
self.ptop.set_has_separator(False) self.ptop.set_has_separator(False)
@ -1272,10 +1274,12 @@ class ProgressMeter:
if (self.pbar_index > self.pbar_max): if (self.pbar_index > self.pbar_max):
self.pbar_index = self.pbar_max self.pbar_index = self.pbar_max
val = self.pbar_index/self.pbar_max val = int(100*self.pbar_index/self.pbar_max)
self.pbar.set_text("%d of %d (%.1f%%)" % (self.pbar_index,self.pbar_max,(val*100))) if val != self.old_val:
self.pbar.set_fraction(val) self.pbar.set_text("%d%%" % val)
self.pbar.set_fraction(val/100.0)
self.old_val = val
while gtk.events_pending(): while gtk.events_pending():
gtk.main_iteration() gtk.main_iteration()

View File

@ -57,12 +57,12 @@ from PluginUtils import Tool, register_tool
# ChangeNames # ChangeNames
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ChangeNames(Tool.Tool, ManagedWindow,ManagedWindow): class ChangeNames(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self, dbstate, uistate, options_class, name, callback=None): def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name) Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, []. self) ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
self.cb = callback self.cb = callback
@ -167,7 +167,7 @@ class ChangeNames(Tool.Tool, ManagedWindow,ManagedWindow):
self.db.request_rebuild() self.db.request_rebuild()
self.parent.bookmarks.redraw() self.parent.bookmarks.redraw()
self.close(obj) self.close(obj)
self.cb(None,1) self.cb()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -78,8 +78,8 @@ class ChangeTypes(Tool.Tool, ManagedWindow.ManagedWindow):
self.auto1 = self.glade.get_widget("original") self.auto1 = self.glade.get_widget("original")
self.auto2 = self.glade.get_widget("new") self.auto2 = self.glade.get_widget("new")
AutoComp.fill_combo(self.auto1,const.personalEvents) AutoComp.fill_combo(self.auto1,Utils.personal_events)
AutoComp.fill_combo(self.auto2,const.personalEvents) AutoComp.fill_combo(self.auto2,Utils.personal_events)
# Need to display localized event names # Need to display localized event names
self.auto1.child.set_text(const.display_event( self.auto1.child.set_text(const.display_event(
self.options.handler.options_dict['fromtype'])) self.options.handler.options_dict['fromtype']))

View File

@ -236,7 +236,6 @@ class CheckIntegrity:
self.db.commit_person(p,self.trans) self.db.commit_person(p,self.trans)
self.progress.step() self.progress.step()
def fix_encoding(self): def fix_encoding(self):
self.progress.set_pass(_('Looking for character encoding errors'), self.progress.set_pass(_('Looking for character encoding errors'),
self.db.get_number_of_media_objects()) self.db.get_number_of_media_objects())
@ -887,6 +886,7 @@ class Report(ManagedWindow.ManagedWindow):
base = os.path.dirname(__file__) base = os.path.dirname(__file__)
glade_file = base + os.sep + "summary.glade" glade_file = base + os.sep + "summary.glade"
topDialog = gtk.glade.XML(glade_file,"summary","gramps") topDialog = gtk.glade.XML(glade_file,"summary","gramps")
topDialog.get_widget("close").connect('clicked',self.close)
self.window = topDialog.get_widget("summary") self.window = topDialog.get_widget("summary")
textwindow = topDialog.get_widget("textwindow") textwindow = topDialog.get_widget("textwindow")

View File

@ -24,6 +24,8 @@
import gtk import gtk
import ListModel import ListModel
import ManagedWindow
from PluginUtils import Tool, register_tool from PluginUtils import Tool, register_tool
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
@ -32,20 +34,24 @@ _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class DumpGenderStats(Tool.Tool): class DumpGenderStats(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name) def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
stats_list = [] stats_list = []
for name in db.genderStats.stats.keys(): for name in dbstate.db.genderStats.stats.keys():
stats_list.append( stats_list.append(
(name,) (name,)
+ db.genderStats.stats[name] + dbstate.db.genderStats.stats[name]
+ (_GENDER[db.genderStats.guess_gender(name)],) + (_GENDER[dbstate.db.genderStats.guess_gender(name)],)
) )
if parent: if uistate:
titles = [ titles = [
(_('Name'),1,100), (_('Male'),2,70), (_('Name'),1,100), (_('Male'),2,70),
(_('Female'),3,70), (_('Unknown'),4,70), (_('Female'),3,70), (_('Unknown'),4,70),
@ -56,14 +62,14 @@ class DumpGenderStats(Tool.Tool):
model = ListModel.ListModel(treeview,titles) model = ListModel.ListModel(treeview,titles)
for entry in stats_list: for entry in stats_list:
model.add(entry,entry[0]) model.add(entry,entry[0])
w = gtk.Window()
w.set_transient_for(parent.topWindow) self.window = gtk.Window()
w.set_position(gtk.WIN_POS_MOUSE) self.window.set_default_size(400,300)
w.set_default_size(400,300)
s = gtk.ScrolledWindow() s = gtk.ScrolledWindow()
s.add(treeview) s.add(treeview)
w.add(s) self.window.add(s)
w.show_all() self.window.show_all()
else: else:
print "\t%s\t%s\t%s\t%s\t%s\n" % ( print "\t%s\t%s\t%s\t%s\t%s\n" % (
'Name','Male','Female','Unknown','Guess') 'Name','Male','Female','Unknown','Guess')

View File

@ -248,8 +248,8 @@ class GraphViz:
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
fadopted = frel != RelLib.ChildRef.CHILD_BIRTH fadopted = frel != RelLib.ChildRefType.BIRTH
madopted = mrel != RelLib.ChildRef.CHILD_BIRTH madopted = mrel != RelLib.ChildRefType.BIRTH
famid = family.get_gramps_id().replace('-','_') famid = family.get_gramps_id().replace('-','_')
if (self.show_families and if (self.show_families and
(father_handle and person_dict.has_key(father_handle) or (father_handle and person_dict.has_key(father_handle) or

View File

@ -1764,7 +1764,7 @@ class IndividualPage(BasePage):
val) val)
else: else:
of.write(nameof(person,self.exclude_private)) of.write(nameof(person,self.exclude_private))
if rel != RelLib.ChildRef.CHILD_BIRTH: if rel != RelLib.ChildRefType.BIRTH:
of.write('&nbsp;&nbsp;&nbsp;(%s)' % Utils.format_child_relation(rel)) of.write('&nbsp;&nbsp;&nbsp;(%s)' % Utils.format_child_relation(rel))
of.write('</td>\n') of.write('</td>\n')

View File

@ -89,7 +89,9 @@ _sn_prefix_re = re.compile("^\s*(%s)\s+(.*)" % '|'.join(prefix_list),
class PatchNames(Tool.Tool, ManagedWindow.ManagedWindow): class PatchNames(Tool.Tool, ManagedWindow.ManagedWindow):
def __init__(self, dbstate, uistate, options_class, name, callback=None): def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.Tool.__init__(self, dbstate, options_class, name) Tool.Tool.__init__(self, dbstate, options_class, name)
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
self.cb = callback self.cb = callback
self.trans = self.db.transaction_begin() self.trans = self.db.transaction_begin()

View File

@ -520,7 +520,7 @@ class TestcaseGenerator(Tool.Tool):
person2.add_family_handle(fam_h) person2.add_family_handle(fam_h)
self.db.commit_person(person2,self.trans) self.db.commit_person(person2,self.trans)
child = self.db.get_person_from_handle(child_h) child = self.db.get_person_from_handle(child_h)
child.add_parent_family_handle(fam_h,(RelLib.ChildRef.CHILD_BIRTH,''),(RelLib.ChildRef.CHILD_BIRTH,'')) child.add_parent_family_handle(fam_h,RelLib.ChildRefType(),RelLib.ChildRefType())
self.db.commit_person(child,self.trans) self.db.commit_person(child,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP self.commit_transaction() # COMMIT TRANSACTION STEP

View File

@ -18,6 +18,8 @@
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<signal name="delete_event" handler="on_delete_event" last_modification_time="Thu, 24 Mar 2005 18:53:09 GMT"/> <signal name="delete_event" handler="on_delete_event" last_modification_time="Thu, 24 Mar 2005 18:53:09 GMT"/>
@ -33,7 +35,7 @@
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
<child> <child>
<widget class="GtkButton" id="button3"> <widget class="GtkButton" id="close">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -74,6 +76,10 @@
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
<property name="xpad">0</property> <property name="xpad">0</property>
<property name="ypad">0</property> <property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="padding">8</property> <property name="padding">8</property>