2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2009-02-12 01:43:46 +05:30
|
|
|
# Copyright (C) 2003-2006 Donald N. Allingham
|
|
|
|
# 2009 Gary Burton
|
2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2006-05-17 11:15:53 +05:30
|
|
|
# $Id$
|
2004-05-07 09:57:16 +05:30
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2003-06-02 19:04:18 +05:30
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-11-08 22:11:49 +05:30
|
|
|
from gui.views.treemodels import PeopleModel
|
2009-12-15 09:15:09 +05:30
|
|
|
from baseselector import BaseSelector
|
2007-03-25 07:55:37 +05:30
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2009-02-12 01:43:46 +05:30
|
|
|
# SelectEvent
|
2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-02-12 01:43:46 +05:30
|
|
|
class SelectPerson(BaseSelector):
|
2006-04-28 06:03:44 +05:30
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
def __init__(self, dbstate, uistate, track=[], title = None, filter = None,
|
|
|
|
skip=set(), show_search_bar = False):
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
# SelectPerson may have a title passed to it which should be used
|
|
|
|
# instead of the default defined for get_window_title()
|
|
|
|
if title is not None:
|
|
|
|
self.title = title
|
2006-10-10 04:34:52 +05:30
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
BaseSelector.__init__(self, dbstate, uistate, track, filter,
|
|
|
|
skip, show_search_bar)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
def _local_init(self):
|
|
|
|
"""
|
|
|
|
Perform local initialisation for this class
|
|
|
|
"""
|
2009-10-08 06:42:51 +05:30
|
|
|
self.width_key = 'interface.person-sel-width'
|
|
|
|
self.height_key = 'interface.person-sel-height'
|
2009-02-12 01:43:46 +05:30
|
|
|
self.tree.connect('key-press-event', self._key_press)
|
2006-10-10 04:34:52 +05:30
|
|
|
self.showall.connect('toggled',self.show_toggle)
|
2006-03-20 10:12:37 +05:30
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
def get_window_title(self):
|
|
|
|
return _("Select Person")
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
def get_model_class(self):
|
|
|
|
return PeopleModel
|
|
|
|
|
|
|
|
def get_column_titles(self):
|
|
|
|
return [
|
2009-08-25 04:26:12 +05:30
|
|
|
(_('Name'), 250, BaseSelector.TEXT, 0),
|
|
|
|
(_('ID'), 75, BaseSelector.TEXT, 1),
|
|
|
|
(_('Gender'), 75, BaseSelector.TEXT, 2),
|
|
|
|
(_('Birth Date'), 150, BaseSelector.MARKUP, 3),
|
|
|
|
(_('Birth Place'), 150, BaseSelector.MARKUP, 4),
|
|
|
|
(_('Death Date'), 150, BaseSelector.MARKUP, 5),
|
|
|
|
(_('Death Place'), 150, BaseSelector.MARKUP, 6),
|
|
|
|
(_('Spouse'), 150, BaseSelector.TEXT, 7),
|
|
|
|
(_('Last Change'), 150, BaseSelector.TEXT, 8)
|
2009-02-12 01:43:46 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
def get_from_handle_func(self):
|
|
|
|
return self.db.get_person_from_handle
|
|
|
|
|
|
|
|
def get_handle_column(self):
|
|
|
|
return PeopleModel.COLUMN_INT_ID
|
2009-08-25 04:26:12 +05:30
|
|
|
|
2009-11-07 18:34:45 +05:30
|
|
|
def exact_search(self):
|
|
|
|
"""
|
|
|
|
Returns a tuple indicating columns requiring an exact search
|
|
|
|
"""
|
|
|
|
return (2,) # Gender ('female' contains the string 'male')
|
|
|
|
|
2009-02-12 01:43:46 +05:30
|
|
|
def _on_row_activated(self, treeview, path, view_col):
|
|
|
|
store, paths = self.selection.get_selected_rows()
|
|
|
|
if paths and len(paths[0]) == 2 :
|
|
|
|
self.window.response(gtk.RESPONSE_OK)
|
2008-01-03 19:09:57 +05:30
|
|
|
|
|
|
|
def _key_press(self, obj, event):
|
|
|
|
if not event.state or event.state in (gtk.gdk.MOD2_MASK, ):
|
|
|
|
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
|
|
|
|
store, paths = self.selection.get_selected_rows()
|
|
|
|
if paths and len(paths[0]) == 1 :
|
2009-02-12 01:43:46 +05:30
|
|
|
if self.tree.row_expanded(paths[0]):
|
|
|
|
self.tree.collapse_row(paths[0])
|
2008-01-03 19:09:57 +05:30
|
|
|
else:
|
2009-02-12 01:43:46 +05:30
|
|
|
self.tree.expand_row(paths[0], 0)
|
2008-01-03 19:09:57 +05:30
|
|
|
return True
|
|
|
|
return False
|