Better spouse handling

svn: r859
This commit is contained in:
Don Allingham 2002-03-26 23:47:04 +00:00
parent 54da58996a
commit 7ff7bb789d
3 changed files with 157 additions and 156 deletions

View File

@ -1079,7 +1079,6 @@ class Person:
def addAltFamily(self,family,mrel,frel): def addAltFamily(self,family,mrel,frel):
"""adds a Family to the alternate family list, indicating the relationship """adds a Family to the alternate family list, indicating the relationship
to the mother (mrel) and the father (frel)""" to the mother (mrel) and the father (frel)"""
assert(family==None)
self.AltFamilyList.append((family,mrel,frel)) self.AltFamilyList.append((family,mrel,frel))
def removeAltFamily(self,family): def removeAltFamily(self,family):

View File

@ -1545,6 +1545,7 @@
<widget> <widget>
<class>GtkButton</class> <class>GtkButton</class>
<name>editSpouse</name> <name>editSpouse</name>
<border_width>5</border_width>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<signal> <signal>
<name>clicked</name> <name>clicked</name>
@ -1570,10 +1571,14 @@
</widget> </widget>
<widget> <widget>
<class>GtkHBox</class> <class>GtkHButtonBox</class>
<name>hbox77</name> <name>hbuttonbox30</name>
<homogeneous>False</homogeneous> <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
<spacing>0</spacing> <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> <child>
<left_attach>1</left_attach> <left_attach>1</left_attach>
<right_attach>2</right_attach> <right_attach>2</right_attach>
@ -1582,7 +1587,7 @@
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
<xexpand>False</xexpand> <xexpand>False</xexpand>
<yexpand>False</yexpand> <yexpand>True</yexpand>
<xshrink>False</xshrink> <xshrink>False</xshrink>
<yshrink>False</yshrink> <yshrink>False</yshrink>
<xfill>True</xfill> <xfill>True</xfill>
@ -1590,118 +1595,30 @@
</child> </child>
<widget> <widget>
<class>GtkHButtonBox</class> <class>GtkButton</class>
<name>hbuttonbox30</name> <name>pref_spouse</name>
<layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> <can_default>True</can_default>
<spacing>30</spacing> <can_focus>True</can_focus>
<child_min_width>85</child_min_width> <signal>
<child_min_height>27</child_min_height> <name>clicked</name>
<child_ipad_x>7</child_ipad_x> <handler>on_prefrel_toggled</handler>
<child_ipad_y>0</child_ipad_y> <last_modification_time>Tue, 26 Mar 2002 15:03:14 GMT</last_modification_time>
<child> </signal>
<padding>0</padding> <label>Make this the preferred spouse</label>
<expand>True</expand> <relief>GTK_RELIEF_NORMAL</relief>
<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>
</widget> </widget>
</widget> </widget>
<widget> <widget>
<class>GtkEntry</class> <class>GtkNotebook</class>
<name>fv_spouse1</name> <name>spouse_tab</name>
<can_focus>True</can_focus> <show_tabs>False</show_tabs>
<editable>False</editable> <show_border>False</show_border>
<text_visible>True</text_visible> <tab_pos>GTK_POS_TOP</tab_pos>
<text_max_length>0</text_max_length> <scrollable>False</scrollable>
<text></text> <tab_hborder>2</tab_hborder>
<tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable>
<child> <child>
<left_attach>1</left_attach> <left_attach>1</left_attach>
<right_attach>2</right_attach> <right_attach>2</right_attach>
@ -1714,8 +1631,72 @@
<xshrink>False</xshrink> <xshrink>False</xshrink>
<yshrink>False</yshrink> <yshrink>False</yshrink>
<xfill>True</xfill> <xfill>True</xfill>
<yfill>False</yfill> <yfill>True</yfill>
</child> </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>
</widget> </widget>

View File

