Go to the newly added person in the choose parents dialog

svn: r865
This commit is contained in:
Don Allingham 2002-03-28 14:24:59 +00:00
parent 2c46a287e4
commit 9232082e9f
4 changed files with 92 additions and 31 deletions

View File

@ -55,6 +55,8 @@ class ChooseParents:
self.family = family self.family = family
self.family_update = family_update self.family_update = family_update
self.full_update = full_update self.full_update = full_update
self.old_type = ""
self.type = ""
if self.family: if self.family:
self.father = self.family.getFather() self.father = self.family.getFather()
@ -76,6 +78,11 @@ class ChooseParents:
self.mlabel = self.glade.get_widget("mlabel") self.mlabel = self.glade.get_widget("mlabel")
self.fcombo.set_popdown_strings(const.familyRelations) self.fcombo.set_popdown_strings(const.familyRelations)
self.mother_list.set_column_visibility(2,0)
self.father_list.set_column_visibility(2,0)
self.mother_list.set_sort_column(2)
self.father_list.set_sort_column(2)
for (f,mr,fr) in self.person.getParentList(): for (f,mr,fr) in self.person.getParentList():
if f == self.family: if f == self.family:
self.mother_rel.set_text(_(mr)) self.mother_rel.set_text(_(mr))
@ -85,6 +92,10 @@ class ChooseParents:
self.mother_rel.set_text(_("Birth")) self.mother_rel.set_text(_("Birth"))
self.father_rel.set_text(_("Birth")) self.father_rel.set_text(_("Birth"))
self.type = self.family.getRelationship()
self.prel.set_text(_(self.type))
self.redraw()
self.glade.signal_autoconnect({ self.glade.signal_autoconnect({
"on_motherList_select_row" : self.mother_list_select_row, "on_motherList_select_row" : self.mother_list_select_row,
"on_fatherList_select_row" : self.father_list_select_row, "on_fatherList_select_row" : self.father_list_select_row,
@ -97,29 +108,22 @@ class ChooseParents:
text = _("Choose the Parents of %s") % GrampsCfg.nameof(self.person) text = _("Choose the Parents of %s") % GrampsCfg.nameof(self.person)
self.title.set_text(text) self.title.set_text(text)
if self.family:
self.prel.set_text(_(self.family.getRelationship()))
else:
self.parent_relation_changed(self.prel)
self.top.show() self.top.show()
def parent_relation_changed(self,obj): def redraw(self):
type = obj.get_text()
self.father_list.freeze() self.father_list.freeze()
self.mother_list.freeze() self.mother_list.freeze()
self.father_list.clear() self.father_list.clear()
self.mother_list.clear() self.mother_list.clear()
self.father_list.append(["Unknown",""]) self.father_list.append(["Unknown","",""])
self.father_list.set_row_data(0,None) self.father_list.set_row_data(0,None)
self.mother_list.append(["Unknown",""]) self.mother_list.append(["Unknown","",""])
self.mother_list.set_row_data(0,None) self.mother_list.set_row_data(0,None)
people = self.db.getPersonMap().values() people = self.db.getPersonMap().values()
people.sort(sort.by_last_name)
father_index = 1 father_index = 1
mother_index = 1 mother_index = 1
fsel = 0 fsel = 0
@ -133,8 +137,10 @@ class ChooseParents:
fsel = father_index fsel = father_index
if self.mother == person: if self.mother == person:
msel = mother_index msel = mother_index
rdata = [Utils.phonebook_name(person),Utils.birthday(person)] name = person.getPrimaryName()
if type == "Partners": rdata = [Utils.phonebook_name(person),Utils.birthday(person),
sort.build_sort_name(name)]
if self.type == "Partners":
self.father_list.append(rdata) self.father_list.append(rdata)
self.father_list.set_row_data(father_index,person) self.father_list.set_row_data(father_index,person)
father_index = father_index + 1 father_index = father_index + 1
@ -151,19 +157,27 @@ class ChooseParents:
mother_index = mother_index + 1 mother_index = mother_index + 1
self.mother_list.select_row(msel,0) self.mother_list.select_row(msel,0)
self.mother_list.moveto(msel,0) self.mother_list.sort()
self.father_list.select_row(fsel,0) self.father_list.select_row(fsel,0)
self.father_list.moveto(fsel,0) self.father_list.sort()
self.mother_list.thaw()
self.father_list.thaw()
self.father_list.moveto(self.father_list.selection[0],0)
self.mother_list.moveto(self.mother_list.selection[0],0)
if type == "Partners": if self.type == "Partners":
self.mlabel.set_label(_("Parent")) self.mlabel.set_label(_("Parent"))
self.flabel.set_label(_("Parent")) self.flabel.set_label(_("Parent"))
else: else:
self.mlabel.set_label(_("Mother")) self.mlabel.set_label(_("Mother"))
self.flabel.set_label(_("Father")) self.flabel.set_label(_("Father"))
self.mother_list.thaw()
self.father_list.thaw() def parent_relation_changed(self,obj):
self.old_type = self.type
self.type = const.save_frel(obj.get_text())
if self.old_type == "Partners" or self.type == "Partners":
self.redraw()
def find_family(self,father,mother): def find_family(self,father,mother):
""" """
@ -200,7 +214,6 @@ class ChooseParents:
def save_parents_clicked(self,obj): def save_parents_clicked(self,obj):
mother_rel = const.childRelations[self.mother_rel.get_text()] mother_rel = const.childRelations[self.mother_rel.get_text()]
father_rel = const.childRelations[self.father_rel.get_text()] father_rel = const.childRelations[self.father_rel.get_text()]
type = const.save_frel(self.prel.get_text())
msel = self.mother_list.selection msel = self.mother_list.selection
fsel = self.father_list.selection fsel = self.father_list.selection
@ -217,27 +230,45 @@ class ChooseParents:
self.father = None self.father = None
self.family = self.find_family(self.father,self.mother) self.family = self.find_family(self.father,self.mother)
elif self.mother.getGender() != self.father.getGender(): elif self.mother.getGender() != self.father.getGender():
if type == "Partners": if self.type == "Partners":
type = "Unknown" self.type = "Unknown"
if self.father.getGender() == RelLib.Person.female: if self.father.getGender() == RelLib.Person.female:
x = self.father x = self.father
self.father = self.mother self.father = self.mother
self.mother = x self.mother = x
self.family = self.find_family(self.father,self.mother) self.family = self.find_family(self.father,self.mother)
else: else:
type = "Partners" self.type = "Partners"
self.family = self.find_family(self.father,self.mother) self.family = self.find_family(self.father,self.mother)
else: else:
self.family = None self.family = None
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
if self.family: if self.family:
self.family.setRelationship(type) self.family.setRelationship(self.type)
self.change_family_type(self.family,mother_rel,father_rel) self.change_family_type(self.family,mother_rel,father_rel)
self.family_update(None) self.family_update(None)
def add_new_parent(self,person): def add_new_parent(self,person):
self.type = const.save_frel(self.prel.get_text())
rdata = [Utils.phonebook_name(person),Utils.birthday(person),
sort.build_sort_name(person.getPrimaryName())]
if self.type == "Partners":
self.parent_relation_changed(self.prel) self.parent_relation_changed(self.prel)
elif person.getGender() == RelLib.Person.male:
self.father_list.insert(0,rdata)
self.father_list.set_row_data(0,person)
self.father_list.select_row(0,0)
self.father_list.sort()
self.father_list.moveto(self.father_list.selection[0],0)
else:
self.mother_list.insert(0,rdata)
self.mother_list.set_row_data(0,person)
self.mother_list.select_row(0,0)
self.mother_list.moveto(0,0)
self.mother_list.sort()
self.mother_list.moveto(self.mother_list.selection[0],0)
self.full_update() self.full_update()
def add_parent_clicked(self,obj): def add_parent_clicked(self,obj):

View File

@ -1100,7 +1100,6 @@ class Person:
def setMainParents(self,family): def setMainParents(self,family):
"""sets the main Family of the Person, the Family in which the """sets the main Family of the Person, the Family in which the
Person is a natural born child""" Person is a natural born child"""
print family,self.AltFamilyList
f = self.removeAltFamily(family) f = self.removeAltFamily(family)
if f: if f:
self.AltFamilyList = [f] + self.AltFamilyList self.AltFamilyList = [f] + self.AltFamilyList

View File

@ -4977,14 +4977,14 @@
<name>fatherList</name> <name>fatherList</name>
<border_width>3</border_width> <border_width>3</border_width>
<width>400</width> <width>400</width>
<height>100</height> <height>150</height>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<signal> <signal>
<name>select_row</name> <name>select_row</name>
<handler>on_fatherList_select_row</handler> <handler>on_fatherList_select_row</handler>
</signal> </signal>
<columns>2</columns> <columns>3</columns>
<column_widths>198,80</column_widths> <column_widths>200,190,10</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode> <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles> <show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type> <shadow_type>GTK_SHADOW_IN</shadow_type>
@ -5014,6 +5014,19 @@
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
</widget> </widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label82a</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget> </widget>
</widget> </widget>
@ -5123,14 +5136,14 @@ Unknown
<class>GtkCList</class> <class>GtkCList</class>
<name>motherList</name> <name>motherList</name>
<border_width>3</border_width> <border_width>3</border_width>
<height>100</height> <height>150</height>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<signal> <signal>
<name>select_row</name> <name>select_row</name>
<handler>on_motherList_select_row</handler> <handler>on_motherList_select_row</handler>
</signal> </signal>
<columns>2</columns> <columns>3</columns>
<column_widths>198,80</column_widths> <column_widths>200,190,10</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode> <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles> <show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type> <shadow_type>GTK_SHADOW_IN</shadow_type>
@ -5160,6 +5173,19 @@ Unknown
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
</widget> </widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label85a</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget> </widget>
</widget> </widget>

View File

@ -1416,6 +1416,11 @@ class Gramps:
def load_family(self,family=None): def load_family(self,family=None):
if family != None: if family != None:
self.active_family = family self.active_family = family
elif self.active_person:
flist = self.active_person.getFamilyList()
if len(flist) > 0:
self.active_family = flist[0]
if self.active_family: if self.active_family:
flist = self.active_person.getFamilyList() flist = self.active_person.getFamilyList()
if self.active_person != self.active_family.getFather() and \ if self.active_person != self.active_family.getFather() and \