diff --git a/gramps/src/AddSpouse.py b/gramps/src/AddSpouse.py index 850578508..8bcfdcd65 100644 --- a/gramps/src/AddSpouse.py +++ b/gramps/src/AddSpouse.py @@ -82,16 +82,6 @@ class AddSpouse: self.spouse_list = self.glade.get_widget("spouseList") self.relation_def = self.glade.get_widget("reldef") self.top = self.glade.get_widget("spouseDialog") - self.given = self.glade.get_widget("given") - self.surname = self.glade.get_widget("surname") - self.surname_combo = self.glade.get_widget("surname_combo") - - self.rel_combo.set_popdown_strings(const.familyRelations) - Utils.attach_surnames(self.surname_combo) - - # Typing CR selects 'Add Existing' button - self.top.editable_enters(self.given) - self.top.editable_enters(self.surname) self.name_list = self.db.getPersonMap().values() self.name_list.sort(sort.by_last_name) @@ -114,38 +104,26 @@ class AddSpouse: Called when the spouse to be added does not exist, and needs to be created and added to the database """ - spouse = RelLib.Person() - self.db.addPerson(spouse) - - name = spouse.getPrimaryName() - name.setSurname(string.strip(self.surname.get_text())) - name.setFirstName(string.strip(self.given.get_text())) + import QuickAdd relation = const.save_frel(self.relation_type.get_text()) if relation == "Partners": - spouse.setGender(self.person.getGender()) + if self.person.getGender() == RelLib.Person.male: + gen = "male" + else: + gen = "female" elif self.person.getGender() == RelLib.Person.male: - spouse.setGender(RelLib.Person.female) + gen = "female" else: - spouse.setGender(RelLib.Person.male) + gen = "male" - family = self.db.newFamily() - family.setRelationship(relation) + QuickAdd.QuickAdd(self.db,gen,self.update_list) - self.person.addFamily(family) - spouse.addFamily(family) - - if self.person.getGender() == RelLib.Person.male: - family.setMother(spouse) - family.setFather(self.person) - else: - family.setFather(spouse) - family.setMother(self.person) - - Utils.destroy_passed_object(obj) - Utils.modified() - self.addperson(spouse) - self.update(family) + def update_list(self,person): + self.name_list.append(person) + self.name_list.sort(sort.by_last_name) + self.addperson(person) + self.relation_type_changed(self.relation_type) def select_spouse_clicked(self,obj): """ diff --git a/gramps/src/ChooseParents.py b/gramps/src/ChooseParents.py index cdbe2f4d0..620b30102 100644 --- a/gramps/src/ChooseParents.py +++ b/gramps/src/ChooseParents.py @@ -70,8 +70,6 @@ class ChooseParents: self.fcombo = self.glade.get_widget("prel_combo") self.prel = self.glade.get_widget("prel") self.title = self.glade.get_widget("chooseTitle") - self.father_name = self.glade.get_widget("fatherName") - self.mother_name = self.glade.get_widget("motherName") self.father_list = self.glade.get_widget("fatherList") self.mother_list = self.glade.get_widget("motherList") self.flabel = self.glade.get_widget("flabel") @@ -91,8 +89,7 @@ class ChooseParents: "on_motherList_select_row" : self.mother_list_select_row, "on_fatherList_select_row" : self.father_list_select_row, "on_save_parents_clicked" : self.save_parents_clicked, - "on_addmother_clicked" : self.add_mother_clicked, - "on_addfather_clicked" : self.add_father_clicked, + "on_add_parent_clicked" : self.add_parent_clicked, "on_prel_changed" : self.parent_relation_changed, "on_combo_insert_text" : Utils.combo_insert_text, "destroy_passed_object" : Utils.destroy_passed_object @@ -110,9 +107,6 @@ class ChooseParents: type = obj.get_text() - self.father_name.set_text(GrampsCfg.nameof(self.father)) - self.mother_name.set_text(GrampsCfg.nameof(self.mother)) - self.father_list.freeze() self.mother_list.freeze() self.father_list.clear() @@ -128,11 +122,17 @@ class ChooseParents: people.sort(sort.by_last_name) father_index = 1 mother_index = 1 + fsel = 0 + msel = 0 for person in people: if person == self.person: continue if person.getGender() == RelLib.Person.unknown: continue + if self.father == person: + fsel = father_index + if self.mother == person: + msel = mother_index rdata = [Utils.phonebook_name(person),Utils.birthday(person)] if type == "Partners": self.father_list.append(rdata) @@ -150,12 +150,17 @@ class ChooseParents: self.mother_list.set_row_data(mother_index,person) mother_index = mother_index + 1 + self.mother_list.select_row(msel,0) + self.mother_list.moveto(msel,0) + self.father_list.select_row(fsel,0) + self.father_list.moveto(fsel,0) + if type == "Partners": - self.mlabel.set_text(_("Parent")) - self.flabel.set_text(_("Parent")) + self.mlabel.set_label(_("Parent")) + self.flabel.set_label(_("Parent")) else: - self.mlabel.set_text(_("Mother")) - self.flabel.set_text(_("Father")) + self.mlabel.set_label(_("Mother")) + self.flabel.set_label(_("Father")) self.mother_list.thaw() self.father_list.thaw() @@ -188,17 +193,18 @@ class ChooseParents: def mother_list_select_row(self,obj,a,b,c): self.mother = obj.get_row_data(a) - self.mother_name.set_text(GrampsCfg.nameof(self.mother)) def father_list_select_row(self,obj,a,b,c): self.father = obj.get_row_data(a) - self.father_name.set_text(GrampsCfg.nameof(self.father)) def save_parents_clicked(self,obj): mother_rel = const.childRelations[self.mother_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 + fsel = self.father_list.selection + if self.father or self.mother: if self.mother and not self.father: if self.mother.getGender() == RelLib.Person.male: @@ -230,25 +236,13 @@ class ChooseParents: self.change_family_type(self.family,mother_rel,father_rel) self.family_update(None) - def add_parent_clicked(self,obj,sex): - self.xml = libglade.GladeXML(const.gladeFile,"addperson") - self.xml.get_widget(sex).set_active(1) - self.xml.signal_autoconnect({ - "on_addfather_close": self.add_parent_close, - "on_combo_insert_text" : Utils.combo_insert_text, - "destroy_passed_object" : Utils.destroy_passed_object - }) - - window = self.xml.get_widget("addperson") - window.editable_enters(self.xml.get_widget("given")) - window.editable_enters(self.xml.get_widget("surname")) - Utils.attach_surnames(self.xml.get_widget("surnameCombo")) - - def add_father_clicked(self,obj): - self.add_parent_clicked(obj,"male") - - def add_mother_clicked(self,obj): - self.add_parent_clicked(obj,"female") + def add_new_parent(self,person): + self.parent_relation_changed(self.prel) + self.full_update() + + def add_parent_clicked(self,obj): + import QuickAdd + QuickAdd.QuickAdd(self.db,"male",self.add_new_parent) def change_family_type(self,family,mother_rel,father_rel): """ diff --git a/gramps/src/QuickAdd.py b/gramps/src/QuickAdd.py new file mode 100644 index 000000000..7c524704d --- /dev/null +++ b/gramps/src/QuickAdd.py @@ -0,0 +1,62 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import libglade + +import Utils +import AutoComp +import const +import RelLib + +class QuickAdd: + def __init__(self,db,sex,callback): + self.db = db + self.callback = callback + + self.xml = libglade.GladeXML(const.gladeFile,"addperson") + self.xml.get_widget(sex).set_active(1) + self.xml.signal_autoconnect({ + "on_addfather_close": self.close, + "destroy_passed_object" : Utils.destroy_passed_object + }) + + self.window = self.xml.get_widget("addperson") + self.window.editable_enters(self.xml.get_widget("given")) + self.window.editable_enters(self.xml.get_widget("surname")) + self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"), + const.surnames) + + def close(self,obj): + surname = self.xml.get_widget("surname").get_text() + given = self.xml.get_widget("given").get_text() + person = RelLib.Person() + self.db.addPerson(person) + name = person.getPrimaryName() + name.setSurname(surname) + name.setFirstName(given) + if self.xml.get_widget("male").get_active(): + person.setGender(RelLib.Person.male) + self.father = person + else: + person.setGender(RelLib.Person.female) + self.mother = person + Utils.modified() + Utils.destroy_passed_object(self.window) + self.callback(person) diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index a72e79d71..7c6cf5844 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -1570,25 +1570,19 @@ - GtkNotebook - rel_notebook - False - False - False - GTK_POS_TOP - False - 2 - 2 - False + GtkHBox + hbox77 + False + 0 1 2 1 2 - 5 + 0 0 False - True + False False False True @@ -1596,127 +1590,132 @@ - GtkCheckButton - prefrel - True - - toggled - on_prefrel_toggled - Sat, 23 Mar 2002 15:15:51 GMT - - - False - True + GtkHButtonBox + hbuttonbox30 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + True + True + + + + GtkButton + pref_spouse + True + True + + clicked + on_prefrel_toggled + Tue, 26 Mar 2002 15:03:14 GMT + + + GTK_RELIEF_NORMAL + - GtkLabel - Notebook:tab - label296 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 5 - 0 - + GtkVBox + multi_spouse + False + 0 + + 0 + False + True + - - GtkLabel - label298 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - + + GtkButton + button150 + Make the current father the active person + True + + clicked + on_spouse_up_clicked + Tue, 26 Mar 2002 15:18:30 GMT + + GTK_RELIEF_NORMAL + + 0 + False + False + - - GtkLabel - Notebook:tab - label297 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 + + GtkArrow + arrow13 + 10 + 10 + GTK_ARROW_UP + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + + + + GtkButton + button151 + Make the current mother the active person + True + + clicked + on_spouse_down_clicked + Tue, 26 Mar 2002 15:18:40 GMT + + GTK_RELIEF_NORMAL + + 0 + False + False + + + + GtkArrow + arrow14 + 10 + 10 + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + - GtkNotebook - lab_or_list - False - False - GTK_POS_TOP - False - 2 - 2 - False + GtkEntry + fv_spouse1 + True + False + True + 0 + 1 2 0 1 - 5 + 0 0 True - True + False False False True False - - - GtkEntry - fv_spouse1 - True - False - True - 0 - - - - - GtkLabel - Notebook:tab - label224 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkOptionMenu - fv_spouse - True - - - 0 - - - - GtkLabel - Notebook:tab - label225 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - @@ -2192,18 +2191,14 @@ - GtkCheckButton - preffam - False - True - - toggled - on_preffam_toggled - Sun, 24 Mar 2002 16:20:15 GMT - - - False - True + GtkHButtonBox + hbuttonbox31 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 1 2 @@ -2216,8 +2211,22 @@ False False True - False + True + + + GtkButton + preffam + True + True + + clicked + on_preffam_clicked + Tue, 26 Mar 2002 15:04:33 GMT + + + GTK_RELIEF_NORMAL + @@ -4586,7 +4595,7 @@ GtkHButtonBox GnomeDialog:action_area hbuttonbox6 - GTK_BUTTONBOX_SPREAD + GTK_BUTTONBOX_END 0 0 0 @@ -4599,21 +4608,6 @@ GTK_PACK_END - - GtkButton - spouseNewPerson - True - True - True - - clicked - on_new_spouse_clicked - spouseDialog - Thu, 23 Aug 2001 21:21:10 GMT - - - - GtkButton spouseExistingPerson @@ -4625,7 +4619,7 @@ spouseDialog Thu, 23 Aug 2001 21:21:01 GMT - + GNOME_STOCK_BUTTON_OK @@ -4670,12 +4664,10 @@ - GtkFrame - frame5 - 5 - - 0 - GTK_SHADOW_ETCHED_IN + GtkVBox + vbox50 + False + 0 0 True @@ -4692,6 +4684,11 @@ GTK_POLICY_ALWAYS GTK_UPDATE_CONTINUOUS GTK_UPDATE_CONTINUOUS + + 0 + True + True + GtkCList @@ -4735,154 +4732,36 @@ - - - - GtkFrame - frame4 - 5 - - 0 - GTK_SHADOW_ETCHED_IN - - 5 - False - True - - GtkTable - table25 - 2 - 2 - False - 5 - 5 + GtkHButtonBox + hbuttonbox28 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + False + True + - GtkLabel - label235 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 5 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkLabel - label236 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 5 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - given + GtkButton + spouseNewPerson + True + True True - True - activate - on_given_activate + clicked + on_new_spouse_clicked spouseDialog - Sat, 22 Sep 2001 04:20:27 GMT + Thu, 23 Aug 2001 21:21:10 GMT - True - True - 0 - - - 1 - 2 - 0 - 1 - 5 - 5 - True - False - False - False - True - False - - - - - GtkCombo - surname_combo - 5 - False - True - False - True - False - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - surname - True - - insert_text - on_combo_insert_text - surname_combo - Tue, 30 Oct 2001 09:51:42 GMT - - True - True - 0 - - + + GTK_RELIEF_NORMAL @@ -4974,7 +4853,7 @@ GTK_WIN_POS_NONE False False - False + True False False False @@ -5072,16 +4951,156 @@ hseparator15 5 - True + False True - GtkHBox - hbox6 - False - 0 + GtkFrame + flabel + 5 + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkVBox + vbox51 + False + 0 + + + GtkCList + fatherList + 3 + 400 + 100 + True + + select_row + on_fatherList_select_row + + 2 + 198,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + 0 + True + True + + + + GtkLabel + CList:title + label81 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label82 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkHBox + hbox24 + 3 + False + 0 + + 0 + True + True + + + + GtkLabel + label223 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 5 + 0 + + 5 + False + False + + + + + GtkCombo + frel_combo + True + False + True + True + False + Birth +Adopted +Stepchild +Foster +None +Unknown + + + 5 + True + True + + + + GtkEntry + GtkCombo:entry + frel + True + + insert_text + on_combo_insert_text + frel_combo + + True + True + 0 + Birth + + + + + + + + GtkFrame + mlabel + 5 + + 0 + GTK_SHADOW_ETCHED_IN 10 True @@ -5089,37 +5108,143 @@ - GtkLabel - flabel - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 0 - - 5 - False - True - - + GtkVBox + vbox52 + False + 0 - - GtkEntry - fatherName - True - True - False - True - 0 - - - 0 - True - True - + + GtkCList + motherList + 3 + 100 + True + + select_row + on_motherList_select_row + + 2 + 198,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + 0 + True + True + + + + GtkLabel + CList:title + label84 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label85 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkHBox + hbox16 + 3 + False + 0 + + 0 + True + True + + + + GtkLabel + label186 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 5 + 0 + + 5 + False + False + + + + + GtkCombo + mrel_combo + True + False + True + True + False + Birth +Adopted +Stepchild +Foster +None +Unknown + + + 5 + True + True + + + + GtkEntry + GtkCombo:entry + mrel + True + + insert_text + on_combo_insert_text + mrel_combo + + True + True + 0 + + + + + + + + GtkHButtonBox + hbuttonbox29 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + False + True + GtkButton @@ -5127,336 +5252,12 @@ True clicked - on_addfather_clicked + on_add_parent_clicked prel - Thu, 27 Sep 2001 23:08:17 GMT + Tue, 26 Mar 2002 14:41:53 GMT - + GTK_RELIEF_NORMAL - - 5 - False - False - - - - - - GtkScrolledWindow - scrolledwindow11 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - fatherList - 400 - 100 - True - - select_row - on_fatherList_select_row - - 2 - 198,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - GtkLabel - CList:title - label81 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - CList:title - label82 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkHBox - hbox24 - False - 0 - - 8 - False - False - - - - GtkLabel - label223 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 5 - 0 - - 5 - False - False - - - - - GtkCombo - frel_combo - True - False - True - True - False - Birth -Adopted -Stepchild -Foster -None -Unknown - - - 5 - True - True - - - - GtkEntry - GtkCombo:entry - frel - True - - insert_text - on_combo_insert_text - frel_combo - - True - True - 0 - Birth - - - - - - GtkHSeparator - hseparator17 - - 10 - True - True - - - - - GtkHBox - hbox7 - False - 0 - - 10 - True - True - - - - GtkLabel - mlabel - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 5 - 0 - - 5 - False - True - - - - - GtkEntry - motherName - True - False - True - 0 - - - 0 - True - True - - - - - GtkButton - button124 - True - - clicked - on_addmother_clicked - prel - - - GTK_RELIEF_NORMAL - - 5 - False - False - - - - - - GtkScrolledWindow - scrolledwindow12 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - motherList - 100 - True - - select_row - on_motherList_select_row - - 2 - 198,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - GtkLabel - CList:title - label84 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - CList:title - label85 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkHBox - hbox16 - False - 0 - - 8 - True - True - - - - GtkLabel - label186 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 5 - 0 - - 5 - False - False - - - - - GtkCombo - mrel_combo - True - False - True - True - False - Birth -Adopted -Stepchild -Foster -None -Unknown - - - 5 - True - True - - - - GtkEntry - GtkCombo:entry - mrel - True - - insert_text - on_combo_insert_text - mrel_combo - - True - True - 0 - - @@ -5465,7 +5266,7 @@ Unknown hseparator19 10 - True + False True @@ -5477,7 +5278,7 @@ Unknown 0 0 - True + False True @@ -7092,7 +6893,7 @@ Unknown GnomeDialog addperson - Edit Person - GRAMPS + Add Person - GRAMPS GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE True diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 5e375b7fa..3fceb4f03 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -89,6 +89,7 @@ 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 @@ -176,7 +177,8 @@ class Gramps: self.qual_label = self.gtop.get_widget("qual") self.child_type = self.gtop.get_widget("childtype") self.spouse_tab = self.gtop.get_widget("lab_or_list") - self.spouse_ptab = self.gtop.get_widget("rel_notebook") + self.pref_spouse = self.gtop.get_widget("pref_spouse") + self.multi_spouse= self.gtop.get_widget("multi_spouse") 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") @@ -211,9 +213,11 @@ class Gramps: self.gtop.signal_autoconnect({ "delete_event" : self.delete_event, "destroy_passed_object" : Utils.destroy_passed_object, - "on_preffam_toggled" : self.on_preferred_fam_toggled, + "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_prefrel_toggled" : self.on_preferred_rel_toggled, "on_about_activate" : self.on_about_activate, "on_add_bookmark_activate" : self.on_add_bookmark_activate, @@ -285,7 +289,6 @@ class Gramps: "on_show_plugin_status" : self.on_show_plugin_status, "on_source_list_button_press_event" : self.source_view.on_button_press_event, "on_sources_activate" : self.on_sources_activate, - "on_spouselist_changed" : self.on_spouselist_changed, "on_swap_clicked" : self.on_swap_clicked, "on_tools_clicked" : self.on_tools_clicked, "on_gramps_home_page_activate" : self.on_gramps_home_page_activate, @@ -1300,18 +1303,12 @@ class Gramps: filter.hide() filter.set_sensitive(obj.get_data("qual")) - def on_spouselist_changed(self,obj): - if self.active_person: - self.display_marriage(obj.get_data("family")) - def on_preferred_rel_toggled(self,obj): - self.spouse_ptab.set_page(1) - self.spouse_pref.set_active(0) self.active_person.setPreferred(self.active_family) + self.load_family(self.active_family) Utils.modified() def on_preferred_fam_toggled(self,obj): - obj.set_active(0) self.active_person.setMainParents(self.active_parents) self.change_parents(self.active_parents) Utils.modified() @@ -1389,7 +1386,6 @@ class Gramps: self.active_family = family if self.active_family: flist = self.active_person.getFamilyList() - if self.active_family: if self.active_person != self.active_family.getFather() and \ self.active_family != self.active_family.getMother(): if len(flist) > 0: @@ -1397,6 +1393,8 @@ class Gramps: else: self.active_family = None + self.spouse_index = 0 + family_types = [] main_family = None @@ -1425,35 +1423,37 @@ class Gramps: flist = self.active_person.getFamilyList() number_of_families = len(flist) if number_of_families > 1: - myMenu = gtk.GtkMenu() - index = 0 - opt_index = 0 - for f in flist: - person = None - if f.getMother() == self.active_person: - if f.getFather() != None: - person = f.getFather() - else: - if f.getMother() != None: - person = f.getMother() + 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 - menuitem = gtk.GtkMenuItem(GrampsCfg.nameof(person)) - myMenu.append(menuitem) - menuitem.set_data("person",person) - menuitem.set_data("family",f) - menuitem.connect("activate",self.on_spouselist_changed) - menuitem.show() - if family and f == family: - opt_index = index - index = index + 1 - self.spouse_menu.set_menu(myMenu) - self.spouse_menu.set_history(opt_index) - self.spouse_tab.set_page(1) - self.spouse_pref.set_active(0) + self.pref_spouse.show() + self.multi_spouse.show() + if self.active_family == flist[0]: + self.pref_spouse.set_sensitive(0) + msg = _("Preferred Relationship (%d of %d)") % (self.spouse_index+1, + len(flist)) + else: + msg = _("Relationship (%d of %d)") % (self.spouse_index+1, + len(flist)) + self.pref_spouse.set_sensitive(1) + + self.gtop.get_widget('rel_frame').set_label(msg) + if self.active_person != self.active_family.getFather(): + spouse = self.active_family.getFather() + else: + spouse = self.active_family.getMother() + + 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.spouse_tab.set_page(0) + self.pref_spouse.hide() + self.multi_spouse.hide() f = self.active_person.getFamilyList()[0] if self.active_person != f.getFather(): spouse = f.getFather() @@ -1461,18 +1461,17 @@ class Gramps: spouse = f.getMother() self.active_spouse = spouse self.spouse_text.set_text(GrampsCfg.nameof(spouse)) - self.spouse_text.set_data("person",spouse) - self.spouse_text.set_data("family",self.active_person.getFamilyList()[0]) self.spouse_edit.set_sensitive(1) self.spouse_del.set_sensitive(1) + self.gtop.get_widget('rel_frame').set_label(_("Relationship")) else: - self.spouse_tab.set_page(0) + self.pref_spouse.hide() + self.multi_spouse.hide() self.spouse_text.set_text("") - self.spouse_text.set_data("person",None) - self.spouse_text.set_data("family",None) self.active_spouse = None self.spouse_edit.set_sensitive(0) self.spouse_del.set_sensitive(0) + self.gtop.get_widget('rel_frame').set_label(_("No Relationship")) if number_of_families > 0: if family: @@ -1577,15 +1576,6 @@ class Gramps: if family: flist = self.active_person.getFamilyList() - if len(flist) <= 1: - self.spouse_ptab.hide() - else: - if family == flist[0]: - self.spouse_ptab.set_page(1) - else: - self.spouse_ptab.set_page(0) - self.spouse_ptab.show() - if self.active_person.getGender() == Person.male: self.active_spouse = family.getMother() else: @@ -1855,6 +1845,28 @@ class Gramps: self.active_parents = flist[self.parents_index][0] self.change_parents(self.active_parents) + def spouse_up_clicked(self,obj): + if self.active_family == None: + return + flist = self.active_person.getFamilyList() + if self.spouse_index == 0: + self.spouse_index = len(flist)-1 + else: + self.spouse_index = self.spouse_index - 1 + self.active_family = flist[self.spouse_index] + self.load_family() + + 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 + else: + self.spouse_index = self.spouse_index + 1 + self.active_family = flist[self.spouse_index] + self.load_family() + def export_callback(self,obj,plugin_function): """Call the export plugin, with the active person and database""" if self.active_person: