* src/FamilyView.py: commit family properly

* src/PedView.py: change_active_person typo
* src/PeopleView.py: don't change active person with updated
* src/SelectChild.py: Fix callbacks
* src/gramps_main.py: load active family on change


svn: r4289
This commit is contained in:
Don Allingham 2005-04-04 03:59:42 +00:00
parent 8126f34ec9
commit 17bbd11d07
6 changed files with 56 additions and 57 deletions

View File

@ -1,4 +1,9 @@
2005-04-03 Don Allingham <don@gramps-project.org>
* src/FamilyView.py: commit family properly
* src/PedView.py: change_active_person typo
* src/PeopleView.py: don't change active person with updated
* src/SelectChild.py: Fix callbacks
* src/gramps_main.py: load active family on change
* src/ArgHandler.py: Make sure all databases are closed before
creating a new one.
* src/DisplayModels.py: Calculate new nodes properly after a

View File

@ -303,7 +303,8 @@ class FamilyView:
def ap_button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
self.parent.load_person(self.person)
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3 and self.person:
elif (event.type == gtk.gdk.BUTTON_PRESS and event.button == 3
and self.person):
self.build_ap_menu(event)
def ap_key_press(self,obj,event):
@ -797,8 +798,7 @@ class FamilyView:
return
try:
SelectChild.SelectChild(self.parent, self.parent.db, self.family,
self.person, self.load_family,
self.update_person_list)
self.person, self.load_family)
except:
DisplayTrace.DisplayTrace()
@ -806,6 +806,8 @@ class FamilyView:
if self.family == None or self.person == None:
return
family = self.family
model, node = self.child_selection.get_selected()
if not node:
return
@ -815,18 +817,17 @@ class FamilyView:
trans = self.parent.db.transaction_begin()
self.family.remove_child_handle(child.get_handle())
child.remove_parent_family_handle(self.family.get_handle())
family.remove_child_handle(child.get_handle())
child.remove_parent_family_handle(family.get_handle())
if len(self.family.get_child_handle_list()) == 0:
if self.family.get_father_handle() == None:
self.delete_family_from(self.family.get_mother_handle())
elif self.family.get_mother_handle() == None:
self.delete_family_from(self.family.get_father_handle())
if len(family.get_child_handle_list()) == 0:
if family.get_father_handle() == None:
self.delete_family_from(family.get_mother_handle(),trans)
elif family.get_mother_handle() == None:
self.delete_family_from(family.get_father_handle(),trans)
self.parent.db.commit_person(child,trans)
if self.family:
self.parent.db.commit_family(self.family,trans)
self.parent.db.commit_family(family,trans)
n = child.get_primary_name().get_regular_name()
self.parent.db.transaction_commit(trans,_("Remove Child (%s)") % n)
@ -961,8 +962,10 @@ class FamilyView:
self.clear()
return
bd = self.parent.db.get_event_from_handle(self.person.get_birth_handle())
dd = self.parent.db.get_event_from_handle(self.person.get_death_handle())
bhandle = self.person.get_birth_handle()
dhandle = self.person.get_death_handle()
bd = self.parent.db.get_event_from_handle(bhandle)
dd = self.parent.db.get_event_from_handle(dhandle)
if bd and dd:
n = "%s [%s]\n\t%s %s\n\t%s %s " % (
@ -1091,8 +1094,7 @@ class FamilyView:
else:
return _("%s: unknown") % (l)
def delete_family_from(self,person_handle):
trans = self.parent.db.transaction_begin()
def delete_family_from(self,person_handle,trans):
person = self.parent.db.get_person_from_handle(person_handle)
person.remove_family_handle(self.family.get_handle())
self.parent.db.remove_family(self.family.get_handle(),trans)
@ -1102,7 +1104,6 @@ class FamilyView:
else:
self.family = None
n = NameDisplay.displayer.display(person)
self.parent.db.transaction_commit(trans,_("Remove from family (%s)") % n)
def display_marriage(self,family):
if not family:

View File

@ -111,28 +111,20 @@ class DispBox:
self.group = self.root.add(CanvasGroup,x=x,y=y)
self.shadow = self.group.add(CanvasRect,
x1=shadow,
y1=shadow,
x2=w+shadow,
y2=h+shadow,
self.shadow = self.group.add(
CanvasRect, x1=shadow, y1=shadow, x2=w+shadow, y2=h+shadow,
outline_color_gdk=style.dark[gtk.STATE_NORMAL],
fill_color_gdk=style.dark[gtk.STATE_NORMAL])
# draw the real box
self.bkgnd = self.group.add(CanvasRect,
x1=0,
y1=0,
x2=w,
y2=h,
self.bkgnd = self.group.add(
CanvasRect, x1=0, y1=0, x2=w, y2=h,
outline_color_gdk=style.fg[gtk.STATE_NORMAL],
fill_color_gdk=style.base[gtk.STATE_NORMAL])
font = gtk.gdk.font_from_description(style.font_desc)
self.textbox = self.group.add(CanvasText,
x=xpad,
y=h/2.0,
text=self.name,
self.textbox = self.group.add(
CanvasText, x=xpad, y=h/2.0, text=self.name,
fill_color_gdk=style.text[gtk.STATE_NORMAL],
font=font, anchor=gtk.ANCHOR_WEST)
self.group.connect('event',self.group_event)
@ -276,11 +268,8 @@ class PedigreeView:
xpts = self.build_x_coords(cw/xdiv,_CANVASPAD+h)
ypts = self.build_y_coords((ch-h)/32.0, h)
self.anchor_txt = self.root.add(CanvasText,
x=0,
y=y2-12,
font=font,
text=self.make_anchor_label(),
self.anchor_txt = self.root.add(
CanvasText, x=0, y=y2-12, font=font, text=self.make_anchor_label(),
fill_color_gdk=style.fg[gtk.STATE_NORMAL],
anchor=gtk.ANCHOR_WEST)
self.canvas_items.append(self.anchor_txt)
@ -309,7 +298,8 @@ class PedigreeView:
gen_no = 1
if self.anchor:
(firstRel,secondRel,common) = self.distance(self.active_person,self.anchor)
(firstRel,secondRel,common) = self.distance(self.active_person,
self.anchor)
if not common or type(common) in [type(''),type(u'')]:
self.remove_anchor()
else:
@ -331,17 +321,20 @@ class PedigreeView:
if lst[findex]:
p = lst[findex]
self.draw_canvas_line(xpts[i], ypts[i], xpts[findex],
ypts[findex], h, w, p[0], style, p[1])
ypts[findex], h, w, p[0], style,
p[1])
if lst[mindex]:
p = lst[mindex]
self.draw_canvas_line(xpts[i],ypts[i], xpts[mindex],
ypts[mindex], h, w, p[0], style, p[1])
ypts[mindex], h, w, p[0], style,
p[1])
p = lst[i]
box = DispBox(self.root,style,xpts[i],ypts[i],w,h,p[0],self.parent.db,
box = DispBox(self.root,style,xpts[i],ypts[i],w,h,p[0],
self.parent.db,
self.parent.change_active_person,
self.load_person, self.build_full_nav_menu)
self.boxes.append(box)
self.change_active_person(person)
self.parent.change_active_person(person)
def make_arrow_button(self,direction,function):
"""Make a button containing an arrow with the attached callback"""
@ -430,7 +423,8 @@ class PedigreeView:
the specified location. Attach the passed parent and the callback
to the button."""
button,arrow = self.make_arrow_button(gtk.ARROW_RIGHT,self.change_to_parent)
button,arrow = self.make_arrow_button(gtk.ARROW_RIGHT,
self.change_to_parent)
button.set_data(_PERSON,parent.get_handle())
item = self.root.add(CanvasWidget, widget=button, x=x, y=y+(h/2),

View File

@ -365,5 +365,5 @@ class PeopleView:
pnode = self.person_model.get_iter(path)
self.person_model.row_inserted(path,pnode)
self.parent.change_active_person(person)
#self.parent.change_active_person(person)
self.goto_active_person()

View File

@ -56,13 +56,12 @@ from QuestionDialog import ErrorDialog
#-------------------------------------------------------------------------
class SelectChild:
def __init__(self,parent,db,family,person,redraw,add_person):
def __init__(self,parent,db,family,person,callback):
self.parent = parent
self.db = db
self.callback = callback
self.person = person
self.family = family
self.redraw = redraw
self.add_person = add_person
self.renderer = gtk.CellRendererText()
self.xml = gtk.glade.XML(const.gladeFile,"select_child","gramps")
@ -328,8 +327,6 @@ class SelectChild:
self.db.commit_family(self.family,trans)
n = select_child.get_primary_name().get_regular_name()
self.db.transaction_commit(trans,_("Add Child to Family (%s)") % n)
self.redraw(self.family)
self.close(obj)
def on_show_toggled(self,obj):

View File

@ -1608,10 +1608,12 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.filter_text.set_sensitive(0)
def new_after_edit(self,epo,val):
self.active_person = epo.person
self.change_active_person(epo.person)
self.family_view.load_family()
self.goto_active_person()
def update_after_edit(self,epo,change=1):
self.change_active_person(epo.person)
self.goto_active_person()
def load_person(self,person):