Better spouse handling
svn: r859
This commit is contained in:
parent
aeaa70dc7f
commit
dd764f28cd
@ -1079,7 +1079,6 @@ class Person:
|
||||
def addAltFamily(self,family,mrel,frel):
|
||||
"""adds a Family to the alternate family list, indicating the relationship
|
||||
to the mother (mrel) and the father (frel)"""
|
||||
assert(family==None)
|
||||
self.AltFamilyList.append((family,mrel,frel))
|
||||
|
||||
def removeAltFamily(self,family):
|
||||
|
209
src/gramps.glade
209
src/gramps.glade
@ -1545,6 +1545,7 @@
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>editSpouse</name>
|
||||
<border_width>5</border_width>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
@ -1570,10 +1571,14 @@
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox77</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<class>GtkHButtonBox</class>
|
||||
<name>hbuttonbox30</name>
|
||||
<layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
|
||||
<spacing>30</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
@ -1582,7 +1587,7 @@
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<yexpand>True</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
@ -1590,118 +1595,30 @@
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<name>hbuttonbox30</name>
|
||||
<layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
|
||||
<spacing>30</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>pref_spouse</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_prefrel_toggled</handler>
|
||||
<last_modification_time>Tue, 26 Mar 2002 15:03:14 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Make this the preferred spouse</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>multi_spouse</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button150</name>
|
||||
<tooltip>Make the current father the active person</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_spouse_up_clicked</handler>
|
||||
<last_modification_time>Tue, 26 Mar 2002 15:18:30 GMT</last_modification_time>
|
||||
</signal>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkArrow</class>
|
||||
<name>arrow13</name>
|
||||
<width>10</width>
|
||||
<height>10</height>
|
||||
<arrow_type>GTK_ARROW_UP</arrow_type>
|
||||
<shadow_type>GTK_SHADOW_OUT</shadow_type>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button151</name>
|
||||
<tooltip>Make the current mother the active person</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_spouse_down_clicked</handler>
|
||||
<last_modification_time>Tue, 26 Mar 2002 15:18:40 GMT</last_modification_time>
|
||||
</signal>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkArrow</class>
|
||||
<name>arrow14</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>
|
||||
</widget>
|
||||
</widget>
|
||||
<class>GtkButton</class>
|
||||
<name>pref_spouse</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_prefrel_toggled</handler>
|
||||
<last_modification_time>Tue, 26 Mar 2002 15:03:14 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Make this the preferred spouse</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
<name>fv_spouse1</name>
|
||||
<can_focus>True</can_focus>
|
||||
<editable>False</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
<class>GtkNotebook</class>
|
||||
<name>spouse_tab</name>
|
||||
<show_tabs>False</show_tabs>
|
||||
<show_border>False</show_border>
|
||||
<tab_pos>GTK_POS_TOP</tab_pos>
|
||||
<scrollable>False</scrollable>
|
||||
<tab_hborder>2</tab_hborder>
|
||||
<tab_vborder>2</tab_vborder>
|
||||
<popup_enable>False</popup_enable>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
@ -1714,8 +1631,72 @@
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
<name>fv_spouse1</name>
|
||||
<can_focus>True</can_focus>
|
||||
<editable>False</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<child_name>Notebook:tab</child_name>
|
||||
<name>label303</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>
|
||||
<class>GtkCombo</class>
|
||||
<name>spouse_combo</name>
|
||||
<border_width>3</border_width>
|
||||
<value_in_list>True</value_in_list>
|
||||
<ok_if_empty>True</ok_if_empty>
|
||||
<case_sensitive>False</case_sensitive>
|
||||
<use_arrows>True</use_arrows>
|
||||
<use_arrows_always>False</use_arrows_always>
|
||||
<items></items>
|
||||
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
<child_name>GtkCombo:entry</child_name>
|
||||
<name>combo-entry1</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>on_spouse_list_changed</handler>
|
||||
<last_modification_time>Tue, 26 Mar 2002 23:26:23 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>False</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<child_name>Notebook:tab</child_name>
|
||||
<name>label304</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>
|
||||
|
||||
|
@ -89,7 +89,6 @@ class Gramps:
|
||||
self.active_mother = None
|
||||
self.active_parents = None
|
||||
self.parents_index = 0
|
||||
self.spouse_index = 0
|
||||
self.active_person = None
|
||||
self.active_spouse = None
|
||||
self.bookmarks = None
|
||||
@ -182,6 +181,8 @@ class Gramps:
|
||||
self.spouse_pref = self.gtop.get_widget("prefrel")
|
||||
self.spouse_edit = self.gtop.get_widget("edit_sp")
|
||||
self.spouse_del = self.gtop.get_widget("delete_sp")
|
||||
self.spouse_combo= self.gtop.get_widget("spouse_combo")
|
||||
self.spouse_tab = self.gtop.get_widget("spouse_tab")
|
||||
|
||||
self.person_list.set_column_visibility(5,0)
|
||||
self.person_list.set_column_visibility(6,0)
|
||||
@ -216,8 +217,7 @@ class Gramps:
|
||||
"on_preffam_clicked" : self.on_preferred_fam_toggled,
|
||||
"on_family_up_clicked" : self.family_up_clicked,
|
||||
"on_family_down_clicked" : self.family_down_clicked,
|
||||
"on_spouse_up_clicked" : self.spouse_up_clicked,
|
||||
"on_spouse_down_clicked" : self.spouse_down_clicked,
|
||||
"on_spouse_list_changed" : self.spouse_list_changed,
|
||||
"on_prefrel_toggled" : self.on_preferred_rel_toggled,
|
||||
"on_about_activate" : self.on_about_activate,
|
||||
"on_add_bookmark_activate" : self.on_add_bookmark_activate,
|
||||
@ -1274,13 +1274,9 @@ class Gramps:
|
||||
def on_swap_clicked(self,obj):
|
||||
if not self.active_person:
|
||||
return
|
||||
if len(self.active_person.getFamilyList()) > 1:
|
||||
spouse = self.spouse_menu.get_menu().get_active().get_data("person")
|
||||
else:
|
||||
spouse = self.spouse_text.get_data("person")
|
||||
|
||||
if spouse:
|
||||
self.change_active_person(spouse)
|
||||
if self.active_spouse:
|
||||
self.change_active_person(self.active_spouse)
|
||||
self.load_family()
|
||||
|
||||
def on_apply_filter_clicked(self,obj):
|
||||
@ -1381,6 +1377,41 @@ class Gramps:
|
||||
EditPerson.EditPerson(person,self.database,
|
||||
self.update_after_edit)
|
||||
|
||||
def build_spouse_dropdown(self):
|
||||
mymap = {}
|
||||
mynmap = {}
|
||||
list = []
|
||||
for f in self.active_person.getFamilyList():
|
||||
if self.active_person == f.getFather():
|
||||
if f.getMother() == None:
|
||||
sname = _("Unknown")
|
||||
else:
|
||||
sname = GrampsCfg.nameof(f.getMother())
|
||||
else:
|
||||
if f.getFather() == None:
|
||||
sname = _("Unknown")
|
||||
else:
|
||||
sname = GrampsCfg.nameof(f.getFather())
|
||||
l = gtk.GtkLabel(sname)
|
||||
l.show()
|
||||
l.set_alignment(0,0.5)
|
||||
c = gtk.GtkListItem()
|
||||
c.add(l)
|
||||
c.set_data('d',f)
|
||||
c.show()
|
||||
list.append(c)
|
||||
if f == self.active_family:
|
||||
sel = c
|
||||
mymap[f] = c
|
||||
mynmap[f] = sname
|
||||
self.spouse_combo.disable_activate()
|
||||
self.spouse_combo.list.clear_items(0,-1)
|
||||
self.spouse_combo.list.append_items(list)
|
||||
self.spouse_combo.list.select_child(sel)
|
||||
|
||||
for v in mymap.keys():
|
||||
self.spouse_combo.set_item_string(mymap[v],mynmap[v])
|
||||
|
||||
def load_family(self,family=None):
|
||||
if family != None:
|
||||
self.active_family = family
|
||||
@ -1392,9 +1423,7 @@ class Gramps:
|
||||
self.active_family = flist[0]
|
||||
else:
|
||||
self.active_family = None
|
||||
|
||||
self.spouse_index = 0
|
||||
|
||||
|
||||
family_types = []
|
||||
|
||||
main_family = None
|
||||
@ -1425,21 +1454,14 @@ class Gramps:
|
||||
if number_of_families > 1:
|
||||
if self.active_family == None:
|
||||
self.active_family = flist[0]
|
||||
else:
|
||||
for f in flist:
|
||||
if f == self.active_family:
|
||||
break
|
||||
self.spouse_index = self.spouse_index + 1
|
||||
|
||||
self.pref_spouse.show()
|
||||
self.multi_spouse.show()
|
||||
self.spouse_tab.set_page(1)
|
||||
if self.active_family == flist[0]:
|
||||
self.pref_spouse.set_sensitive(0)
|
||||
msg = _("Preferred Relationship (%d of %d)") % (self.spouse_index+1,
|
||||
len(flist))
|
||||
msg = _("Preferred Relationship")
|
||||
else:
|
||||
msg = _("Relationship (%d of %d)") % (self.spouse_index+1,
|
||||
len(flist))
|
||||
msg = _("Relationship")
|
||||
self.pref_spouse.set_sensitive(1)
|
||||
|
||||
self.gtop.get_widget('rel_frame').set_label(msg)
|
||||
@ -1448,12 +1470,13 @@ class Gramps:
|
||||
else:
|
||||
spouse = self.active_family.getMother()
|
||||
|
||||
self.build_spouse_dropdown()
|
||||
self.spouse_text.set_text(GrampsCfg.nameof(spouse))
|
||||
self.spouse_edit.set_sensitive(1)
|
||||
self.spouse_del.set_sensitive(1)
|
||||
elif number_of_families == 1:
|
||||
self.pref_spouse.hide()
|
||||
self.multi_spouse.hide()
|
||||
self.spouse_tab.set_page(0)
|
||||
f = self.active_person.getFamilyList()[0]
|
||||
if self.active_person != f.getFather():
|
||||
spouse = f.getFather()
|
||||
@ -1466,7 +1489,7 @@ class Gramps:
|
||||
self.gtop.get_widget('rel_frame').set_label(_("Relationship"))
|
||||
else:
|
||||
self.pref_spouse.hide()
|
||||
self.multi_spouse.hide()
|
||||
self.spouse_tab.set_page(0)
|
||||
self.spouse_text.set_text("")
|
||||
self.active_spouse = None
|
||||
self.spouse_edit.set_sensitive(0)
|
||||
@ -1483,7 +1506,7 @@ class Gramps:
|
||||
else:
|
||||
self.spouse_text.set_text("")
|
||||
self.display_marriage(None)
|
||||
|
||||
|
||||
def change_parents(self,family):
|
||||
"""Switches to a different set of parents on the Family View"""
|
||||
|
||||
@ -1845,27 +1868,25 @@ class Gramps:
|
||||
self.active_parents = flist[self.parents_index][0]
|
||||
self.change_parents(self.active_parents)
|
||||
|
||||
def spouse_up_clicked(self,obj):
|
||||
def spouse_list_changed(self,obj):
|
||||
if self.active_family == None:
|
||||
return
|
||||
flist = self.active_person.getFamilyList()
|
||||
if self.spouse_index == 0:
|
||||
self.spouse_index = len(flist)-1
|
||||
select = self.spouse_combo.list.get_selection()
|
||||
if len(select) == 0:
|
||||
self.active_family = None
|
||||
else:
|
||||
self.spouse_index = self.spouse_index - 1
|
||||
self.active_family = flist[self.spouse_index]
|
||||
self.load_family()
|
||||
self.active_family = select[0].get_data('d')
|
||||
|
||||
def spouse_down_clicked(self,obj):
|
||||
if self.active_family == None:
|
||||
return
|
||||
flist = self.active_person.getFamilyList()
|
||||
if self.spouse_index == len(flist)-1:
|
||||
self.spouse_index = 0
|
||||
if self.active_family == self.active_person.getFamilyList()[0]:
|
||||
self.pref_spouse.set_sensitive(0)
|
||||
msg = _("Preferred Relationship")
|
||||
else:
|
||||
self.spouse_index = self.spouse_index + 1
|
||||
self.active_family = flist[self.spouse_index]
|
||||
self.load_family()
|
||||
msg = _("Relationship")
|
||||
self.pref_spouse.set_sensitive(1)
|
||||
|
||||
self.gtop.get_widget('rel_frame').set_label(msg)
|
||||
|
||||
self.display_marriage(self.active_family)
|
||||
|
||||
def export_callback(self,obj,plugin_function):
|
||||
"""Call the export plugin, with the active person and database"""
|
||||
|
Loading…
Reference in New Issue
Block a user