diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py
index 755da4b11..f3d3f802e 100644
--- a/gramps2/src/FamilyView.py
+++ b/gramps2/src/FamilyView.py
@@ -152,12 +152,25 @@ class FamilyView:
self.parent.load_person(self.person)
def on_child_list_button_press(self,obj,event):
+ model, iter = self.child_selection.get_selected()
+ if not iter:
+ return
+ id = self.child_model.get_value(iter,2)
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
- model, iter = self.child_selection.get_selected()
- if iter:
- id = self.child_model.get_value(iter,2)
- self.parent.load_person(self.parent.db.getPerson(id))
+ self.parent.load_person(self.parent.db.getPerson(id))
+ elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
+ menu = gtk.Menu()
+ item = gtk.TearoffMenuItem()
+ item.show()
+ menu.append(item)
+ msg = _("Edit relationships")
+ Utils.add_menuitem(menu,msg,id,self.child_rel)
+ menu.popup(None,None,None,0,0)
+ def child_rel(self,obj):
+ person = self.parent.db.getPerson(obj.get_data(Utils.OBJECT))
+ SelectChild.EditRel(person,self.family,self.load_family)
+
def spouse_changed(self,obj):
model, iter = obj.get_selected()
if not iter:
diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py
index 792ca82d6..3c3fe3c9e 100644
--- a/gramps2/src/RelLib.py
+++ b/gramps2/src/RelLib.py
@@ -1256,6 +1256,15 @@ class Person(Persistent):
else:
return None
+ def changeAltFamily(self,family,mrel,frel):
+ """removes a Family instance from the alternate family list"""
+ index = 0
+ for f in self.AltFamilyList[:]:
+ if f[0] == family:
+ self.AltFamilyList[index] = (family,mrel,frel)
+ self._p_changed = 1
+ index += 1
+
def has_family(self,family):
for f in self.AltFamilyList:
if f[0] == family:
diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py
index 4908e3587..650d54f21 100644
--- a/gramps2/src/SelectChild.py
+++ b/gramps2/src/SelectChild.py
@@ -85,12 +85,16 @@ class SelectChild:
if father != None:
fname = father.getPrimaryName().getName()
- label = _("Relationship to %s") % fname
+ label = _("Relationship to %(father)s") % {
+ 'father' : fname
+ }
self.xml.get_widget("flabel").set_text(label)
if mother != None:
mname = mother.getPrimaryName().getName()
- label = _("Relationship to %s") % mname
+ label = _("Relationship to %(mother)s") % {
+ 'mother' : mname
+ }
self.xml.get_widget("mlabel").set_text(label)
else:
fname = self.person.getPrimaryName().getName()
@@ -304,3 +308,83 @@ class SelectChild:
return "%sdóttir" % fname
else:
return ""
+
+class EditRel:
+
+ def __init__(self,child,family,update):
+ self.update = update
+ self.child = child
+ self.family = family
+
+ self.xml = gtk.glade.XML(const.gladeFile,"editrel")
+ self.top = self.xml.get_widget('editrel')
+ self.mdesc = self.xml.get_widget('mrel_desc')
+ self.fdesc = self.xml.get_widget('frel_desc')
+ self.mentry = self.xml.get_widget('mrel')
+ self.fentry = self.xml.get_widget('frel')
+ self.mcombo = self.xml.get_widget('mrel_combo')
+ self.fcombo = self.xml.get_widget('frel_combo')
+
+ name = child.getPrimaryName().getName()
+ Utils.set_titles(self.top,self.xml.get_widget('title'),
+ _('Relationships of %s') % name)
+
+ father = self.family.getFather()
+ mother = self.family.getMother()
+
+ if father:
+ fname = father.getPrimaryName().getName()
+ val = _("Relationship to %(father)s" % {
+ 'father' : fname
+ })
+ self.fdesc.set_text('%s' % val)
+ self.fcombo.set_sensitive(1)
+ else:
+ val = _("Relationship to father")
+ self.fdesc.set_text('%s' % val)
+ self.fcombo.set_sensitive(0)
+
+ if mother:
+ mname = mother.getPrimaryName().getName()
+ val = _("Relationship to %(mother)s" % {
+ 'mother' : mname
+ })
+ self.mdesc.set_text('%s' % val)
+ self.mcombo.set_sensitive(1)
+ else:
+ val = _("Relationship to mother")
+ self.mdesc.set_text('%s' % val)
+ self.mcombo.set_sensitive(0)
+
+ self.xml.signal_autoconnect({
+ "on_ok_clicked" : self.on_ok_clicked,
+ "destroy_passed_object" : self.close
+ })
+
+ f = self.child.has_family(self.family)
+ self.fentry.set_text(_(f[2]))
+ self.mentry.set_text(_(f[1]))
+
+ self.fdesc.set_use_markup(gtk.TRUE)
+ self.mdesc.set_use_markup(gtk.TRUE)
+ self.top.show()
+
+ def close(self,obj):
+ self.top.destroy()
+
+ def on_ok_clicked(self,obj):
+ mrel = const.childRelations[self.mentry.get_text()]
+ mother = self.family.getMother()
+ if mother and mother.getGender() != RelLib.Person.female:
+ if mrel == "Birth":
+ mrel = "Unknown"
+
+ frel = const.childRelations[self.fentry.get_text()]
+ father = self.family.getFather()
+ if father and father.getGender() !=RelLib. Person.male:
+ if frel == "Birth":
+ frel = "Unknown"
+
+ self.child.changeAltFamily(self.family,mrel,frel)
+ self.update()
+ self.top.destroy()