* src/Makefile.am: remove PeopleView.py

* src/PeopleView.py: removed, replaced by PersonView
* src/PersonView.py: set ellipsize property
* src/GrampsDb/_ReadGedcom.py: fix event handling


svn: r5820
This commit is contained in:
Don Allingham 2006-01-23 01:27:46 +00:00
parent be7aec6ea5
commit 5a04ba7350
6 changed files with 124 additions and 478 deletions

View File

@ -1,3 +1,9 @@
2006-01-22 Don Allingham <don@gramps-project.org>
* src/Makefile.am: remove PeopleView.py
* src/PeopleView.py: removed, replaced by PersonView
* src/PersonView.py: set ellipsize property
* src/GrampsDb/_ReadGedcom.py: fix event handling
2006-01-21 Don Allingham <don@gramps-project.org>
* src/PeopleModel.py: fix sorting of subnames
* src/Utils.py: fix GEDCOM mappings

View File

@ -680,7 +680,8 @@
2 CALN
3 MEDI Book
0 @S1601@ SOUR
1 TITL Birth Records
1 TITL Birth Record
2 CONC s
1 REPO
2 CALN
3 MEDI Book

View File

@ -129,6 +129,8 @@ for _val in Utils.familyConstantEvents.keys():
if _key != "":
ged2fam[_key] = _val
ged2fam_custom = {}
#-------------------------------------------------------------------------
#
# regular expressions
@ -274,7 +276,7 @@ class NoteParser:
f = open(filename,"rU")
innote = False
for line in f.xreadlines():
for line in f:
self.count += 1
if innote:
@ -449,7 +451,7 @@ class GedcomParser:
mypaths = []
f = open("/proc/mounts","r")
for line in f.xreadlines():
for line in f:
paths = line.split()
ftype = paths[2].upper()
if ftype in file_systems.keys():
@ -492,7 +494,60 @@ class GedcomParser:
else:
return (0,tries)
def track_lines(self):
self.current += 1
newval = int((100*self.current)/self.maxlines)
if self.callback and newval != self.oldval:
self.callback(newval)
self.oldval = newval
def get_next(self):
if self.backoff == 0:
next_line = self.f.readline()
self.track_lines()
# EOF ?
if next_line == "":
self.index += 1
self.text = "";
self.backoff = 0
msg = _("Warning: Premature end of file at line %d.\n") % self.index
self.errmsg(msg)
self.error_count = self.error_count + 1
self.groups = (-1, "END OF FILE", "","")
return self.groups
try:
self.text = string.translate(next_line.strip(),self.transtable,self.delc)
except:
self.text = next_line.strip()
try:
self.text = self.cnv(self.text)
except:
self.text = string.translate(self.text,self.transtable2)
self.index += 1
l = whitespaceRegexp.split(self.text, 2)
ln = len(l)
try:
if ln == 2:
self.groups = (int(l[0]),tokens.get(l[1],TOKEN_UNKNOWN),u"",unicode(l[1]))
else:
self.groups = (int(l[0]),tokens.get(l[1],TOKEN_UNKNOWN),unicode(l[2]),unicode(l[1]))
except:
if self.text == "":
msg = _("Warning: line %d was blank, so it was ignored.\n") % self.index
else:
msg = _("Warning: line %d was not understood, so it was ignored.") % self.index
msg = "%s\n\t%s\n" % (msg,self.text)
self.errmsg(msg)
self.error_count = self.error_count + 1
self.groups = (999, TOKEN_UNKNOWN, "XXX", "")
self.backoff = 0
return self.groups
def get_next_original(self):
if self.backoff == 0:
next_line = self.f.readline()
self.current += 1
@ -962,13 +1017,15 @@ class GedcomParser:
else:
event = RelLib.Event()
try:
print matches[1]
print ged2fam[matches[1]]
event.set_name(ged2fam[matches[1]])
event.set_type((ged2fam[matches[3]],''))
except:
event.set_name(matches[1])
val = ged2fam_custom.has_key(matches[3])
if val:
event.set_type((RelLib.Event.CUSTOM,val))
else:
event.set_type((RelLib.Event.CUSTOM,matches[1]))
if event.get_type()[0] == RelLib.Event.MARRIAGE:
self.family.set_relationship(RelLib.Family.MARRIED)
self.family.set_relationship((RelLib.Family.MARRIED,''))
self.parse_family_event(event,2)
self.db.add_event(event,self.trans)
@ -1011,7 +1068,7 @@ class GedcomParser:
if int(matches[0]) < 1:
self.backup()
if state.get_text():
self.person.set_note(state.get_text())
state.person.set_note(state.get_text())
return
else:
func = self.person_func.get(matches[1],self.func_person_event)
@ -1035,8 +1092,8 @@ class GedcomParser:
self.barf(level+1)
return None
def parse_famc_type(self,level):
ftype = RelLib.Person.CHILD_BIRTH
def parse_famc_type(self,level,person):
ftype = (RelLib.Person.CHILD_BIRTH,'')
note = ""
while 1:
matches = self.get_next()
@ -1048,7 +1105,7 @@ class GedcomParser:
ftype = pedi_type.get(matches[2],RelLib.Person.UNKNOWN)
elif matches[1] == TOKEN_SOUR:
source_ref = self.handle_source(matches,level+1)
self.person.get_primary_name().add_source_reference(source_ref)
person.get_primary_name().add_source_reference(source_ref)
elif matches[1] == TOKEN__PRIMARY:
pass #type = matches[1]
elif matches[1] == TOKEN_NOTE:
@ -1061,7 +1118,7 @@ class GedcomParser:
self.barf(level+1)
return None
def parse_person_object(self,level):
def parse_person_object(self,level,state):
form = ""
filename = ""
title = "no title"
@ -1088,7 +1145,7 @@ class GedcomParser:
url = RelLib.Url()
url.set_path(filename)
url.set_description(title)
self.person.add_url(url)
state.person.add_url(url)
else:
(ok,path) = self.find_file(filename,self.dir_path)
if not ok:
@ -1110,8 +1167,7 @@ class GedcomParser:
oref = RelLib.MediaRef()
oref.set_reference_handle(photo.get_handle())
oref.set_note(note)
self.person.add_media_reference(oref)
#self.db.commit_person(self.person, self.trans)
state.person.add_media_reference(oref)
def parse_family_object(self,level):
form = ""
@ -1156,7 +1212,6 @@ class GedcomParser:
oref.set_reference_handle(photo.get_handle())
oref.set_note(note)
self.family.add_media_reference(oref)
#self.db.commit_family(self.family, self.trans)
def parse_residence(self,address,level):
note = ""
@ -1459,11 +1514,12 @@ class GedcomParser:
self.backup()
break
elif matches[1] == TOKEN_TYPE:
if event.get_name() == "" or event.get_name() == 'EVEN':
etype = event.get_type()
if etype[0] == RelLib.Event.CUSTOM:
try:
event.set_name(ged2fam[matches[2]])
event.set_name((ged2fam[matches[2]],''))
except:
event.set_name(matches[2])
event.set_name((RelLib.Event.CUSTOM,matches[2]))
else:
note = 'Status = %s\n' % matches[2]
elif matches[1] == TOKEN_DATE:
@ -1679,7 +1735,7 @@ class GedcomParser:
return
else:
label = self.parse_label(level+1)
ged2fam[matches[1]] = label
ged2fam[matches[3]] = label
return None
def ignore_sub_junk(self,level):
@ -1900,9 +1956,9 @@ class GedcomParser:
if names[4]:
name.set_suffix(names[4].strip())
if state.name_cnt == 0:
self.person.set_primary_name(name)
state.person.set_primary_name(name)
else:
self.person.add_alternate_name(name)
state.person.add_alternate_name(name)
state.name_cnt += 1
self.parse_name(name,2,state)
@ -1918,49 +1974,49 @@ class GedcomParser:
aka.set_surname(names[2])
if names[4]:
aka.set_suffix(names[4])
self.person.add_alternate_name(aka)
state.person.add_alternate_name(aka)
def func_person_object(self,matches,state):
if matches[2] and matches[2][0] == '@':
self.barf(2)
else:
self.parse_person_object(2)
self.parse_person_object(2,state)
def func_person_note(self,matches,state):
self.note = self.parse_note(matches,self.person,1,state)#self.note)
def func_person_sex(self,matches,state):
if matches[2] == '':
self.person.set_gender(RelLib.Person.UNKNOWN)
state.person.set_gender(RelLib.Person.UNKNOWN)
elif matches[2][0] == "M":
self.person.set_gender(RelLib.Person.MALE)
state.person.set_gender(RelLib.Person.MALE)
elif matches[2][0] == "F":
self.person.set_gender(RelLib.Person.FEMALE)
state.person.set_gender(RelLib.Person.FEMALE)
else:
self.person.set_gender(RelLib.Person.UNKNOWN)
state.person.set_gender(RelLib.Person.UNKNOWN)
def func_person_bapl(self,matches,state):
lds_ord = RelLib.LdsOrd()
self.person.set_lds_baptism(lds_ord)
state.person.set_lds_baptism(lds_ord)
self.parse_ord(lds_ord,2)
def func_person_endl(self,matches,state):
lds_ord = RelLib.LdsOrd()
self.person.set_lds_endowment(lds_ord)
state.person.set_lds_endowment(lds_ord)
self.parse_ord(lds_ord,2)
def func_person_slgc(self,matches,state):
lds_ord = RelLib.LdsOrd()
self.person.set_lds_sealing(lds_ord)
state.person.set_lds_sealing(lds_ord)
self.parse_ord(lds_ord,2)
def func_person_fams(self,matches,state):
handle = self.find_family_handle(matches[2][1:-1])
self.person.add_family_handle(handle)
state.person.add_family_handle(handle)
state.add_to_note(self.parse_optional_note(2))
def func_person_famc(self,matches,state):
ftype,note = self.parse_famc_type(2)
ftype,note = self.parse_famc_type(2,state.person)
handle = self.find_family_handle(matches[2][1:-1])
for f in self.person.get_parent_family_handle_list():
@ -1968,29 +2024,30 @@ class GedcomParser:
break
else:
if ftype in rel_types:
self.person.add_parent_family_handle(
handle, RelLib.Person.CHILD_BIRTH, RelLib.Person.CHILD_BIRTH)
state.person.add_parent_family_handle(
handle, (RelLib.Person.CHILD_BIRTH,''),
(RelLib.Person.CHILD_BIRTH,''))
else:
if self.person.get_main_parents_family_handle() == handle:
self.person.set_main_parent_family_handle(None)
self.person.add_parent_family_handle(handle,ftype,ftype)
if state.person.get_main_parents_family_handle() == handle:
state.person.set_main_parent_family_handle(None)
state.person.add_parent_family_handle((handle,ftype,ftype))
def func_person_resi(self,matches,state):
addr = RelLib.Address()
self.person.add_address(addr)
state.person.add_address(addr)
self.parse_residence(addr,2)
def func_person_addr(self,matches,state):
addr = RelLib.Address()
addr.set_street(matches[2] + self.parse_continue_data(1))
self.parse_address(addr,2)
self.person.add_address(addr)
state.person.add_address(addr)
def func_person_phon(self,matches,state):
addr = RelLib.Address()
addr.set_street("Unknown")
addr.set_phone(matches[2])
self.person.add_address(addr)
state.person.add_address(addr)
def func_person_birt(self,matches,state):
event = RelLib.Event()
@ -2005,10 +2062,10 @@ class GedcomParser:
event_ref.set_reference_handle(event.handle)
event_ref.set_role((RelLib.EventRef.PRIMARY,''))
if self.person.get_birth_ref():
self.person.add_event_ref(event_ref)
if state.person.get_birth_ref():
state.person.add_event_ref(event_ref)
else:
self.person.set_birth_ref(event_ref)
state.person.set_birth_ref(event_ref)
def func_person_adop(self,matches,state):
event = RelLib.Event()
@ -2019,7 +2076,7 @@ class GedcomParser:
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event.handle)
event_ref.set_rol((RelLib.EventRef.PRIMARY,''))
self.person.add_event_ref(event_ref)
state.person.add_event_ref(event_ref)
def func_person_deat(self,matches,state):
event = RelLib.Event()
@ -2034,32 +2091,32 @@ class GedcomParser:
event_ref.set_reference_handle(event.handle)
event_ref.set_role((RelLib.EventRef.PRIMARY,''))
if self.person.get_death_ref():
self.person.add_event_ref(event_ref)
if state.person.get_death_ref():
state.person.add_event_ref(event_ref)
else:
self.person.set_death_ref(event_ref)
state.person.set_death_ref(event_ref)
def func_person_even(self,matches,state):
event = RelLib.Event()
if matches[2]:
event.set_description(matches[2])
self.parse_person_event(event,2)
n = event.get_name().strip()
if n in self.attrs:
(t,n) = event.get_type()
if t == RelLib.Event.CUSTOM and n in self.attrs:
attr = RelLib.Attribute()
attr.set_type((self.gedattr[n],''))
attr.set_value(event.get_description())
self.person.add_attribute(attr)
state.person.add_attribute(attr)
else:
self.db.add_event(event, self.trans)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event.handle)
event_ref.set_role((RelLib.EventRef.PRIMARY,''))
self.person.add_event_ref(event_ref)
state.person.add_event_ref(event_ref)
def func_person_sour(self,matches,state):
source_ref = self.handle_source(matches,2)
self.person.add_source_reference(source_ref)
state.person.add_source_reference(source_ref)
def func_person_refn(self,matches,state):
if intRE.match(matches[2]):
@ -2072,7 +2129,7 @@ class GedcomParser:
attr = RelLib.Attribute()
attr.set_type(matches[1])
attr.set_value(matches[2])
self.person.add_attribute(attr)
state.person.add_attribute(attr)
def func_person_event(self,matches,state):
n = matches[3].strip()
@ -2080,7 +2137,7 @@ class GedcomParser:
attr = RelLib.Attribute()
attr.set_type((self.gedattr[n],''))
attr.set_value(matches[2])
self.person.add_attribute(attr)
state.person.add_attribute(attr)
self.parse_person_attr(attr,2)
return
elif ged2gramps.has_key(n):
@ -2089,7 +2146,6 @@ class GedcomParser:
else:
event = RelLib.Event()
val = self.gedsource.tag2gramps(n)
print n, val
if val:
event.set_type((RelLib.Event.CUSTOM,val))
else:
@ -2103,7 +2159,7 @@ class GedcomParser:
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event.get_handle())
event_ref.set_role((RelLib.EventRef.PRIMARY,''))
self.person.add_event_ref(event_ref)
state.person.add_event_ref(event_ref)
#-------------------------------------------------------------------------
#

