2005-08-09 10:11:20 +05:30
|
|
|
# -*- 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
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
|
|
|
from gettext import gettext as _
|
2006-02-09 02:43:05 +05:30
|
|
|
import cPickle as pickle
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gtk
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
2006-01-23 06:57:46 +05:30
|
|
|
import pango
|
2005-08-09 10:11:20 +05:30
|
|
|
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-11 05:23:24 +05:30
|
|
|
import RelLib
|
2005-08-09 10:11:20 +05:30
|
|
|
import PeopleModel
|
|
|
|
import PageView
|
|
|
|
import GenericFilter
|
|
|
|
import EditPerson
|
|
|
|
import NameDisplay
|
|
|
|
import Utils
|
|
|
|
import QuestionDialog
|
2005-08-19 18:14:44 +05:30
|
|
|
import TreeTips
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
from DdTargets import DdTargets
|
|
|
|
|
|
|
|
column_names = [
|
|
|
|
_('Name'),
|
|
|
|
_('ID') ,
|
|
|
|
_('Gender'),
|
|
|
|
_('Birth Date'),
|
|
|
|
_('Birth Place'),
|
|
|
|
_('Death Date'),
|
|
|
|
_('Death Place'),
|
|
|
|
_('Spouse'),
|
|
|
|
_('Last Change'),
|
|
|
|
_('Cause of Death'),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2005-08-11 22:49:03 +05:30
|
|
|
class PersonView(PageView.PersonNavView):
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2005-08-11 05:23:24 +05:30
|
|
|
def __init__(self,dbstate,uistate):
|
2005-08-11 22:49:03 +05:30
|
|
|
PageView.PersonNavView.__init__(self,'Person View',dbstate,uistate)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.inactive = False
|
2005-08-11 05:23:24 +05:30
|
|
|
dbstate.connect('database-changed',self.change_db)
|
|
|
|
dbstate.connect('active-changed',self.goto_active_person)
|
2006-01-24 09:43:21 +05:30
|
|
|
self.handle_col = PeopleModel.COLUMN_INT_ID
|
2005-08-20 03:40:35 +05:30
|
|
|
|
2005-08-14 10:01:29 +05:30
|
|
|
def change_page(self):
|
2006-01-17 20:41:15 +05:30
|
|
|
self.generic_filter_widget.on_filter_name_changed(None)
|
2005-08-14 10:01:29 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def define_actions(self):
|
2005-08-11 05:23:24 +05:30
|
|
|
"""
|
|
|
|
Required define_actions function for PageView. Builds the action
|
|
|
|
group information required. We extend beyond the normal here,
|
|
|
|
since we want to have more than one action group for the PersonView.
|
|
|
|
Most PageViews really won't care about this.
|
|
|
|
|
|
|
|
Special action groups for Forward and Back are created to allow the
|
|
|
|
handling of navigation buttons. Forward and Back allow the user to
|
|
|
|
advance or retreat throughout the history, and we want to have these
|
|
|
|
be able to toggle these when you are at the end of the history or
|
|
|
|
at the beginning of the history.
|
|
|
|
"""
|
|
|
|
|
2005-08-11 22:49:03 +05:30
|
|
|
PageView.PersonNavView.define_actions(self)
|
|
|
|
|
2005-08-14 10:01:29 +05:30
|
|
|
self.add_action('Add', gtk.STOCK_ADD, "_Add",
|
|
|
|
callback=self.add)
|
|
|
|
self.add_action('Edit', gtk.STOCK_EDIT, "_Edit",
|
|
|
|
callback=self.edit)
|
|
|
|
self.add_action('Remove', gtk.STOCK_REMOVE, "_Remove",
|
|
|
|
callback=self.remove)
|
2006-01-08 10:10:33 +05:30
|
|
|
self.add_action('Jump', None, "_Jump",
|
|
|
|
accel="<control>j",callback=self.jumpto)
|
2005-08-14 10:01:29 +05:30
|
|
|
|
2006-01-06 10:38:51 +05:30
|
|
|
self.add_toggle_action('Filter', None, '_Filter', None, None,
|
|
|
|
self.filter_toggle)
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def get_stock(self):
|
2005-08-11 05:23:24 +05:30
|
|
|
"""
|
|
|
|
Returns the name of the stock icon to use for the display.
|
|
|
|
This assumes that this icon has already been registered with
|
|
|
|
GNOME as a stock icon.
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
return 'gramps-person'
|
|
|
|
|
|
|
|
def build_widget(self):
|
2005-08-11 05:23:24 +05:30
|
|
|
"""
|
|
|
|
Builds the interface and returns a gtk.Container type that
|
|
|
|
contains the interface. This containter will be inserted into
|
|
|
|
a gtk.Notebook page.
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
self.vbox = gtk.VBox()
|
|
|
|
self.vbox.set_border_width(4)
|
|
|
|
self.vbox.set_spacing(4)
|
|
|
|
|
2006-01-17 20:41:15 +05:30
|
|
|
self.generic_filter_widget = GenericFilter.FilterWidget( self.uistate, self.build_tree, self.goto_active_person)
|
|
|
|
filter_box = self.generic_filter_widget.build()
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree = gtk.TreeView()
|
|
|
|
self.tree.set_rules_hint(True)
|
|
|
|
self.tree.set_headers_visible(True)
|
|
|
|
self.tree.connect('key-press-event',self.key_press)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
scrollwindow = gtk.ScrolledWindow()
|
|
|
|
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
scrollwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
2005-08-20 03:40:35 +05:30
|
|
|
scrollwindow.add(self.tree)
|
2005-12-05 10:24:40 +05:30
|
|
|
scrollwindow.show_all()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-01-17 20:41:15 +05:30
|
|
|
self.vbox.pack_start(filter_box,False)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.vbox.pack_start(scrollwindow,True)
|
|
|
|
|
|
|
|
self.renderer = gtk.CellRendererText()
|
2006-01-23 06:57:46 +05:30
|
|
|
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.inactive = False
|
|
|
|
|
|
|
|
self.columns = []
|
|
|
|
self.build_columns()
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree.connect('button-press-event', self.button_press)
|
|
|
|
self.tree.connect('drag_data_get', self.drag_data_get)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
|
2005-08-20 03:40:35 +05:30
|
|
|
self.selection = self.tree.get_selection()
|
|
|
|
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
|
|
|
self.selection.connect('changed',self.row_changed)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-01-17 20:41:15 +05:30
|
|
|
#self.vbox.set_focus_chain([self.tree, self.filter_list,
|
|
|
|
# self.filter_text, self.filter_invert,
|
|
|
|
# self.filter_button])
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
self.setup_filter()
|
|
|
|
return self.vbox
|
|
|
|
|
|
|
|
def ui_definition(self):
|
2005-08-11 05:23:24 +05:30
|
|
|
"""
|
|
|
|
Specifies the UIManager XML code that defines the menus and buttons
|
|
|
|
associated with the interface.
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
return '''<ui>
|
2006-01-08 10:10:33 +05:30
|
|
|
<accelerator action="Jump"/>
|
2005-08-09 10:11:20 +05:30
|
|
|
<menubar name="MenuBar">
|
|
|
|
<menu action="ViewMenu">
|
|
|
|
<menuitem action="Filter"/>
|
|
|
|
</menu>
|
|
|
|
<menu action="GoMenu">
|
|
|
|
<placeholder name="CommonGo">
|
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
|
|
|
<separator/>
|
|
|
|
<menuitem action="HomePerson"/>
|
|
|
|
<separator/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
|
|
|
<menu action="EditMenu">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
|
|
|
<placeholder name="CommonNavigation">
|
|
|
|
<toolitem action="Back"/>
|
|
|
|
<toolitem action="Forward"/>
|
|
|
|
<toolitem action="HomePerson"/>
|
|
|
|
</placeholder>
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<toolitem action="Add"/>
|
|
|
|
<toolitem action="Edit"/>
|
|
|
|
<toolitem action="Remove"/>
|
|
|
|
</placeholder>
|
|
|
|
</toolbar>
|
2005-08-12 08:05:27 +05:30
|
|
|
<popup name="Popup">
|
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
|
|
|
<menuitem action="HomePerson"/>
|
|
|
|
<separator/>
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</popup>
|
2005-08-09 10:11:20 +05:30
|
|
|
</ui>'''
|
|
|
|
|
2005-08-11 05:23:24 +05:30
|
|
|
def change_db(self,db):
|
|
|
|
"""
|
|
|
|
Callback associated with DbState. Whenenver the database
|
|
|
|
changes, this task is called. In this case, we rebuild the
|
|
|
|
columns, and connect signals to the connected database. Tere
|
|
|
|
is no need to store the database, since we will get the value
|
|
|
|
from self.state.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.build_tree)
|
2006-01-17 20:41:15 +05:30
|
|
|
self.generic_filter_widget.apply_filter()
|
2005-08-11 05:23:24 +05:30
|
|
|
|
|
|
|
def goto_active_person(self,obj=None):
|
2006-01-20 11:03:38 +05:30
|
|
|
self.goto_active_person_2(None)
|
|
|
|
|
|
|
|
def goto_active_person_2(self,obj=None):
|
2005-08-11 05:23:24 +05:30
|
|
|
"""
|
|
|
|
Callback (and usable function) that selects the active person
|
|
|
|
in the display tree.
|
|
|
|
|
|
|
|
We have a bit of a problem due to the nature of how GTK works.
|
|
|
|
We have unselect the previous path and select the new path. However,
|
|
|
|
these cause a row change, which calls the row_change callback, which
|
|
|
|
can end up calling change_active_person, which can call
|
|
|
|
goto_active_person, causing a bit of recusion. Confusing, huh?
|
|
|
|
|
|
|
|
Unforunately, we row_change has to be able to call change_active_person,
|
|
|
|
because the can occur from the interface in addition to programatically.
|
|
|
|
|
|
|
|
TO handle this, we set the self.inactive variable that we can check
|
|
|
|
in row_change to look for this particular condition.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# if there is no active person, or if we have been marked inactive,
|
|
|
|
# simply return
|
|
|
|
|
|
|
|
if not self.dbstate.active or self.inactive:
|
|
|
|
return
|
|
|
|
|
|
|
|
# mark inactive to prevent recusion
|
|
|
|
self.inactive = True
|
|
|
|
|
|
|
|
# select the active person in the person view
|
|
|
|
p = self.dbstate.active
|
|
|
|
try:
|
2005-08-20 03:40:35 +05:30
|
|
|
path = self.model.on_get_path(p.get_handle())
|
2005-08-11 05:23:24 +05:30
|
|
|
group_name = p.get_primary_name().get_group_name()
|
|
|
|
top_name = self.dbstate.db.get_name_group_mapping(group_name)
|
2005-08-20 03:40:35 +05:30
|
|
|
top_path = self.model.on_get_path(top_name)
|
|
|
|
self.tree.expand_row(top_path,0)
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2005-08-20 03:40:35 +05:30
|
|
|
current = self.model.on_get_iter(path)
|
|
|
|
selected = self.selection.path_is_selected(path)
|
2005-08-11 05:23:24 +05:30
|
|
|
if current != p.get_handle() or not selected:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.selection.unselect_all()
|
|
|
|
self.selection.select_path(path)
|
|
|
|
self.tree.scroll_to_cell(path,None,1,0.5,0)
|
2005-08-11 05:23:24 +05:30
|
|
|
except KeyError:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.selection.unselect_all()
|
2005-12-23 11:05:32 +05:30
|
|
|
self.uistate.push_message(_("Active person not visible"))
|
2005-08-11 05:23:24 +05:30
|
|
|
self.dbstate.active = p
|
|
|
|
|
|
|
|
# disable the inactive flag
|
|
|
|
self.inactive = False
|
|
|
|
|
|
|
|
# update history
|
|
|
|
self.handle_history(p.handle)
|
|
|
|
|
|
|
|
def setup_filter(self):
|
|
|
|
"""
|
|
|
|
Builds the default filters and add them to the filter menu.
|
|
|
|
"""
|
2006-01-17 20:41:15 +05:30
|
|
|
default_filters = [
|
|
|
|
[GenericFilter.Everyone, []],
|
|
|
|
[GenericFilter.IsFemale, []],
|
|
|
|
[GenericFilter.IsMale, []],
|
|
|
|
[GenericFilter.HasUnknownGender, []],
|
|
|
|
[GenericFilter.Disconnected, []],
|
|
|
|
[GenericFilter.SearchName, ['']],
|
|
|
|
[GenericFilter.HaveAltFamilies, []],
|
|
|
|
[GenericFilter.HavePhotos, []],
|
|
|
|
[GenericFilter.IncompleteNames, []],
|
|
|
|
[GenericFilter.HaveChildren, []],
|
|
|
|
[GenericFilter.NeverMarried, []],
|
|
|
|
[GenericFilter.MultipleMarriages, []],
|
|
|
|
[GenericFilter.NoBirthdate, []],
|
|
|
|
[GenericFilter.PersonWithIncompleteEvent, []],
|
|
|
|
[GenericFilter.FamilyWithIncompleteEvent, []],
|
|
|
|
[GenericFilter.ProbablyAlive, ['']],
|
|
|
|
[GenericFilter.PeoplePrivate, []],
|
|
|
|
[GenericFilter.IsWitness, ['','']],
|
|
|
|
[GenericFilter.HasTextMatchingSubstringOf, ['',0,0]],
|
|
|
|
[GenericFilter.HasTextMatchingRegexpOf, ['',0,1]],
|
|
|
|
[GenericFilter.HasNote, []],
|
|
|
|
[GenericFilter.HasNoteMatchingSubstringOf, ['']],
|
|
|
|
[GenericFilter.IsFemale, []],
|
|
|
|
]
|
|
|
|
self.generic_filter_widget.setup_filter( default_filters, "person")
|
2005-08-11 05:23:24 +05:30
|
|
|
|
|
|
|
def build_tree(self):
|
|
|
|
"""
|
|
|
|
Creates a new PeopleModel instance. Essentially creates a complete
|
|
|
|
rebuild of the data.
|
|
|
|
"""
|
2006-01-20 11:03:38 +05:30
|
|
|
if self.active:
|
|
|
|
self.model = PeopleModel.PeopleModel(
|
2006-01-24 09:43:21 +05:30
|
|
|
self.dbstate.db, self.generic_filter_widget.get_filter(),
|
|
|
|
self.generic_filter_widget.inverted())
|
2006-01-20 11:03:38 +05:30
|
|
|
self.tree.set_model(self.model)
|
|
|
|
|
|
|
|
if self.model.tooltip_column != None:
|
|
|
|
self.tooltips = TreeTips.TreeTips(self.tree,self.model.tooltip_column,True)
|
|
|
|
self.build_columns()
|
|
|
|
self.dirty = False
|
|
|
|
else:
|
|
|
|
self.dirty = True
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def filter_toggle(self,obj):
|
|
|
|
if obj.get_active():
|
2006-01-17 20:41:15 +05:30
|
|
|
self.generic_filter_widget.show()
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
2006-01-17 20:41:15 +05:30
|
|
|
self.generic_filter_widget.hide()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def add(self,obj):
|
|
|
|
person = RelLib.Person()
|
2005-12-14 12:24:02 +05:30
|
|
|
EditPerson.EditPerson(self.dbstate, self.uistate, [], person)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def edit(self,obj):
|
2005-09-17 00:07:13 +05:30
|
|
|
if self.dbstate.active:
|
2006-01-24 09:43:21 +05:30
|
|
|
EditPerson.EditPerson(self.dbstate, self.uistate, [],
|
|
|
|
self.dbstate.active)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def remove(self,obj):
|
|
|
|
mlist = self.get_selected_objects()
|
|
|
|
if len(mlist) == 0:
|
|
|
|
return
|
|
|
|
|
|
|
|
for sel in mlist:
|
2005-08-11 05:23:24 +05:30
|
|
|
p = self.dbstate.db.get_person_from_handle(sel)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.active_person = p
|
|
|
|
name = NameDisplay.displayer.display(p)
|
|
|
|
|
|
|
|
msg = _('Deleting the person will remove the person '
|
|
|
|
'from the database.')
|
|
|
|
msg = "%s %s" % (msg,Utils.data_recover_msg)
|
|
|
|
QuestionDialog.QuestionDialog(_('Delete %s?') % name,msg,
|
|
|
|
_('_Delete Person'),
|
|
|
|
self.delete_person_response)
|
|
|
|
|
|
|
|
def delete_person_response(self):
|
|
|
|
#self.disable_interface()
|
2005-08-11 05:23:24 +05:30
|
|
|
trans = self.dbstate.db.transaction_begin()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
n = NameDisplay.displayer.display(self.active_person)
|
|
|
|
|
2005-08-11 05:23:24 +05:30
|
|
|
if self.dbstate.db.get_default_person() == self.active_person:
|
|
|
|
self.dbstate.db.set_default_person_handle(None)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
for family_handle in self.active_person.get_family_handle_list():
|
|
|
|
if not family_handle:
|
|
|
|
continue
|
2005-08-11 05:23:24 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
2005-08-09 10:11:20 +05:30
|
|
|
family_to_remove = False
|
|
|
|
if self.active_person.get_handle() == family.get_father_handle():
|
|
|
|
if family.get_mother_handle():
|
|
|
|
family.set_father_handle(None)
|
|
|
|
else:
|
|
|
|
family_to_remove = True
|
|
|
|
else:
|
|
|
|
if family.get_father_handle():
|
|
|
|
family.set_mother_handle(None)
|
|
|
|
else:
|
|
|
|
family_to_remove = True
|
|
|
|
if family_to_remove:
|
|
|
|
for child_handle in family.get_child_handle_list():
|
2005-08-11 05:23:24 +05:30
|
|
|
child = self.dbstate.db.get_person_from_handle(child_handle)
|
2005-08-09 10:11:20 +05:30
|
|
|
child.remove_parent_family_handle(family_handle)
|
2005-12-22 11:43:11 +05:30
|
|
|
self.dbstate.db.commit_person(child,trans)
|
2005-08-11 05:23:24 +05:30
|
|
|
self.dbstate.db.remove_family(family_handle,trans)
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
2005-08-11 05:23:24 +05:30
|
|
|
self.dbstate.db.commit_family(family,trans)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
for (family_handle,mrel,frel) in self.active_person.get_parent_family_handle_list():
|
|
|
|
if family_handle:
|
2005-12-22 11:43:11 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
2005-08-09 10:11:20 +05:30
|
|
|
family.remove_child_handle(self.active_person.get_handle())
|
2005-12-22 11:43:11 +05:30
|
|
|
self.dbstate.db.commit_family(family,trans)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
handle = self.active_person.get_handle()
|
|
|
|
|
|
|
|
person = self.active_person
|
|
|
|
self.remove_from_person_list(person)
|
2005-12-22 11:43:11 +05:30
|
|
|
#self.remove_from_history(handle)
|
2005-08-11 05:23:24 +05:30
|
|
|
self.dbstate.db.remove_person(handle, trans)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2006-02-03 11:01:42 +05:30
|
|
|
self.uistate.phistory.back()
|
2005-08-11 05:23:24 +05:30
|
|
|
self.dbstate.db.transaction_commit(trans,_("Delete Person (%s)") % n)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def build_columns(self):
|
|
|
|
for column in self.columns:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree.remove_column(column)
|
2005-09-16 20:55:27 +05:30
|
|
|
try:
|
2006-01-06 10:38:51 +05:30
|
|
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0,
|
|
|
|
background=self.model.marker_color_column)
|
2005-09-16 20:55:27 +05:30
|
|
|
except AttributeError:
|
|
|
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
2005-08-09 10:11:20 +05:30
|
|
|
column.set_resizable(True)
|
|
|
|
#column.set_clickable(True)
|
|
|
|
#column.connect('clicked',self.sort_clicked)
|
|
|
|
column.set_min_width(225)
|
|
|
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree.append_column(column)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.columns = [column]
|
|
|
|
|
2005-08-11 05:23:24 +05:30
|
|
|
for pair in self.dbstate.db.get_person_column_order():
|
2005-08-09 10:11:20 +05:30
|
|
|
if not pair[0]:
|
|
|
|
continue
|
|
|
|
name = column_names[pair[1]]
|
2005-09-16 20:55:27 +05:30
|
|
|
try:
|
2006-01-06 10:38:51 +05:30
|
|
|
column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1],
|
|
|
|
background=self.model.marker_color_column)
|
2005-09-16 20:55:27 +05:30
|
|
|
except AttributeError:
|
|
|
|
column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1])
|
2005-08-09 10:11:20 +05:30
|
|
|
column.set_resizable(True)
|
|
|
|
column.set_min_width(60)
|
|
|
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
|
|
|
|
self.columns.append(column)
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree.append_column(column)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
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()
|
2005-08-11 05:23:24 +05:30
|
|
|
if not self.inactive:
|
|
|
|
try:
|
|
|
|
person = self.dbstate.db.get_person_from_handle(selected_ids[0])
|
|
|
|
self.dbstate.change_active_person(person)
|
|
|
|
except:
|
|
|
|
self.dbstate.change_active_person(None)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
if len(selected_ids) == 1:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree.drag_source_set(BUTTON1_MASK,
|
2005-08-09 10:11:20 +05:30
|
|
|
[DdTargets.PERSON_LINK.target()],
|
|
|
|
ACTION_COPY)
|
|
|
|
elif len(selected_ids) > 1:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.tree.drag_source_set(BUTTON1_MASK,
|
2005-08-09 10:11:20 +05:30
|
|
|
[DdTargets.PERSON_LINK_LIST.target()],
|
|
|
|
ACTION_COPY)
|
2005-08-11 05:23:24 +05:30
|
|
|
self.uistate.modify_statusbar()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2005-08-20 03:40:35 +05:30
|
|
|
def drag_data_get(self, widget, context, sel_data, info, time):
|
2005-08-09 10:11:20 +05:30
|
|
|
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 person_added(self,handle_list):
|
2006-02-09 10:40:20 +05:30
|
|
|
self.model.clear_cache()
|
2005-08-09 10:11:20 +05:30
|
|
|
for node in handle_list:
|
2005-08-11 05:23:24 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(node)
|
2005-08-09 10:11:20 +05:30
|
|
|
top = person.get_primary_name().get_group_name()
|
2006-02-03 11:01:42 +05:30
|
|
|
self.model.rebuild_data()
|
2005-08-20 03:40:35 +05:30
|
|
|
if not self.model.is_visable(node):
|
2005-08-09 10:11:20 +05:30
|
|
|
continue
|
2005-08-20 03:40:35 +05:30
|
|
|
if (not self.model.sname_sub.has_key(top) or
|
|
|
|
len(self.model.sname_sub[top]) == 1):
|
|
|
|
path = self.model.on_get_path(top)
|
|
|
|
pnode = self.model.get_iter(path)
|
|
|
|
self.model.row_inserted(path,pnode)
|
|
|
|
path = self.model.on_get_path(node)
|
|
|
|
pnode = self.model.get_iter(path)
|
|
|
|
self.model.row_inserted(path,pnode)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def person_removed(self,handle_list):
|
2006-02-09 10:40:20 +05:30
|
|
|
self.model.clear_cache()
|
|
|
|
self.build_tree()
|
|
|
|
# for node in handle_list:
|
|
|
|
# person = self.dbstate.db.get_person_from_handle(node)
|
|
|
|
# top = person.get_primary_name().get_group_name()
|
|
|
|
# mylist = self.model.sname_sub.get(top,[])
|
|
|
|
# self.model.calculate_data()
|
|
|
|
# if mylist:
|
|
|
|
# try:
|
|
|
|
# path = self.model.on_get_path(node)
|
|
|
|
# self.model.row_deleted(path)
|
|
|
|
# if len(mylist) == 1:
|
|
|
|
# path = self.model.on_get_path(top)
|
|
|
|
# self.model.row_deleted(path)
|
|
|
|
# except KeyError:
|
|
|
|
# pass
|
|
|
|
# self.model.assign_data()
|
2006-02-09 06:05:46 +05:30
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def person_updated(self,handle_list):
|
2006-02-09 10:40:20 +05:30
|
|
|
self.model.clear_cache()
|
2005-08-09 10:11:20 +05:30
|
|
|
for node in handle_list:
|
2005-08-11 05:23:24 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(node)
|
2005-08-09 10:11:20 +05:30
|
|
|
try:
|
2005-08-20 03:40:35 +05:30
|
|
|
oldpath = self.model.iter2path[node]
|
2005-08-09 10:11:20 +05:30
|
|
|
except:
|
|
|
|
return
|
2005-08-20 03:40:35 +05:30
|
|
|
pathval = self.model.on_get_path(node)
|
|
|
|
pnode = self.model.get_iter(pathval)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# calculate the new data
|
|
|
|
|
|
|
|
if person.primary_name.group_as:
|
|
|
|
surname = person.primary_name.group_as
|
|
|
|
else:
|
2005-08-11 05:23:24 +05:30
|
|
|
base = person.primary_name.surname
|
|
|
|
surname = self.dbstate.db.get_name_group_mapping(base)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
if oldpath[0] == surname:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.model.build_sub_entry(surname)
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.model.calculate_data(self.DataFilter)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# find the path of the person in the new data build
|
2005-08-20 03:40:35 +05:30
|
|
|
newpath = self.model.temp_iter2path[node]
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# if paths same, just issue row changed signal
|
|
|
|
|
|
|
|
if oldpath == newpath:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.model.row_changed(pathval,pnode)
|
2005-08-09 10:11:20 +05:30
|
|
|
else:
|
|
|
|
# paths different, get the new surname list
|
|
|
|
|
2005-08-20 03:40:35 +05:30
|
|
|
mylist = self.model.temp_sname_sub.get(oldpath[0],[])
|
|
|
|
path = self.model.on_get_path(node)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# delete original
|
2005-08-20 03:40:35 +05:30
|
|
|
self.model.row_deleted(pathval)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# delete top node of original if necessar
|
|
|
|
if len(mylist)==0:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.model.row_deleted(pathval[0])
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# determine if we need to insert a new top node',
|
2005-08-20 03:40:35 +05:30
|
|
|
insert = not self.model.sname_sub.has_key(newpath[0])
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# assign new data
|
2005-08-20 03:40:35 +05:30
|
|
|
self.model.assign_data()
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# insert new row if needed
|
|
|
|
if insert:
|
2005-08-20 03:40:35 +05:30
|
|
|
path = self.model.on_get_path(newpath[0])
|
|
|
|
pnode = self.model.get_iter(path)
|
|
|
|
self.model.row_inserted(path,pnode)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
# insert new person
|
2005-08-20 03:40:35 +05:30
|
|
|
path = self.model.on_get_path(node)
|
|
|
|
pnode = self.model.get_iter(path)
|
|
|
|
self.model.row_inserted(path,pnode)
|
2005-08-09 10:11:20 +05:30
|
|
|
self.goto_active_person()
|
|
|
|
|
|
|
|
def get_selected_objects(self):
|
2005-08-20 03:40:35 +05:30
|
|
|
(mode,paths) = self.selection.get_selected_rows()
|
2005-08-09 10:11:20 +05:30
|
|
|
mlist = []
|
|
|
|
for path in paths:
|
2005-08-20 03:40:35 +05:30
|
|
|
node = self.model.on_get_iter(path)
|
2006-01-24 09:43:21 +05:30
|
|
|
handle = self.model.on_get_value(node, PeopleModel.COLUMN_INT_ID)
|
|
|
|
mlist.append(handle)
|
2005-08-09 10:11:20 +05:30
|
|
|
return mlist
|
|
|
|
|
|
|
|
def remove_from_person_list(self,person):
|
|
|
|
"""Remove the selected person from the list. A person object is
|
|
|
|
expected, not an ID"""
|
2005-08-20 03:40:35 +05:30
|
|
|
path = self.model.on_get_path(person.get_handle())
|
2005-08-09 10:11:20 +05:30
|
|
|
(col,row) = path
|
|
|
|
if row > 0:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.selection.select_path((col,row-1))
|
|
|
|
elif row == 0 and self.model.on_get_iter(path):
|
|
|
|
self.selection.select_path(path)
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2005-08-12 08:05:27 +05:30
|
|
|
def button_press(self,obj,event):
|
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
handle = self.first_selected()
|
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
2005-09-16 18:48:52 +05:30
|
|
|
if person:
|
2005-12-14 12:24:02 +05:30
|
|
|
EditPerson.EditPerson(self.dbstate, self.uistate, [], person)
|
2005-09-16 18:48:52 +05:30
|
|
|
return True
|
2005-08-12 08:05:27 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
|
|
menu = self.uistate.uimanager.get_widget('/Popup')
|
2005-09-16 18:48:52 +05:30
|
|
|
if menu:
|
|
|
|
menu.popup(None,None,None,event.button,event.time)
|
|
|
|
return True
|
2005-08-12 08:05:27 +05:30
|
|
|
return False
|