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
|
|
|
|
#
|
|
|
|
|
2004-05-07 09:57:16 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import const
|
|
|
|
import Utils
|
2004-03-23 10:31:19 +05:30
|
|
|
import PeopleModel
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SelectPerson
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SelectPerson:
|
|
|
|
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
def __init__(self,db,title,flabel="",filter=None,parent_window=None):
|
2003-06-02 19:04:18 +05:30
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
self.renderer = gtk.CellRendererText()
|
2003-06-02 19:04:18 +05:30
|
|
|
self.db = db
|
2004-05-07 09:28:26 +05:30
|
|
|
self.filter = filter
|
2004-05-07 08:28:29 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
|
|
|
self.top = self.glade.get_widget('select_person')
|
2003-06-02 19:04:18 +05:30
|
|
|
title_label = self.glade.get_widget('title')
|
|
|
|
self.filter_select = self.glade.get_widget('filter')
|
2004-03-23 10:31:19 +05:30
|
|
|
self.plist = self.glade.get_widget('plist')
|
2003-06-02 19:04:18 +05:30
|
|
|
self.notebook = self.glade.get_widget('notebook')
|
|
|
|
if filter:
|
|
|
|
self.use_filter = 1
|
|
|
|
else:
|
|
|
|
self.use_filter = 0
|
|
|
|
|
|
|
|
Utils.set_titles(self.top,title_label,title)
|
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
self.model = PeopleModel.PeopleModel(self.db)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
if filter:
|
|
|
|
self.filter_select.set_label(flabel)
|
|
|
|
self.filter_select.connect('toggled',self.redraw_cb)
|
2004-05-07 09:28:26 +05:30
|
|
|
self.filter_select.show()
|
2003-06-02 19:04:18 +05:30
|
|
|
self.filter_select.set_active(1)
|
|
|
|
else:
|
|
|
|
self.filter_select.hide()
|
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
self.add_columns(self.plist)
|
2003-06-02 19:04:18 +05:30
|
|
|
self.redraw()
|
2004-03-23 10:31:19 +05:30
|
|
|
self.plist.set_model(self.model)
|
2003-06-02 19:04:18 +05:30
|
|
|
self.top.show()
|
|
|
|
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
if parent_window:
|
|
|
|
self.top.set_transient_for(parent_window)
|
|
|
|
|
2003-06-02 19:04:18 +05:30
|
|
|
def redraw_cb(self,obj):
|
|
|
|
self.use_filter = self.filter_select.get_active()
|
|
|
|
self.redraw()
|
2004-03-23 10:31:19 +05:30
|
|
|
|
|
|
|
def add_columns(self,tree):
|
|
|
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
|
|
|
column.set_resizable(gtk.TRUE)
|
|
|
|
column.set_clickable(gtk.TRUE)
|
|
|
|
column.set_sort_column_id(0)
|
|
|
|
column.set_min_width(225)
|
|
|
|
tree.append_column(column)
|
|
|
|
column = gtk.TreeViewColumn(_('ID'), self.renderer,text=1)
|
|
|
|
column.set_resizable(gtk.TRUE)
|
|
|
|
column.set_clickable(gtk.TRUE)
|
|
|
|
column.set_sort_column_id(1)
|
|
|
|
column.set_min_width(75)
|
|
|
|
tree.append_column(column)
|
|
|
|
column = gtk.TreeViewColumn(_('Birth date'), self.renderer,text=3)
|
|
|
|
#column.set_resizable(gtk.TRUE)
|
|
|
|
column.set_clickable(gtk.TRUE)
|
|
|
|
tree.append_column(column)
|
2003-06-02 19:04:18 +05:30
|
|
|
|
|
|
|
def redraw(self):
|
|
|
|
|
2004-05-07 09:28:26 +05:30
|
|
|
return
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
for key in self.db.get_person_handles(sort_handles=True):
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_handle(key)
|
2004-05-07 09:28:26 +05:30
|
|
|
if self.use_filter and not self.filter(person):
|
2003-06-02 19:04:18 +05:30
|
|
|
continue
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
data = self.db.get_person_from_handle(key).get_display_info()
|
2004-02-14 11:10:30 +05:30
|
|
|
gender = person.get_gender()
|
2004-05-07 09:28:26 +05:30
|
|
|
if gender == RelLib.Person.plist:
|
|
|
|
self.mmodel.add([data[0],data[1],data[3],data[5],data[6]],key)
|
|
|
|
elif gender == RelLib.Person.feplist:
|
|
|
|
self.fmodel.add([data[0],data[1],data[3],data[5],data[6]],key)
|
2003-06-02 19:04:18 +05:30
|
|
|
else:
|
2004-05-07 09:28:26 +05:30
|
|
|
self.umodel.add([data[0],data[1],data[3],data[5],data[6]],key)
|
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):
|
|
|
|
id_list.append(self.model.get_value(iter,1))
|
|
|
|
|
|
|
|
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):
|
|
|
|
val = self.top.run()
|
|
|
|
if val == gtk.RESPONSE_OK:
|
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
idlist = self.get_selected_ids()
|
|
|
|
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
|
|
|
|
self.top.destroy()
|
|
|
|
return return_value
|
|
|
|
else:
|
|
|
|
self.top.destroy()
|
|
|
|
return None
|