2007-04-02 Don Allingham <don@gramps-project.org>
* src/DisplayState.py: shorten match message * src/GrampsDb/Makefile.am: Added _HelperFunctions.py * src/GrampsDb/__init__.py: Added _HelperFunctions.py * src/GrampsDb/_HelperFunctions.py: Added support functions svn: r8349
This commit is contained in:
parent
5580ad12d3
commit
f32d7b6d1a
@ -1,3 +1,9 @@
|
|||||||
|
2007-04-02 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/DisplayState.py: shorten match message
|
||||||
|
* src/GrampsDb/Makefile.am: Added _HelperFunctions.py
|
||||||
|
* src/GrampsDb/__init__.py: Added _HelperFunctions.py
|
||||||
|
* src/GrampsDb/_HelperFunctions.py: Added support functions
|
||||||
|
|
||||||
2007-04-01 Don Allingham <don@gramps-project.org>
|
2007-04-01 Don Allingham <don@gramps-project.org>
|
||||||
* src/GrampsDb/_GrampsDbBase.py: handle close/delete of active database
|
* src/GrampsDb/_GrampsDbBase.py: handle close/delete of active database
|
||||||
* src/DbManager.py: clean up
|
* src/DbManager.py: clean up
|
||||||
|
@ -82,7 +82,7 @@ class History(GrampsDb.GrampsDBCallback):
|
|||||||
self.index = -1
|
self.index = -1
|
||||||
self.lock = False
|
self.lock = False
|
||||||
|
|
||||||
def remove(self,person_handle,old_id=None):
|
def remove(self, person_handle, old_id=None):
|
||||||
"""Removes a person from the history list"""
|
"""Removes a person from the history list"""
|
||||||
if old_id:
|
if old_id:
|
||||||
del_id = old_id
|
del_id = old_id
|
||||||
@ -100,7 +100,7 @@ class History(GrampsDb.GrampsDBCallback):
|
|||||||
self.emit('changed',(self.history,))
|
self.emit('changed',(self.history,))
|
||||||
self.emit('menu-changed',(self.mhistory,))
|
self.emit('menu-changed',(self.mhistory,))
|
||||||
|
|
||||||
def push(self,person_handle):
|
def push(self, person_handle):
|
||||||
self.prune()
|
self.prune()
|
||||||
if len(self.history) == 0 or person_handle != self.history[-1]:
|
if len(self.history) == 0 or person_handle != self.history[-1]:
|
||||||
self.history.append(person_handle)
|
self.history.append(person_handle)
|
||||||
@ -111,7 +111,7 @@ class History(GrampsDb.GrampsDBCallback):
|
|||||||
self.emit('menu-changed',(self.mhistory,))
|
self.emit('menu-changed',(self.mhistory,))
|
||||||
self.emit('changed',(self.history,))
|
self.emit('changed',(self.history,))
|
||||||
|
|
||||||
def forward(self,step=1):
|
def forward(self, step=1):
|
||||||
self.index += step
|
self.index += step
|
||||||
person_handle = self.history[self.index]
|
person_handle = self.history[self.index]
|
||||||
if person_handle not in self.mhistory:
|
if person_handle not in self.mhistory:
|
||||||
@ -119,7 +119,7 @@ class History(GrampsDb.GrampsDBCallback):
|
|||||||
self.emit('menu-changed',(self.mhistory,))
|
self.emit('menu-changed',(self.mhistory,))
|
||||||
return str(self.history[self.index])
|
return str(self.history[self.index])
|
||||||
|
|
||||||
def back(self,step=1):
|
def back(self, step=1):
|
||||||
self.index -= step
|
self.index -= step
|
||||||
try:
|
try:
|
||||||
person_handle = self.history[self.index]
|
person_handle = self.history[self.index]
|
||||||
@ -339,7 +339,7 @@ class DisplayState(GrampsDb.GrampsDBCallback):
|
|||||||
gobject.timeout_add(5000,self.modify_statusbar,dbstate)
|
gobject.timeout_add(5000,self.modify_statusbar,dbstate)
|
||||||
|
|
||||||
def show_filter_results(self, dbstate, matched, total):
|
def show_filter_results(self, dbstate, matched, total):
|
||||||
text = _("%d/%d matched") % (matched, total)
|
text = "%d/%d" % (matched, total)
|
||||||
self.status.pop(1, self.last_bar)
|
self.status.pop(1, self.last_bar)
|
||||||
self.status.push(1, text, self.last_bar)
|
self.status.push(1, text, self.last_bar)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ pkgdata_PYTHON = \
|
|||||||
_GrampsInMemDB.py\
|
_GrampsInMemDB.py\
|
||||||
_GrampsXMLDB.py\
|
_GrampsXMLDB.py\
|
||||||
_GrampsDbConst.py\
|
_GrampsDbConst.py\
|
||||||
|
_HelperFunctions.py\
|
||||||
__init__.py
|
__init__.py
|
||||||
|
|
||||||
pkgpyexecdir = @pkgpyexecdir@/GrampsDb
|
pkgpyexecdir = @pkgpyexecdir@/GrampsDb
|
||||||
|
127
src/GrampsDb/_HelperFunctions.py
Normal file
127
src/GrampsDb/_HelperFunctions.py
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2007 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
|
||||||
|
#
|
||||||
|
|
||||||
|
import RelLib
|
||||||
|
|
||||||
|
def children_of_person(db, person):
|
||||||
|
"""
|
||||||
|
Returns a list of Person instances which represents children of
|
||||||
|
the specified person.
|
||||||
|
"""
|
||||||
|
families = [ db.get_family_from_handle(h) \
|
||||||
|
for h in person.get_family_handle_list() ]
|
||||||
|
chandles = []
|
||||||
|
for family in families:
|
||||||
|
chandles += [ ref.ref for ref in family.get_child_ref_list() ]
|
||||||
|
|
||||||
|
return [ db.get_person_from_handle(h) for h in chandles ]
|
||||||
|
|
||||||
|
def parents_of_person(db, person):
|
||||||
|
"""
|
||||||
|
Returns a list of Person instances which represents the parents of
|
||||||
|
the specified person. Each element in the list is a tuple consisting
|
||||||
|
of the (father, mother)
|
||||||
|
"""
|
||||||
|
|
||||||
|
families = [ db.get_family_from_handle(h) \
|
||||||
|
for h in person.get_parent_family_handle_list() ]
|
||||||
|
|
||||||
|
parents = []
|
||||||
|
for family in families:
|
||||||
|
fhandle = family.get_father_handle()
|
||||||
|
mhandle = family.get_mother_handle()
|
||||||
|
if fhandle:
|
||||||
|
father = db.get_person_from_handle(fhandle)
|
||||||
|
else:
|
||||||
|
father = None
|
||||||
|
if mhandle:
|
||||||
|
mother = db.get_person_from_handle(mhandle)
|
||||||
|
else:
|
||||||
|
mother = None
|
||||||
|
parents.append((father,mother))
|
||||||
|
return parents
|
||||||
|
|
||||||
|
def children_of_family(db, family):
|
||||||
|
"""
|
||||||
|
Returns a list of Person instances associated with the family.
|
||||||
|
"""
|
||||||
|
return [ db.get_person_from_handle(ref.ref) \
|
||||||
|
for ref in family.get_child_ref_list() ]
|
||||||
|
|
||||||
|
def parents_of_family(db, family):
|
||||||
|
"""
|
||||||
|
Returns a tuple of Person instances representing a father, mother pair.
|
||||||
|
"""
|
||||||
|
fhandle = family.get_father_handle()
|
||||||
|
mhandle = family.get_mother_handle()
|
||||||
|
if fhandle:
|
||||||
|
father = db.get_person_from_handle(fhandle)
|
||||||
|
else:
|
||||||
|
father = None
|
||||||
|
if mhandle:
|
||||||
|
mother = db.get_person_from_handle(mhandle)
|
||||||
|
else:
|
||||||
|
mother = None
|
||||||
|
return (father,mother)
|
||||||
|
|
||||||
|
def primary_parents_of(db, person):
|
||||||
|
handle = person.get_main_parents_family_handle()
|
||||||
|
if not handle:
|
||||||
|
return (None, None)
|
||||||
|
family = db.get_family_from_handle(handle)
|
||||||
|
mhandle = family.get_mother_handle()
|
||||||
|
fhandle = family.get_father_handle()
|
||||||
|
if mhandle:
|
||||||
|
mother = db.get_person_from_handle(mhandle)
|
||||||
|
else:
|
||||||
|
mother = None
|
||||||
|
if fhandle:
|
||||||
|
father = db.get_person_from_handle(fhandle)
|
||||||
|
else:
|
||||||
|
father = None
|
||||||
|
return (father, mother)
|
||||||
|
|
||||||
|
def primary_parent_family_of(db, person):
|
||||||
|
handle = person.get_main_parents_family_handle()
|
||||||
|
if not handle:
|
||||||
|
return db.get_family_from_handle(handle)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
#def events_of_person(db, person):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
#def events_of_family(db, family):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
def notes_of(db, obj):
|
||||||
|
return [ db.get_note_from_handle(h) for h in obj.get_note_handle_list() ]
|
||||||
|
|
||||||
|
def sources_of(db, obj):
|
||||||
|
return [ db.get_source_from_handle(h) for h in obj.get_source_handle_list() ]
|
||||||
|
|
||||||
|
def sources_of_event(db, event):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def sources_of_person(db, person):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def sources_of_note(db, note):
|
||||||
|
pass
|
@ -57,4 +57,4 @@ from _GrampsDbWriteXML import GrampsDbXmlWriter, \
|
|||||||
from _LongOpStatus import LongOpStatus
|
from _LongOpStatus import LongOpStatus
|
||||||
from _ProgressMonitor import ProgressMonitor
|
from _ProgressMonitor import ProgressMonitor
|
||||||
|
|
||||||
|
from _HelperFunctions import *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user