* src/FamilyView.py: add/edit/delete buttons for families added,
add support for no families or parents * src/GrampsDb/_GrampsBSDDB.py: txn handling for get_handles * src/GrampsDb/_GrampsDbBase.py: txn handling for get_handles * src/GrampsDb/_GrampsGEDDB.py: txn handling for get_handles * src/GrampsDb/_GrampsXMLDb.py: txn handling for get_handles svn: r5707
This commit is contained in:
parent
c929fd14a6
commit
a357061713
@ -1,6 +1,11 @@
|
||||
2006-01-10 Don Allingham <don@gramps-project.org>
|
||||
* src/FamilyView.py: add/edit/delete buttons for families added
|
||||
|
||||
* src/FamilyView.py: add/edit/delete buttons for families added,
|
||||
add support for no families or parents
|
||||
* src/GrampsDb/_GrampsBSDDB.py: txn handling for get_handles
|
||||
* src/GrampsDb/_GrampsDbBase.py: txn handling for get_handles
|
||||
* src/GrampsDb/_GrampsGEDDB.py: txn handling for get_handles
|
||||
* src/GrampsDb/_GrampsXMLDb.py: txn handling for get_handles
|
||||
|
||||
2006-01-10 Alex Roitman <shura@gramps-project.org>
|
||||
* src/Assistant.py: Cosmeti c changes.
|
||||
* src/Exporter.py: Start converting to Assistant.
|
||||
|
@ -262,14 +262,22 @@ class FamilyView(PageView.PersonNavView):
|
||||
|
||||
self.row = 5
|
||||
family_handle_list = person.get_parent_family_handle_list()
|
||||
for (family_handle,mrel,frel) in family_handle_list:
|
||||
if family_handle:
|
||||
self.write_parents(family_handle)
|
||||
if family_handle_list:
|
||||
for (family_handle,mrel,frel) in family_handle_list:
|
||||
if family_handle:
|
||||
self.write_parents(family_handle)
|
||||
else:
|
||||
self.write_label("%s:" % _('Parents'),None)
|
||||
self.row += 1
|
||||
|
||||
family_handle_list = person.get_family_handle_list()
|
||||
for family_handle in family_handle_list:
|
||||
if family_handle:
|
||||
self.write_family(family_handle)
|
||||
if family_handle_list:
|
||||
for family_handle in family_handle_list:
|
||||
if family_handle:
|
||||
self.write_family(family_handle)
|
||||
else:
|
||||
self.write_label("%s:" % _('Family'),None)
|
||||
self.row += 1
|
||||
|
||||
self.row = 1
|
||||
self.write_title(person)
|
||||
@ -303,8 +311,6 @@ class FamilyView(PageView.PersonNavView):
|
||||
x0 -= 1
|
||||
if x1 > 4:
|
||||
x1 -= 1
|
||||
if x0 == x1:
|
||||
print d[0]
|
||||
self.child.attach(d[0],x0,x1,d[3],d[4],d[5],d[6])
|
||||
|
||||
self.child.show_all()
|
||||
@ -403,17 +409,22 @@ class FamilyView(PageView.PersonNavView):
|
||||
self.attach.attach(MarkupLabel(msg),_LABEL_START,_LABEL_STOP,
|
||||
self.row,self.row+1,gtk.SHRINK|gtk.FILL)
|
||||
|
||||
self.attach.attach(BasicLabel(family.gramps_id),_DATA_START,_DATA_STOP,
|
||||
if family:
|
||||
value = family.gramps_id
|
||||
else:
|
||||
value = ""
|
||||
self.attach.attach(BasicLabel(value),_DATA_START,_DATA_STOP,
|
||||
self.row,self.row+1,gtk.SHRINK|gtk.FILL)
|
||||
|
||||
hbox = gtk.HBox()
|
||||
hbox.set_spacing(6)
|
||||
add = IconButton(self.add_family,None,gtk.STOCK_ADD)
|
||||
hbox.pack_start(add,False)
|
||||
edit = IconButton(self.edit_family,family.handle,gtk.STOCK_EDIT)
|
||||
hbox.pack_start(edit,False)
|
||||
delete = IconButton(self.delete_family,family.handle,gtk.STOCK_REMOVE)
|
||||
hbox.pack_start(delete,False)
|
||||
if family:
|
||||
edit = IconButton(self.edit_family,family.handle,gtk.STOCK_EDIT)
|
||||
hbox.pack_start(edit,False)
|
||||
delete = IconButton(self.delete_family,family.handle,gtk.STOCK_REMOVE)
|
||||
hbox.pack_start(delete,False)
|
||||
self.attach.attach(hbox,_BTN_START,_BTN_STOP,self.row,self.row+1)
|
||||
self.row += 1
|
||||
|
||||
@ -532,12 +543,15 @@ class FamilyView(PageView.PersonNavView):
|
||||
return p.get_title()
|
||||
|
||||
def write_marriage(self,family):
|
||||
value = False
|
||||
for event_ref in family.get_event_ref_list():
|
||||
handle = event_ref.ref
|
||||
event = self.dbstate.db.get_event_from_handle(handle)
|
||||
etype = event.get_type()
|
||||
if etype[0] == RelLib.Event.MARRIAGE:
|
||||
self.write_event_ref(_('Marriage'),event)
|
||||
value = True
|
||||
return value
|
||||
|
||||
def write_event_ref(self, ename, event,start_col=_SDATA_START,stop_col=_SDATA_STOP):
|
||||
if event:
|
||||
@ -593,8 +607,8 @@ class FamilyView(PageView.PersonNavView):
|
||||
self.attach.attach(BasicLabel(value),_PDTLS_START,
|
||||
_PDTLS_STOP,self.row, self.row+1)
|
||||
self.row += 1
|
||||
self.write_relationship(family)
|
||||
self.write_marriage(family)
|
||||
if not self.write_marriage(family):
|
||||
self.write_relationship(family)
|
||||
|
||||
child_list = family.get_child_handle_list()
|
||||
label = _("Children")
|
||||
|
@ -133,6 +133,9 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
dbmap.open(name, dbname, db.DB_HASH,
|
||||
db.DB_CREATE|db.DB_AUTO_COMMIT, 0666)
|
||||
return dbmap
|
||||
|
||||
def _all_handles(self,table):
|
||||
return table.keys(self.txn)
|
||||
|
||||
def get_person_cursor(self):
|
||||
return GrampsBSDDBCursor(self.person_map,self.txn)
|
||||
@ -244,7 +247,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
and self.metadata.get('version',0) < _DBVERSION
|
||||
|
||||
def load(self,name,callback,mode="w"):
|
||||
if self.person_map:
|
||||
if self.db_is_open:
|
||||
self.close()
|
||||
|
||||
self.readonly = mode == "r"
|
||||
@ -394,6 +397,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.bookmarks = []
|
||||
|
||||
self.genderStats = GenderStats(gstats)
|
||||
self.db_is_open = True
|
||||
return 1
|
||||
|
||||
def rebuild_secondary(self,callback=None):
|
||||
@ -714,7 +718,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self.person_map == None:
|
||||
if not self.db_is_open:
|
||||
return
|
||||
self.name_group.close()
|
||||
self.person_map.close()
|
||||
@ -764,6 +768,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.surnames = None
|
||||
self.env = None
|
||||
self.metadata = None
|
||||
self.db_is_open = False
|
||||
|
||||
def _del_person(self,handle):
|
||||
self._delete_primary_from_reference_map(handle)
|
||||
|
@ -207,6 +207,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
self.lmap_index = 0
|
||||
self.omap_index = 0
|
||||
self.rmap_index = 0
|
||||
self.db_is_open = False
|
||||
|
||||
self.family_event_names = sets.Set()
|
||||
self.individual_event_names = sets.Set()
|
||||
@ -336,7 +337,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
"""
|
||||
Returns 1 if the database has been opened.
|
||||
"""
|
||||
return self.person_map != None
|
||||
return self.db_is_open
|
||||
|
||||
def request_rebuild(self):
|
||||
"""
|
||||
@ -843,7 +844,10 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
"""
|
||||
Returns the number of people currently in the databse.
|
||||
"""
|
||||
return len(self.person_map)
|
||||
if self.db_is_open:
|
||||
return len(self.person_map)
|
||||
else:
|
||||
return 0
|
||||
|
||||
def get_number_of_families(self):
|
||||
"""
|
||||
@ -881,12 +885,15 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
"""
|
||||
return len(self.repository_map)
|
||||
|
||||
def _all_handles(self,table):
|
||||
return table.keys()
|
||||
|
||||
def get_person_handles(self,sort_handles=True):
|
||||
"""
|
||||
Returns a list of database handles, one handle for each Person in
|
||||
the database. If sort_handles is True, the list is sorted by surnames
|
||||
"""
|
||||
if self.person_map:
|
||||
if self.db_is_open:
|
||||
if sort_handles:
|
||||
slist = []
|
||||
cursor = self.get_person_cursor()
|
||||
@ -898,7 +905,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
slist.sort()
|
||||
return map(lambda x: x[1], slist)
|
||||
else:
|
||||
return self.person_map.keys()
|
||||
return self._all_handles(self.person_map)
|
||||
return []
|
||||
|
||||
def get_place_handles(self,sort_handles=True):
|
||||
@ -920,7 +927,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
val = map(lambda x: x[1], slist)
|
||||
return val
|
||||
else:
|
||||
return self.place_map.keys()
|
||||
return self._all_handles(self.place_map)
|
||||
return []
|
||||
|
||||
def get_source_handles(self,sort_handles=True):
|
||||
@ -930,7 +937,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
Source title.
|
||||
"""
|
||||
if self.source_map:
|
||||
handle_list = self.source_map.keys()
|
||||
handle_list = self._all_handles(self.source_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(self._sortbysource)
|
||||
return handle_list
|
||||
@ -942,7 +949,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
the database. If sort_handles is True, the list is sorted by title.
|
||||
"""
|
||||
if self.media_map:
|
||||
handle_list = self.media_map.keys()
|
||||
handle_list = self._all_handles(self.media_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(self._sortbymedia)
|
||||
return handle_list
|
||||
@ -954,7 +961,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
the database.
|
||||
"""
|
||||
if self.event_map:
|
||||
return self.event_map.keys()
|
||||
return self._all_handles(self.event_map)
|
||||
return []
|
||||
|
||||
def get_family_handles(self):
|
||||
@ -963,7 +970,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
the database.
|
||||
"""
|
||||
if self.family_map:
|
||||
return self.family_map.keys()
|
||||
return self._all_handles(self.family_map)
|
||||
return []
|
||||
|
||||
def get_repository_handles(self):
|
||||
@ -972,7 +979,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
the database.
|
||||
"""
|
||||
if self.repository_map:
|
||||
return self.repository_map.keys()
|
||||
return self._all_handles(self.repository_map)
|
||||
return []
|
||||
|
||||
def _validated_id_prefix(self, val, default):
|
||||
|
@ -45,16 +45,22 @@ class GrampsGEDDB(GrampsInMemDB):
|
||||
GrampsInMemDB.__init__(self)
|
||||
|
||||
def load(self,name,callback, mode="w"):
|
||||
if self.db_is_open:
|
||||
self.close()
|
||||
GrampsInMemDB.load(self,name,callback,mode)
|
||||
ReadGedcom.importData(self,name,use_trans=False)
|
||||
|
||||
self.bookmarks = self.metadata.get('bookmarks')
|
||||
if self.bookmarks == None:
|
||||
self.bookmarks = []
|
||||
self.db_is_open = True
|
||||
return 1
|
||||
|
||||
def close(self):
|
||||
if not self.db_is_open:
|
||||
return
|
||||
if not self.readonly and len(self.undodb) > 0:
|
||||
writer = WriteGedcom.GedcomWriter(self,self.get_default_person())
|
||||
writer.export_data(self.filename)
|
||||
self.db_is_open = False
|
||||
|
||||
|
@ -45,6 +45,8 @@ class GrampsXMLDB(GrampsInMemDB):
|
||||
GrampsInMemDB.__init__(self)
|
||||
|
||||
def load(self,name,callback,mode="w"):
|
||||
if self.db_is_open:
|
||||
self.close()
|
||||
GrampsInMemDB.load(self,name,callback,mode)
|
||||
self.id_trans = {}
|
||||
|
||||
@ -53,9 +55,12 @@ class GrampsXMLDB(GrampsInMemDB):
|
||||
self.bookmarks = self.metadata.get('bookmarks')
|
||||
if self.bookmarks == None:
|
||||
self.bookmarks = []
|
||||
self.db_is_open = True
|
||||
return 1
|
||||
|
||||
def close(self):
|
||||
if not self.db_is_open:
|
||||
return
|
||||
if not self.readonly and len(self.undodb) > 0:
|
||||
WriteXML.quick_write(self,self.filename)
|
||||
|
||||
self.db_is_open = False
|
||||
|
Loading…
Reference in New Issue
Block a user