Shift-click to edit spouse, re-implemented family name guessing

svn: r1537
This commit is contained in:
Don Allingham 2003-05-18 04:18:12 +00:00
parent fc1daf4b66
commit b2be35af0a
7 changed files with 130 additions and 28 deletions

3
NEWS
View File

@ -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).

View File

@ -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:

View File

@ -91,6 +91,7 @@ class DispBox:
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,
@ -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)

View File

@ -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)

View File

@ -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 ""

View File

@ -1802,7 +1802,7 @@
<child>
<widget class="GtkLabel" id="label361">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Spouse&lt;/b&gt;</property>
<property name="label" translatable="yes">&lt;b&gt;Relationship&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -1949,7 +1949,7 @@
<child>
<widget class="GtkTreeView" id="sp_list">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Double-click to edit the relationship information</property>
<property name="tooltip" translatable="yes">Double-click to edit the relationship information, Shift-click to edit the person</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
@ -4033,7 +4033,7 @@
<child>
<widget class="GtkTreeView" id="childlist">
<property name="width_request">320</property>
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>

View File

@ -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)