View File

@ -74,7 +74,7 @@ gdir_PYTHON = \
NoteEdit.py\
PaperMenu.py\
PedView.py\
PeopleView.py\
PersonView.py\
PeopleModel.py\
PlaceView.py\
Plugins.py\

View File

@ -1,419 +0,0 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2003 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
#
# $Id$
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
import cPickle as pickle
#-------------------------------------------------------------------------
#
# internationalization
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# gtk
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
#-------------------------------------------------------------------------
#
# gtk
#
#-------------------------------------------------------------------------
import PeopleModel
import GenericFilter
import NameDisplay
from DdTargets import DdTargets
column_names = [
_('Name'),
_('ID') ,
_('Gender'),
_('Birth Date'),
_('Birth Place'),
_('Death Date'),
_('Death Place'),
_('Spouse'),
_('Last Change'),
_('Cause of death'),
]
#-------------------------------------------------------------------------
#
# PeopleView
#
#-------------------------------------------------------------------------
class PeopleView:
def __init__(self,parent):
self.parent = parent
self.parent.connect('database-changed',self.change_db)
self.parent.connect('active-changed',self.change_db)
all = GenericFilter.GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(GenericFilter.Everyone([]))
self.DataFilter = None
self.pscroll = self.parent.gtop.get_widget("pscroll")
self.person_tree = self.parent.gtop.get_widget("person_tree")
self.person_tree.set_rules_hint(True)
self.renderer = gtk.CellRendererText()
self.inactive = False
self.columns = []
self.build_columns()
self.person_selection = self.person_tree.get_selection()
self.person_selection.set_mode(gtk.SELECTION_MULTIPLE)
self.person_selection.connect('changed',self.row_changed)
self.person_tree.connect('row_activated', self.alpha_event)
self.person_tree.connect('button-press-event',
self.on_plist_button_press)
#
# DnD support
#
self.person_tree.connect('drag_data_get', self.person_drag_data_get)
def person_drag_data_get(self, widget, context, sel_data, info, time):
selected_ids = self.get_selected_objects()
if len(selected_ids) == 1:
sel_data.set(sel_data.target, 8, selected_ids[0])
elif len(selected_ids) > 1:
sel_data.set(DdTargets.PERSON_LINK_LIST.drag_type,8,
pickle.dumps(selected_ids))
def set_dnd_target(self,obj):
selected_ids = self.get_selected_objects()
if len(selected_ids) == 1:
self.person_tree.drag_source_set(
BUTTON1_MASK, [DdTargets.PERSON_LINK.target()], ACTION_COPY)
elif len(selected_ids) > 1:
self.person_tree.drag_source_set(
BUTTON1_MASK, [DdTargets.PERSON_LINK_LIST.target()], ACTION_COPY)
def sort_clicked(self,obj):
for col in self.columns:
if obj == col:
if col.get_sort_indicator():
if col.get_sort_order() == gtk.SORT_ASCENDING:
col.set_sort_order(gtk.SORT_DESCENDING)
else:
col.set_sort_order(gtk.SORT_ASCENDING)
else:
col.set_sort_order(gtk.SORT_ASCENDING)
col.set_sort_indicator(True)
else:
col.set_sort_indicator(False)
def build_columns(self):
for column in self.columns:
self.person_tree.remove_column(column)
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
column.set_resizable(True)
column.set_min_width(225)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
self.person_tree.append_column(column)
self.columns = [column]
index = 1
for pair in self.parent.db.get_person_column_order():
if not pair[0]:
continue
name = column_names[pair[1]]
column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1])
column.set_resizable(True)
column.set_min_width(60)
column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
self.columns.append(column)
self.person_tree.append_column(column)
index += 1
def build_tree(self):
self.person_model = PeopleModel.PeopleModel(
self.parent.db,self.DataFilter,
self.parent.filter_invert.get_active())
self.person_tree.set_model(self.person_model)
def get_selected_objects(self):
(mode,paths) = self.person_selection.get_selected_rows()
mlist = []
for path in paths:
node = self.person_model.on_get_iter(path)
mlist.append(self.person_model.on_get_value(node, PeopleModel.COLUMN_INT_ID))
return mlist
def row_changed(self,obj):
"""Called with a row is changed. Check the selected objects from
the person_tree to get the IDs of the selected objects. Set the
active person to the first person in the list. If no one is
selected, set the active person to None"""
selected_ids = self.get_selected_objects()
try:
person = self.parent.db.get_person_from_handle(selected_ids[0])
self.parent.change_active_person(person)
except:
self.parent.change_active_person(None)
if len(selected_ids) == 1:
self.person_tree.drag_source_set(BUTTON1_MASK,
[DdTargets.PERSON_LINK.target()],
ACTION_COPY)
elif len(selected_ids) > 1:
self.person_tree.drag_source_set(BUTTON1_MASK,
[DdTargets.PERSON_LINK_LIST.target()],
ACTION_COPY)
def change_db(self,db):
self.build_columns()
db.connect('person-add', self.person_added)
db.connect('person-update', self.person_updated)
db.connect('person-delete', self.person_removed)
db.connect('person-rebuild', self.redisplay_person_list)
self.apply_filter()
def remove_from_person_list(self,person):
"""Remove the selected person from the list. A person object is
expected, not an ID"""
path = self.person_model.on_get_path(person.get_handle())
#self.person_model.row_deleted(path)
(col,row) = path
if row > 0:
self.person_selection.select_path((col,row-1))
elif row == 0 and self.person_model.on_get_iter(path):
self.person_selection.select_path(path)
def remove_from_history(self,person_handle,old_id=None):
"""Removes a person from the history list"""
if old_id:
del_id = old_id
else:
del_id = person_handle
hc = self.parent.history.count(del_id)
for c in range(hc):
self.parent.history.remove(del_id)
self.parent.hindex -= 1
mhc = self.parent.mhistory.count(del_id)
for c in range(mhc):
self.parent.mhistory.remove(del_id)
def apply_filter_clicked(self):
index = self.parent.filter_list.get_active()
self.DataFilter = self.parent.filter_model.get_filter(index)
if self.DataFilter.need_param:
qual = unicode(self.parent.filter_text.get_text())
self.DataFilter.set_parameter(qual)
self.apply_filter()
self.goto_active_person()
def goto_active_person(self,obj=None):
if not self.state.active or self.inactive:
return
self.inactive = True
p = self.state.active
try:
path = self.person_model.on_get_path(p.get_handle())
group_name = NameDisplay.displayer.name_grouping(self.state.db,p)
top_name = self.state.db.get_name_group_mapping(group_name)
top_path = self.person_model.on_get_path(top_name)
self.person_tree.expand_row(top_path,0)
current = self.person_model.on_get_iter(path)
selected = self.person_selection.path_is_selected(path)
if current != p.get_handle() or not selected:
self.person_selection.unselect_all()
self.person_selection.select_path(path)
self.person_tree.scroll_to_cell(path,None,1,0.5,0)
except KeyError:
self.person_selection.unselect_all()
print "Person not currently available due to filter"
self.state.active = p
self.inactive = False
def alpha_event(self,*obj):
self.parent.load_person(self.parent.active_person)
def apply_filter(self,current_model=None):
self.parent.status_text(_('Updating display...'))
self.build_tree()
self.parent.modify_statusbar()
def on_plist_button_press(self,obj,event):
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
self.build_people_context_menu(event)
def build_people_context_menu(self,event):
"""Builds the menu with navigation and
editing operations on the people's list"""
back_sensitivity = self.parent.hindex > 0
fwd_sensitivity = self.parent.hindex + 1 < len(self.parent.history)
mlist = self.get_selected_objects()
if mlist:
sel_sensitivity = True
else:
sel_sensitivity = False
merge_sensitivity = len(mlist) == 2
entries = [
(gtk.STOCK_GO_BACK,self.parent.back_clicked,back_sensitivity),
(gtk.STOCK_GO_FORWARD,self.parent.fwd_clicked,fwd_sensitivity),
(_("Home"),self.parent.on_home_clicked,1),
(_("Add Bookmark"),self.parent.on_add_bookmark_activate,sel_sensitivity),
(None,None,0),
(gtk.STOCK_ADD, self.parent.add_button_clicked,1),
(gtk.STOCK_REMOVE, self.parent.remove_button_clicked,sel_sensitivity),
(_("Edit"), self.parent.edit_button_clicked,sel_sensitivity),
#(None,None,0),
#(_("Compare and Merge"), self.parent.on_merge_activate,
# merge_sensitivity),
#(_("Fast Merge"), self.parent.on_fast_merge_activate,
# merge_sensitivity),
]
menu = gtk.Menu()
menu.set_title(_('People Menu'))
for stock_id,callback,sensitivity in entries:
item = gtk.ImageMenuItem(stock_id)
#FIXME: remove when German gtk translation is fixed
if stock_id == _("Home"):
im = gtk.image_new_from_stock(gtk.STOCK_HOME,gtk.ICON_SIZE_MENU)
im.show()
item.set_image(im)
if callback:
item.connect("activate",callback)
item.set_sensitive(sensitivity)
item.show()
menu.append(item)
menu.popup(None,None,None,event.button,event.time)
def redisplay_person_list(self):
self.build_tree()
def person_added(self,handle_list):
for node in handle_list:
person = self.parent.db.get_person_from_handle(node)
top = NameDisplay.displayer.name_grouping(self.parent.db,person)
self.person_model.rebuild_data(self.DataFilter)
if not self.person_model.is_visable(node):
continue
if (not self.person_model.sname_sub.has_key(top) or
len(self.person_model.sname_sub[top]) == 1):
path = self.person_model.on_get_path(top)
pnode = self.person_model.get_iter(path)
self.person_model.row_inserted(path,pnode)
path = self.person_model.on_get_path(node)
pnode = self.person_model.get_iter(path)
self.person_model.row_inserted(path,pnode)
def person_removed(self,handle_list):
for node in handle_list:
person = self.parent.db.get_person_from_handle(node)
if not self.person_model.is_visable(node):
continue
top = NameDisplay.displayer.name_grouping(self.parent.db,person)
mylist = self.person_model.sname_sub.get(top,[])
if mylist:
try:
path = self.person_model.on_get_path(node)
self.person_model.row_deleted(path)
if len(mylist) == 1:
path = self.person_model.on_get_path(top)
self.person_model.row_deleted(path)
except KeyError:
pass
self.person_model.rebuild_data(self.DataFilter,skip=node)
def person_updated(self,handle_list):
for node in handle_list:
person = self.parent.db.get_person_from_handle(node)
try:
oldpath = self.person_model.iter2path[node]
except:
return
pathval = self.person_model.on_get_path(node)
pnode = self.person_model.get_iter(pathval)
# calculate the new data
surname = NameDisplay.displayer.name_grouping(self.parent.db,person)
if oldpath[0] == surname:
self.person_model.build_sub_entry(surname)
else:
self.person_model.calculate_data(self.DataFilter)
# find the path of the person in the new data build
newpath = self.person_model.temp_iter2path[node]
# if paths same, just issue row changed signal
if oldpath == newpath:
self.person_model.row_changed(pathval,pnode)
else:
# paths different, get the new surname list
mylist = self.person_model.temp_sname_sub.get(oldpath[0],[])
path = self.person_model.on_get_path(node)
# delete original
self.person_model.row_deleted(pathval)
# delete top node of original if necessar
if len(mylist)==0:
self.person_model.row_deleted(pathval[0])
# determine if we need to insert a new top node',
insert = not self.person_model.sname_sub.has_key(newpath[0])
# assign new data
self.person_model.assign_data()
# insert new row if needed
if insert:
path = self.person_model.on_get_path(newpath[0])
pnode = self.person_model.get_iter(path)
self.person_model.row_inserted(path,pnode)
# insert new person
path = self.person_model.on_get_path(node)
pnode = self.person_model.get_iter(path)
self.person_model.row_inserted(path,pnode)
self.goto_active_person()

View File

@ -35,6 +35,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import gtk
import pango
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
#-------------------------------------------------------------------------
@ -145,6 +146,7 @@ class PersonView(PageView.PersonNavView):
self.vbox.pack_start(scrollwindow,True)
self.renderer = gtk.CellRendererText()
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
self.inactive = False
self.columns = []