removal of families

svn: r6169
This commit is contained in:
Don Allingham
2006-03-18 01:30:23 +00:00
parent 140bf0b678
commit 50f00d12cb
5 changed files with 150 additions and 39 deletions

View File

@@ -155,28 +155,13 @@ class FamilyListView(PageView.ListView):
return True
def remove(self,obj):
import GrampsDb
mlist = []
self.selection.selected_foreach(self.blist,mlist)
for handle in mlist:
family = self.dbstate.db.get_family_from_handle(handle)
trans = self.dbstate.db.transaction_begin()
for phandle in [ family.get_father_handle(),
family.get_mother_handle()]:
if phandle:
person = self.dbstate.db.get_person_from_handle(phandle)
person.remove_family_handle(handle)
self.dbstate.db.commit_person(person,trans)
for phandle in family.get_child_handle_list():
person = self.dbstate.db.get_person_from_handle(phandle)
person.remove_parent_family_handle(handle)
self.dbstate.db.commit_person(person,trans)
self.dbstate.db.remove_family(handle,trans)
self.dbstate.db.transaction_commit(trans,_("Remove Family"))
GrampsDb.remove_family_relationships(handle)
self.build_tree()
def edit(self,obj):

View File

@@ -313,8 +313,8 @@ class FamilyView(PageView.PersonNavView):
# name and edit button
name = NameDisplay.displayer.display(person)
text = '<span size="larger" weight="bold">%s %s</span>' % (cgi.escape(name),
_GenderCode[person.gender])
fmt = '<span size="larger" weight="bold">%s %s</span>'
text = fmt % (cgi.escape(name),_GenderCode[person.gender])
label = GrampsWidgets.MarkupLabel(text)
button = GrampsWidgets.IconButton(self.edit_button_press,person.handle)
@@ -417,8 +417,10 @@ class FamilyView(PageView.PersonNavView):
hbox.set_spacing(12)
if is_parent:
call_fcn = self.add_parent_family
del_fcn = self.delete_parent_family
else:
call_fcn = self.add_family
del_fcn = self.delete_family
add = GrampsWidgets.IconButton(call_fcn,None,gtk.STOCK_ADD)
hbox.pack_start(add,False)
@@ -426,7 +428,7 @@ class FamilyView(PageView.PersonNavView):
edit = GrampsWidgets.IconButton(self.edit_family,family.handle,
gtk.STOCK_EDIT)
hbox.pack_start(edit,False)
delete = GrampsWidgets.IconButton(self.delete_family,family.handle,
delete = GrampsWidgets.IconButton(del_fcn,family.handle,
gtk.STOCK_REMOVE)
hbox.pack_start(delete,False)
self.attach.attach(hbox,_BTN_START,_BTN_STOP,self.row,self.row+1)
@@ -473,14 +475,14 @@ class FamilyView(PageView.PersonNavView):
format = "%s"
label = GrampsWidgets.MarkupLabel(format % cgi.escape(title))
self.attach.attach(label,_PLABEL_START,_PLABEL_STOP,self.row,self.row+1,
xoptions=gtk.FILL|gtk.SHRINK)
self.attach.attach(label,_PLABEL_START,_PLABEL_STOP,self.row,
self.row+1, xoptions=gtk.FILL|gtk.SHRINK)
link_label = GrampsWidgets.LinkLabel(self.get_name(handle,True),
self.button_press,handle)
button = GrampsWidgets.IconButton(self.edit_button_press,handle)
self.attach.attach(GrampsWidgets.LinkBox(link_label,button),_PDATA_START,
_PDATA_STOP,self.row,self.row+1)
self.attach.attach(GrampsWidgets.LinkBox(link_label,button),
_PDATA_START,_PDATA_STOP,self.row,self.row+1)
self.row += 1
def write_child(self,title,handle):
@@ -490,23 +492,24 @@ class FamilyView(PageView.PersonNavView):
format = "%s"
label = GrampsWidgets.MarkupLabel(format % cgi.escape(title))
self.attach.attach(label,_CLABEL_START,_CLABEL_STOP,self.row,self.row+1,
xoptions=gtk.FILL|gtk.SHRINK)
self.attach.attach(label,_CLABEL_START,_CLABEL_STOP,self.row,
self.row+1,xoptions=gtk.FILL|gtk.SHRINK)
link_label = GrampsWidgets.LinkLabel(self.get_name(handle,True),
self.button_press,handle)
button = GrampsWidgets.IconButton(self.edit_button_press,handle)
self.attach.attach(GrampsWidgets.LinkBox(link_label,button),_CDATA_START,
_CDATA_STOP,self.row,self.row+1,
xoptions=gtk.EXPAND|gtk.FILL)
self.attach.attach(GrampsWidgets.LinkBox(link_label,button),
_CDATA_START, _CDATA_STOP, self.row, self.row+1,
xoptions=gtk.EXPAND|gtk.FILL)
self.row += 1
if self.show_details:
value = self.info_string(handle)
if value:
self.attach.attach(GrampsWidgets.BasicLabel(value),_CDTLS_START,
_CDTLS_STOP,self.row, self.row+1)
self.attach.attach(GrampsWidgets.BasicLabel(value),
_CDTLS_START, _CDTLS_STOP, self.row,
self.row+1)
self.row += 1
def write_data(self,title,start_col=_SDATA_START,stop_col=_SDATA_STOP):
@@ -582,9 +585,7 @@ class FamilyView(PageView.PersonNavView):
else:
pname = None
dobj = None
value = {
'event_type' : ename,
}
value = { 'event_type' : ename, }
if dobj:
if pname:
@@ -615,8 +616,9 @@ class FamilyView(PageView.PersonNavView):
value = self.info_string(handle)
if value:
self.attach.attach(GrampsWidgets.BasicLabel(value),_PDTLS_START,
_PDTLS_STOP,self.row, self.row+1)
self.attach.attach(GrampsWidgets.BasicLabel(value),
_PDTLS_START, _PDTLS_STOP,
self.row, self.row+1)
self.row += 1
if not self.write_marriage(family):
self.write_relationship(family)
@@ -687,7 +689,18 @@ class FamilyView(PageView.PersonNavView):
def delete_family(self,obj,event,handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
print "Delete Family",handle
import GrampsDb
GrampsDb.remove_parent_from_family(self.dbstate.db,
self.dbstate.active.handle,
handle)
def delete_parent_family(self,obj,event,handle):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
import GrampsDb
GrampsDb.remove_child_from_family(self.dbstate.db,
self.dbstate.active.handle,
handle)
def change_to(self,obj,handle):
self.dbstate.change_active_handle(handle)