Sorting in ChooseParents dialog

svn: r1042
This commit is contained in:
Don Allingham 2002-06-20 02:06:06 +00:00
parent a624eaff40
commit ace403cb64
3 changed files with 299 additions and 60 deletions

View File

@ -104,9 +104,17 @@ class AddSpouse:
self.relation_type.set_text(_("Married")) self.relation_type.set_text(_("Married"))
def select_row(self,obj,a,b,c): def select_row(self,obj,a,b,c):
"""
Called with a row has be unselected. Used to ensable the OK button
when a row has been selected.
"""
self.ok.set_sensitive(1) self.ok.set_sensitive(1)
def unselect_row(self,obj,a,b,c): def unselect_row(self,obj,a,b,c):
"""
Called with a row has be unselected. Used to disable the OK button
when nothing is selected.
"""
self.ok.set_sensitive(0) self.ok.set_sensitive(0)
def new_spouse_clicked(self,obj): def new_spouse_clicked(self,obj):
@ -130,10 +138,15 @@ class AddSpouse:
QuickAdd.QuickAdd(self.db,gen,self.update_list) QuickAdd.QuickAdd(self.db,gen,self.update_list)
def update_list(self,person): def update_list(self,person):
"""
Updates the potential spouse list after a person has been added
to database. Called by the QuickAdd class when the dialog has
been closed.
"""
self.addperson(person) self.addperson(person)
self.relation_type_changed(self.relation_type) self.relation_type_changed(self.relation_type)
row = self.spouse_list.find_row_from_data(person)
self.sorter.sort_list() self.sorter.sort_list()
row = self.spouse_list.find_row_from_data(person.getId())
self.spouse_list.select_row(row,0) self.spouse_list.select_row(row,0)
self.spouse_list.moveto(row,0) self.spouse_list.moveto(row,0)

View File

@ -43,6 +43,7 @@ import const
import sort import sort
import Utils import Utils
import GrampsCfg import GrampsCfg
import Sorter
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -83,8 +84,16 @@ 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)
fmap = [(2,self.glade.get_widget('fname_arrow')),
(3,self.glade.get_widget('fbirth_arrow'))]
self.fsort = Sorter.Sorter(self.father_list,fmap,'flist')
mmap = [(2,self.glade.get_widget('mname_arrow')),
(3,self.glade.get_widget('mbirth_arrow'))]
self.msort = Sorter.Sorter(self.mother_list,mmap,'mlist')
self.mother_list.set_column_visibility(2,0) self.mother_list.set_column_visibility(2,0)
self.father_list.set_column_visibility(2,0) self.father_list.set_column_visibility(2,0)
self.mother_list.set_column_visibility(3,0)
self.father_list.set_column_visibility(3,0)
self.mother_list.set_sort_column(2) self.mother_list.set_sort_column(2)
self.father_list.set_sort_column(2) self.father_list.set_sort_column(2)
@ -125,43 +134,52 @@ class ChooseParents:
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)
father_index = 1 father_index = 1
mother_index = 1 mother_index = 1
fsel = 0 fsel = 0
msel = 0 msel = 0
pkey = self.person.getId()
gender = self.person.getGender()
if self.father:
fid = self.father.getId()
else:
fid = None
if self.mother:
mid = self.mother.getId()
else:
mid = None
for key in self.db.getPersonKeys(): for key in self.db.getPersonKeys():
person = self.db.getPerson(key) if pkey == key:
if person == self.person:
continue continue
if person.getGender() == RelLib.Person.unknown: if gender == const.unknown:
continue continue
if self.father == person: if fid == key:
fsel = father_index fsel = father_index
if self.mother == person: if mid == key:
msel = mother_index msel = mother_index
name = person.getPrimaryName() dinfo = self.db.getPersonDisplay(key)
rdata = [Utils.phonebook_name(person),Utils.birthday(person), rdata = [dinfo[0],dinfo[3],dinfo[5],dinfo[6]]
sort.build_sort_name(name)]
if self.type == "Partners": 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,dinfo[1])
father_index = father_index + 1 father_index = father_index + 1
self.mother_list.append(rdata) self.mother_list.append(rdata)
self.mother_list.set_row_data(mother_index,person) self.mother_list.set_row_data(mother_index,dinfo[1])
mother_index = mother_index + 1 mother_index = mother_index + 1
elif person.getGender() == RelLib.Person.male: elif dinfo[2] == const.male:
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,dinfo[1])
father_index = father_index + 1 father_index = father_index + 1
else: else:
self.mother_list.append(rdata) self.mother_list.append(rdata)
self.mother_list.set_row_data(mother_index,person) self.mother_list.set_row_data(mother_index,dinfo[1])
mother_index = mother_index + 1 mother_index = mother_index + 1
self.mother_list.select_row(msel,0) self.mother_list.select_row(msel,0)
@ -213,10 +231,18 @@ class ChooseParents:
return family return family
def mother_list_select_row(self,obj,a,b,c): def mother_list_select_row(self,obj,a,b,c):
self.mother = obj.get_row_data(a) id = obj.get_row_data(a)
if id:
self.mother = self.db.getPerson(id)
else:
self.mother = None
def father_list_select_row(self,obj,a,b,c): def father_list_select_row(self,obj,a,b,c):
self.father = obj.get_row_data(a) id = obj.get_row_data(a)
if id:
self.father = self.db.getPerson(id)
else:
self.father = None
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()]