@ -89,7 +89,6 @@ class Gramps:
self.active_mother = None self.active_mother = None
self.active_parents = None self.active_parents = None
self.parents_index = 0 self.parents_index = 0
self.spouse_index = 0
self.active_person = None self.active_person = None
self.active_spouse = None self.active_spouse = None
self.bookmarks = None self.bookmarks = None
@ -182,6 +181,8 @@ class Gramps:
self.spouse_pref = self.gtop.get_widget("prefrel") self.spouse_pref = self.gtop.get_widget("prefrel")
self.spouse_edit = self.gtop.get_widget("edit_sp") self.spouse_edit = self.gtop.get_widget("edit_sp")
self.spouse_del = self.gtop.get_widget("delete_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(5,0)
self.person_list.set_column_visibility(6,0) self.person_list.set_column_visibility(6,0)
@ -216,8 +217,7 @@ class Gramps:
"on_preffam_clicked" : self.on_preferred_fam_toggled, "on_preffam_clicked" : self.on_preferred_fam_toggled,
"on_family_up_clicked" : self.family_up_clicked, "on_family_up_clicked" : self.family_up_clicked,
"on_family_down_clicked" : self.family_down_clicked, "on_family_down_clicked" : self.family_down_clicked,
"on_spouse_up_clicked" : self.spouse_up_clicked, "on_spouse_list_changed" : self.spouse_list_changed,
"on_spouse_down_clicked" : self.spouse_down_clicked,
"on_prefrel_toggled" : self.on_preferred_rel_toggled, "on_prefrel_toggled" : self.on_preferred_rel_toggled,
"on_about_activate" : self.on_about_activate, "on_about_activate" : self.on_about_activate,
"on_add_bookmark_activate" : self.on_add_bookmark_activate, "on_add_bookmark_activate" : self.on_add_bookmark_activate,
@ -1274,13 +1274,9 @@ class Gramps:
def on_swap_clicked(self,obj): def on_swap_clicked(self,obj):
if not self.active_person: if not self.active_person:
return 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: if self.active_spouse:
self.change_active_person(spouse) self.change_active_person(self.active_spouse)
self.load_family() self.load_family()
def on_apply_filter_clicked(self,obj): def on_apply_filter_clicked(self,obj):
@ -1381,6 +1377,41 @@ class Gramps:
EditPerson.EditPerson(person,self.database, EditPerson.EditPerson(person,self.database,
self.update_after_edit) 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): def load_family(self,family=None):
if family != None: if family != None:
self.active_family = family self.active_family = family
@ -1392,9 +1423,7 @@ class Gramps:
self.active_family = flist[0] self.active_family = flist[0]
else: else:
self.active_family = None self.active_family = None
self.spouse_index = 0
family_types = [] family_types = []
main_family = None main_family = None
@ -1425,21 +1454,14 @@ class Gramps:
if number_of_families > 1: if number_of_families > 1:
if self.active_family == None: if self.active_family == None:
self.active_family = flist[0] 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.pref_spouse.show()
self.multi_spouse.show() self.spouse_tab.set_page(1)
if self.active_family == flist[0]: if self.active_family == flist[0]:
self.pref_spouse.set_sensitive(0) self.pref_spouse.set_sensitive(0)
msg = _("Preferred Relationship (%d of %d)") % (self.spouse_index+1, msg = _("Preferred Relationship")
len(flist))
else: else:
msg = _("Relationship (%d of %d)") % (self.spouse_index+1, msg = _("Relationship")
len(flist))
self.pref_spouse.set_sensitive(1) self.pref_spouse.set_sensitive(1)
self.gtop.get_widget('rel_frame').set_label(msg) self.gtop.get_widget('rel_frame').set_label(msg)
@ -1448,12 +1470,13 @@ class Gramps:
else: else:
spouse = self.active_family.getMother() spouse = self.active_family.getMother()
self.build_spouse_dropdown()
self.spouse_text.set_text(GrampsCfg.nameof(spouse)) self.spouse_text.set_text(GrampsCfg.nameof(spouse))
self.spouse_edit.set_sensitive(1) self.spouse_edit.set_sensitive(1)
self.spouse_del.set_sensitive(1) self.spouse_del.set_sensitive(1)
elif number_of_families == 1: elif number_of_families == 1:
self.pref_spouse.hide() self.pref_spouse.hide()
self.multi_spouse.hide() self.spouse_tab.set_page(0)
f = self.active_person.getFamilyList()[0] f = self.active_person.getFamilyList()[0]
if self.active_person != f.getFather(): if self.active_person != f.getFather():
spouse = f.getFather() spouse = f.getFather()
@ -1466,7 +1489,7 @@ class Gramps:
self.gtop.get_widget('rel_frame').set_label(_("Relationship")) self.gtop.get_widget('rel_frame').set_label(_("Relationship"))
else: else:
self.pref_spouse.hide() self.pref_spouse.hide()
self.multi_spouse.hide() self.spouse_tab.set_page(0)
self.spouse_text.set_text("") self.spouse_text.set_text("")
self.active_spouse = None self.active_spouse = None
self.spouse_edit.set_sensitive(0) self.spouse_edit.set_sensitive(0)
@ -1483,7 +1506,7 @@ class Gramps:
else: else:
self.spouse_text.set_text("") self.spouse_text.set_text("")
self.display_marriage(None) self.display_marriage(None)
def change_parents(self,family): def change_parents(self,family):
"""Switches to a different set of parents on the Family View""" """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.active_parents = flist[self.parents_index][0]
self.change_parents(self.active_parents) self.change_parents(self.active_parents)
def spouse_up_clicked(self,obj): def spouse_list_changed(self,obj):
if self.active_family == None: if self.active_family == None:
return return
flist = self.active_person.getFamilyList() select = self.spouse_combo.list.get_selection()
if self.spouse_index == 0: if len(select) == 0:
self.spouse_index = len(flist)-1 self.active_family = None
else: else:
self.spouse_index = self.spouse_index - 1 self.active_family = select[0].get_data('d')
self.active_family = flist[self.spouse_index]
self.load_family()
def spouse_down_clicked(self,obj): if self.active_family == self.active_person.getFamilyList()[0]:
if self.active_family == None: self.pref_spouse.set_sensitive(0)
return msg = _("Preferred Relationship")
flist = self.active_person.getFamilyList()
if self.spouse_index == len(flist)-1:
self.spouse_index = 0
else: else:
self.spouse_index = self.spouse_index + 1 msg = _("Relationship")
self.active_family = flist[self.spouse_index] self.pref_spouse.set_sensitive(1)
self.load_family()
self.gtop.get_widget('rel_frame').set_label(msg)
self.display_marriage(self.active_family)
def export_callback(self,obj,plugin_function): def export_callback(self,obj,plugin_function):
"""Call the export plugin, with the active person and database""" """Call the export plugin, with the active person and database"""