From 76f10e127d211f8432fe5c7bb63cf96adfea5d5d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 18 May 2003 04:18:12 +0000 Subject: [PATCH] Shift-click to edit spouse, re-implemented family name guessing svn: r1537 --- gramps2/NEWS | 3 ++ gramps2/src/FamilyView.py | 16 +++++--- gramps2/src/PedView.py | 17 ++++---- gramps2/src/QuickAdd.py | 32 +++++++++++---- gramps2/src/SelectChild.py | 80 +++++++++++++++++++++++++++++++++++++- gramps2/src/gramps.glade | 6 +-- gramps2/src/gramps_main.py | 4 +- 7 files changed, 130 insertions(+), 28 deletions(-) diff --git a/gramps2/NEWS b/gramps2/NEWS index 20f6b9ab2..316a6c46c 100644 --- a/gramps2/NEWS +++ b/gramps2/NEWS @@ -1,5 +1,8 @@ Version 0.9.2 +* Fixed pedigree view problem that prevented display from updating * Fixed duplicate place problem. +* Re-implemented family name guessing +* Better error handling with reports * Language-specific relationship calculation framework. Volunteers needed to create language-specific plugins. * New Family Tree Maker style reports (Ancestor and Descendant). diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 1b36e7421..7048e8355 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -159,7 +159,11 @@ class FamilyView: self.display_marriage(self.person.getFamilyList()[row[0]]) def edit_relationship(self,obj,event): - if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: + if event.state & gtk.gdk.SHIFT_MASK and \ + event.type == gtk.gdk.BUTTON_PRESS and \ + event.button == 1 and self.selected_spouse: + self.parent.load_person(self.selected_spouse) + elif event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: if self.person: try: if self.selected_spouse: @@ -342,11 +346,11 @@ class FamilyView: first_spouse = sp first_family = f - if len(splist) > 1: - self.spouse_selection.set_mode(gtk.SELECTION_SINGLE) - self.spouse_selection.select_iter(iter) - else: - self.spouse_selection.set_mode(gtk.SELECTION_NONE) + if len(splist) > 1: + self.spouse_selection.set_mode(gtk.SELECTION_SINGLE) + self.spouse_selection.select_iter(iter) + else: + self.spouse_selection.set_mode(gtk.SELECTION_NONE) if sp: if f.getMarriage(): diff --git a/gramps2/src/PedView.py b/gramps2/src/PedView.py index c368a2115..83b28140a 100644 --- a/gramps2/src/PedView.py +++ b/gramps2/src/PedView.py @@ -87,11 +87,12 @@ class DispBox: self.group.set_data('p',person) def cleanup(self): - self.shadow.destroy() - self.bkgnd.destroy() - self.textbox.destroy() - self.group.destroy() - + self.shadow.destroy() + self.bkgnd.destroy() + self.textbox.destroy() + self.group.destroy() + return + def group_event(self,obj,event): """Handle events over a drawn box. Doubleclick would edit, shift doubleclick would change the active person, entering @@ -99,7 +100,7 @@ class DispBox: box returns it to the original size and information""" if event.type == gtk.gdk._2BUTTON_PRESS: - return 1 + return 1 elif event.type == gtk.gdk.ENTER_NOTIFY: self.expand() return 0 @@ -110,14 +111,12 @@ class DispBox: def expand(self): """Expand a box to include additional information""" - self.group.raise_to_top() self.textbox.set(text=self.exp) self.bkgnd.set(y1=-self.h,y2=self.h*2) self.shadow.set(y1=-self.h+_PAD,y2=self.h*2+_PAD) - + def shrink(self): """Expand a box to include additional information""" - self.group.raise_to_top() self.textbox.set(text=self.name) self.bkgnd.set(y1=0,y2=self.h) self.shadow.set(y1=_PAD,y2=self.h+_PAD) diff --git a/gramps2/src/QuickAdd.py b/gramps2/src/QuickAdd.py index 50dc58989..0b2206f08 100644 --- a/gramps2/src/QuickAdd.py +++ b/gramps2/src/QuickAdd.py @@ -18,17 +18,31 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- import gtk.glade +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- import Utils import AutoComp import const import RelLib from intl import gettext as _ - +#------------------------------------------------------------------------- +# +# QuickAdd +# +#------------------------------------------------------------------------- class QuickAdd: - def __init__(self,db,sex,callback): + def __init__(self,db,sex,callback,default_name = ""): self.db = db self.callback = callback @@ -41,15 +55,19 @@ class QuickAdd: self.window = self.xml.get_widget("addperson") title = self.xml.get_widget('title') + combo = self.xml.get_widget("surnameCombo") + self.surname = self.xml.get_widget("surname") + self.given = self.xml.get_widget("given") Utils.set_titles(self.window,title, _('Add Person')) - self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"), - self.db.getSurnames()) - + self.c = AutoComp.AutoCombo(combo,self.db.getSurnames()) + if default_name: + self.surname.set_text(default_name) + def close(self,obj): - surname = self.xml.get_widget("surname").get_text() - given = self.xml.get_widget("given").get_text() + surname = self.surname.get_text() + given = self.given.get_text() person = RelLib.Person() name = person.getPrimaryName() name.setSurname(surname) diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index 8e0144b38..071003d28 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -41,6 +41,8 @@ import RelLib import const import Utils import ListModel +import GrampsCfg +from RelLib import Person #------------------------------------------------------------------------- # @@ -57,6 +59,11 @@ class SelectChild: self.add_person = add_person self.xml = gtk.glade.XML(const.gladeFile,"select_child") + if person: + self.default_name = person.getPrimaryName().getSurname().upper() + else: + self.default_name = "" + self.xml.signal_autoconnect({ "on_save_child_clicked" : self.on_save_child_clicked, "on_show_toggled" : self.on_show_toggled, @@ -164,10 +171,22 @@ class SelectChild: person_list.append(person.getId()) + iter = None for idval in person_list: dinfo = self.db.getPersonDisplay(idval) rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]] - self.refmodel.add(rdata) + new_iter = self.refmodel.add(rdata) + names = dinfo[0].split(',') + if len(names): + ln = names[0].upper() + if self.default_name and ln == self.default_name and not iter: + iter = new_iter + + if iter: + self.refmodel.selection.select_iter(iter) + path = self.refmodel.model.get_path(iter) + col = self.add_child.get_column(0) + self.add_child.scroll_to_cell(path,col,1,0.5,0.0) def on_save_child_clicked(self,obj): store,iter = self.refmodel.selection.get_selected() @@ -213,7 +232,18 @@ class SelectChild: class to create a new person.""" import QuickAdd - QuickAdd.QuickAdd(self.db,"male",self.add_new_parent) + + autoname = GrampsCfg.lastnamegen + + if autoname == 0: + name = self.north_american(0) + elif autoname == 2: + name = self.latin_american(0) + elif autoname == 3: + name = self.icelandic(0) + else: + name = "" + QuickAdd.QuickAdd(self.db,"male",self.add_new_parent, name) def add_new_parent(self,person): """Adds a new person to either the father list or the mother list, @@ -223,3 +253,49 @@ class SelectChild: rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]] self.refmodel.add_and_select(rdata) self.add_person(person) + + def north_american(self,val): + if self.person.getGender() == Person.male: + return self.person.getPrimaryName().getSurname() + elif self.family: + f = self.family.getFather() + if f: + return f.getPrimaryName().getSurname() + return "" + + def no_name(self,val): + return "" + + def latin_american(self,val): + if self.family: + father = self.family.getFather() + mother = self.family.getMother() + if not father or not mother: + return "" + fsn = father.getPrimaryName().getSurname() + msn = mother.getPrimaryName().getSurname() + if not father or not mother: + return "" + try: + return "%s %s" % (fsn.split()[0],msn.split()[0]) + except: + return "" + else: + return "" + + def icelandic(self,val): + fname = "" + if self.person.getGender() == Person.male: + fname = self.person.getPrimaryName().getFirstName() + elif self.family: + f = self.family.getFather() + if f: + fname = f.getPrimaryName().getFirstName() + if fname: + fname = string.split(fname)[0] + if val == 0: + return "%ssson" % fname + elif val == 1: + return "%sdóttir" % fname + else: + return "" diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 894aa30b4..fb26779f4 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1802,7 +1802,7 @@ True - <b>Spouse</b> + <b>Relationship</b> False True GTK_JUSTIFY_LEFT @@ -1949,7 +1949,7 @@ True - Double-click to edit the relationship information + Double-click to edit the relationship information, Shift-click to edit the person True False True @@ -4033,7 +4033,7 @@ - 320 + 400 True True True diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 905396062..138b748c3 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -1183,7 +1183,7 @@ class Gramps: model.selection.select_iter(iter); itpath = model.model.get_path(iter) col = model.tree.get_column(0) - model.tree.scroll_to_cell(itpath,col,1,0.5,0.0) + model.tree.scroll_to_cell(itpath,col,1,0.5,0) def change_active_person(self,person): if person != self.active_person: @@ -1410,6 +1410,8 @@ class Gramps: self.db.buildPersonDisplay(epo.person.getId()) self.change_active_person(epo.person) self.redisplay_person_list(epo.person) + if self.views.get_current_page() == 1: + self.family_view.load_family() for p in plist: self.place_view.new_place_after_edit(p)