View File

@ -5101,16 +5101,34 @@
<name>select_row</name> <name>select_row</name>
<handler>on_fatherList_select_row</handler> <handler>on_fatherList_select_row</handler>
</signal> </signal>
<columns>3</columns> <columns>4</columns>
<column_widths>200,190,10</column_widths> <column_widths>200,190,5,5</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>
<widget>
<class>GtkHBox</class>
<child_name>CList:title</child_name>
<name>hbox84</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox85</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<child_name>CList:title</child_name> <child_name>CList:title</child_name>
<name>label81</name> <name>label320</name>
<label>Name</label> <label>Name</label>
<justify>GTK_JUSTIFY_CENTER</justify> <justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap> <wrap>False</wrap>
@ -5118,13 +5136,95 @@
<yalign>0.5</yalign> <yalign>0.5</yalign>
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkArrow</class>
<name>fname_arrow</name>
<width>10</width>
<height>10</height>
<arrow_type>GTK_ARROW_DOWN</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>5</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<child_name>CList:title</child_name>
<name>hbox88</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox89</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label322</name>
<label>Birth Date</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkArrow</class>
<name>fbirth_arrow</name>
<width>10</width>
<height>10</height>
<visible>False</visible>
<arrow_type>GTK_ARROW_DOWN</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget> </widget>
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<child_name>CList:title</child_name> <child_name>CList:title</child_name>
<name>label82</name> <name>label82a</name>
<label>Birth Date</label> <label></label>
<justify>GTK_JUSTIFY_CENTER</justify> <justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap> <wrap>False</wrap>
<xalign>0.5</xalign> <xalign>0.5</xalign>
@ -5136,7 +5236,7 @@
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<child_name>CList:title</child_name> <child_name>CList:title</child_name>
<name>label82a</name> <name>label82b</name>
<label></label> <label></label>
<justify>GTK_JUSTIFY_CENTER</justify> <justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap> <wrap>False</wrap>
@ -5260,16 +5360,34 @@ Unknown
<name>select_row</name> <name>select_row</name>
<handler>on_motherList_select_row</handler> <handler>on_motherList_select_row</handler>
</signal> </signal>
<columns>3</columns> <columns>4</columns>
<column_widths>200,190,10</column_widths> <column_widths>200,190,5,5</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>
<widget>
<class>GtkHBox</class>
<child_name>CList:title</child_name>
<name>hbox86</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox87</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<child_name>CList:title</child_name> <child_name>CList:title</child_name>
<name>label84</name> <name>label321</name>
<label>Name</label> <label>Name</label>
<justify>GTK_JUSTIFY_CENTER</justify> <justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap> <wrap>False</wrap>
@ -5277,13 +5395,95 @@ Unknown
<yalign>0.5</yalign> <yalign>0.5</yalign>
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkArrow</class>
<name>mname_arrow</name>
<width>10</width>
<height>10</height>
<arrow_type>GTK_ARROW_DOWN</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>5</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<child_name>CList:title</child_name>
<name>hbox90</name>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox91</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label323</name>
<label>Birth Date</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkArrow</class>
<name>mbirth_arrow</name>
<width>10</width>
<height>10</height>
<visible>False</visible>
<arrow_type>GTK_ARROW_DOWN</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget> </widget>
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<child_name>CList:title</child_name> <child_name>CList:title</child_name>
<name>label85</name> <name>label85a</name>
<label>Birth Date</label> <label></label>
<justify>GTK_JUSTIFY_CENTER</justify> <justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap> <wrap>False</wrap>
<xalign>0.5</xalign> <xalign>0.5</xalign>
@ -5295,7 +5495,7 @@ Unknown
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<child_name>CList:title</child_name> <child_name>CList:title</child_name>
<name>label85a</name> <name>label85b</name>
<label></label> <label></label>
<justify>GTK_JUSTIFY_CENTER</justify> <justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap> <wrap>False</wrap>
@ -5370,7 +5570,7 @@ Unknown
<editable>True</editable> <editable>True</editable>
<text_visible>True</text_visible> <text_visible>True</text_visible>
<text_max_length>0</text_max_length> <text_max_length>0</text_max_length>
<text></text> <text>Birth</text>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -5479,7 +5679,7 @@ Unknown
<editable>False</editable> <editable>False</editable>
<text_visible>True</text_visible> <text_visible>True</text_visible>
<text_max_length>0</text_max_length> <text_max_length>0</text_max_length>
<text>Birth</text> <text></text>
</widget> </widget>
</widget> </widget>
</widget> </widget>