* 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> 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 * src/ArgHandler.py: Make sure all databases are closed before
creating a new one. creating a new one.
* src/DisplayModels.py: Calculate new nodes properly after a * src/DisplayModels.py: Calculate new nodes properly after a

View File

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

View File

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

View File

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

View File

@ -1608,10 +1608,12 @@ class Gramps(GrampsDBCallback.GrampsDBCallback):
self.filter_text.set_sensitive(0) self.filter_text.set_sensitive(0)
def new_after_edit(self,epo,val): 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() self.goto_active_person()
def update_after_edit(self,epo,change=1): def update_after_edit(self,epo,change=1):
self.change_active_person(epo.person)
self.goto_active_person() self.goto_active_person()
def load_person(self,person): def load_person(self,person):