2006-01-20 22:01:25 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2006 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$
|
|
|
|
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-01-17 14:08:34 +05:30
|
|
|
|
2006-01-15 03:51:56 +05:30
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
|
2006-02-08 20:33:06 +05:30
|
|
|
from TreeViews import PersonTreeView
|
|
|
|
|
2006-01-19 21:33:09 +05:30
|
|
|
import NameDisplay
|
2006-01-17 14:08:34 +05:30
|
|
|
|
2006-02-08 22:02:47 +05:30
|
|
|
from _TreeFrameBase import TreeFrameBase
|
|
|
|
|
2006-01-17 14:08:34 +05:30
|
|
|
column_names = [
|
|
|
|
_('Name'),
|
|
|
|
_('ID') ,
|
|
|
|
_('Gender'),
|
|
|
|
_('Birth Date'),
|
|
|
|
_('Birth Place'),
|
|
|
|
_('Death Date'),
|
|
|
|
_('Death Place'),
|
|
|
|
_('Spouse'),
|
|
|
|
_('Last Change'),
|
|
|
|
_('Cause of Death'),
|
|
|
|
]
|
|
|
|
|
2006-01-15 03:51:56 +05:30
|
|
|
|
2006-02-08 22:02:47 +05:30
|
|
|
class PersonTreeFrame(TreeFrameBase):
|
2006-01-15 03:51:56 +05:30
|
|
|
|
|
|
|
__gproperties__ = {}
|
|
|
|
|
|
|
|
__gsignals__ = {
|
|
|
|
}
|
|
|
|
|
|
|
|
__default_border_width = 5
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self,dbstate):
|
2006-02-08 22:02:47 +05:30
|
|
|
TreeFrameBase.__init__(self)
|
2006-01-15 03:51:56 +05:30
|
|
|
|
2006-01-17 14:08:34 +05:30
|
|
|
self._dbstate = dbstate
|
|
|
|
self._selection = None
|
|
|
|
self._model = None
|
2006-01-19 21:33:09 +05:30
|
|
|
self._data_filter = None
|
2006-01-17 14:08:34 +05:30
|
|
|
|
2006-02-08 20:33:06 +05:30
|
|
|
self._tree = PersonTreeView(dbstate.db)
|
2006-01-17 14:08:34 +05:30
|
|
|
self._tree.set_rules_hint(True)
|
|
|
|
self._tree.set_headers_visible(True)
|
|
|
|
|
2006-01-19 21:33:09 +05:30
|
|
|
self._tree.connect('row-activated',self._on_row_activated)
|
|
|
|
|
2006-01-17 19:13:29 +05:30
|
|
|
scrollwindow = gtk.ScrolledWindow()
|
|
|
|
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
scrollwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
|
|
|
|
|
|
|
scrollwindow.add(self._tree)
|
|
|
|
|
|
|
|
self.add(scrollwindow)
|
2006-01-15 03:51:56 +05:30
|
|
|
|
2006-01-19 21:33:09 +05:30
|
|
|
self.change_db(self._dbstate.db)
|
|
|
|
|
|
|
|
def _on_row_activated(self,widget,path,col):
|
|
|
|
"""Expand / colapse row"""
|
|
|
|
|
|
|
|
if self._tree.row_expanded(path):
|
|
|
|
self._tree.collapse_row(path)
|
|
|
|
else:
|
|
|
|
self._tree.expand_row(path,False)
|
|
|
|
|
|
|
|
def change_db(self,db):
|
2006-01-20 02:43:00 +05:30
|
|
|
self.set_model()
|
2006-01-17 14:08:34 +05:30
|
|
|
|
2006-01-20 02:43:00 +05:30
|
|
|
def set_model(self,data_filter=None):
|
2006-01-17 14:08:34 +05:30
|
|
|
|
2006-02-08 20:33:06 +05:30
|
|
|
if data_filter is None:
|
|
|
|
self._tree.get_selection().unselect_all()
|
|
|
|
self._tree.clear_filter()
|
|
|
|
else:
|
|
|
|
self._tree.set_filter(data_filter)
|
|
|
|
|
2006-01-17 14:08:34 +05:30
|
|
|
self._selection = self._tree.get_selection()
|
|
|
|
|
2006-01-19 21:33:09 +05:30
|
|
|
# expand the first row so that the tree is a sensible size.
|
|
|
|
self._tree.expand_row((0,),False)
|
|
|
|
|
2006-01-17 14:08:34 +05:30
|
|
|
def get_selection(self):
|
|
|
|
return self._selection
|
2006-01-15 03:51:56 +05:30
|
|
|
|
2006-01-17 20:24:46 +05:30
|
|
|
def get_tree(self):
|
|
|
|
return self._tree
|
|
|
|
|
2006-01-15 03:51:56 +05:30
|
|
|
if gtk.pygtk_version < (2,8,0):
|
|
|
|
gobject.type_register(PersonTreeFrame)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
w = ObjectSelectorWindow()
|
|
|
|
w.show_all()
|
|
|
|
w.connect("destroy", gtk.main_quit)
|
|
|
|
|
|
|
|
gtk.main()
|