2003-06-02 19:04:18 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-05-07 09:57:16 +05:30
|
|
|
# Copyright (C) 2003-2004 Donald N. Allingham
|
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
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
2006-03-20 05:04:23 +05:30
|
|
|
import pango
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2006-05-17 06:18:46 +05:30
|
|
|
from DisplayModels import PeopleModel
|
2006-04-28 06:03:44 +05:30
|
|
|
import ManagedWindow
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SelectPerson
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-28 06:03:44 +05:30
|
|
|
class SelectPerson(ManagedWindow.ManagedWindow):
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2006-05-31 23:56:50 +05:30
|
|
|
def __init__(self, dbstate, uistate, track=[], title='',
|
|
|
|
filter=None, skip=[]):
|
|
|
|
if title:
|
|
|
|
self.title = title
|
|
|
|
else:
|
|
|
|
self.title = _("Select Person")
|
2006-04-28 06:03:44 +05:30
|
|
|
|
2006-05-31 23:56:50 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
self.renderer = gtk.CellRendererText()
|
2006-03-20 05:04:23 +05:30
|
|
|
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
|
2006-04-28 06:03:44 +05:30
|
|
|
self.db = dbstate.db
|
2004-05-07 08:28:29 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
2004-03-23 10:31:19 +05:30
|
|
|
self.plist = self.glade.get_widget('plist')
|
2006-10-10 04:34:52 +05:30
|
|
|
self.showall = self.glade.get_widget('showall')
|
2003-06-02 19:04:18 +05:30
|
|
|
self.notebook = self.glade.get_widget('notebook')
|
|
|
|
|
2006-05-31 23:56:50 +05:30
|
|
|
window = self.glade.get_widget('select_person')
|
|
|
|
title_label = self.glade.get_widget('title')
|
|
|
|
self.set_window(window,title_label,self.title)
|
2006-10-10 04:34:52 +05:30
|
|
|
|
|
|
|
self.filter = filter
|
|
|
|
if self.filter:
|
|
|
|
self.showall.show()
|
|
|
|
|
|
|
|
self.skip = skip
|
|
|
|
|
2006-05-17 06:18:46 +05:30
|
|
|
self.model = PeopleModel(self.db,
|
|
|
|
(PeopleModel.FAST, filter),
|
|
|
|
skip=skip)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
self.add_columns(self.plist)
|
|
|
|
self.plist.set_model(self.model)
|
2006-10-10 04:34:52 +05:30
|
|
|
self.showall.connect('toggled',self.show_toggle)
|
2006-04-28 06:03:44 +05:30
|
|
|
self.show()
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2006-10-10 04:34:52 +05:30
|
|
|
def show_toggle(self, obj):
|
|
|
|
if obj.get_active():
|
|
|
|
filt = None
|
|
|
|
else:
|
|
|
|
filt = self.filter
|
|
|
|
|
|
|
|
self.model = PeopleModel(self.db,
|
|
|
|
(PeopleModel.FAST, filt),
|
|
|
|
skip=self.skip)
|
|
|
|
self.plist.set_model(self.model)
|
|
|
|
|
2006-04-28 06:03:44 +05:30
|
|
|
def build_menu_names(self,obj):
|
2006-05-31 23:56:50 +05:30
|
|
|
return (self.title, None)
|
2006-03-20 10:12:37 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
def add_columns(self,tree):
|
2006-03-19 08:55:31 +05:30
|
|
|
tree.set_fixed_height_mode(True)
|
|
|
|
column = gtk.TreeViewColumn(_('Name'), self.renderer, text=0)
|
|
|
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
|
|
|
column.set_fixed_width(225)
|
2004-03-23 10:31:19 +05:30
|
|
|
tree.append_column(column)
|
2006-03-19 08:55:31 +05:30
|
|
|
|
|
|
|
column = gtk.TreeViewColumn(_('ID'), self.renderer, text=1)
|
|
|
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
|
|
|
column.set_fixed_width(75)
|
2004-03-23 10:31:19 +05:30
|
|
|
tree.append_column(column)
|
2006-03-19 08:55:31 +05:30
|
|
|
|
|
|
|
column = gtk.TreeViewColumn(_('Birth date'), self.renderer, text=3)
|
|
|
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
|
|
|
column.set_fixed_width(160)
|
2004-03-23 10:31:19 +05:30
|
|
|
tree.append_column(column)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
def select_function(self,store,path,iter,id_list):
|
2004-09-01 09:17:10 +05:30
|
|
|
id_list.append(self.model.get_value(iter,PeopleModel.COLUMN_INT_ID))
|
2004-03-23 10:31:19 +05:30
|
|
|
|
|
|
|
def get_selected_ids(self):
|
|
|
|
mlist = []
|
|
|
|
self.plist.get_selection().selected_foreach(self.select_function,mlist)
|
|
|
|
return mlist
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
def run(self):
|
2006-04-28 06:03:44 +05:30
|
|
|
val = self.window.run()
|
2003-06-02 19:04:18 +05:30
|
|
|
if val == gtk.RESPONSE_OK:
|
2004-03-23 10:31:19 +05:30
|
|
|
idlist = self.get_selected_ids()
|
2006-04-28 06:03:44 +05:30
|
|
|
self.close()
|
2004-03-23 10:31:19 +05:30
|
|
|
if idlist and idlist[0]:
|
2004-08-07 10:46:57 +05:30
|
|
|
return_value = self.db.get_person_from_handle(idlist[0])
|
2003-06-02 19:04:18 +05:30
|
|
|
else:
|
|
|
|
return_value = None
|
|
|
|
return return_value
|
2006-06-17 00:32:15 +05:30
|
|
|
elif val != gtk.RESPONSE_DELETE_EVENT:
|
2006-04-28 06:03:44 +05:30
|
|
|
self.close()
|
2003-06-02 19:04:18 +05:30
|
|
|
return None
|