2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-04-26 03:59:46 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2002-10-20 19:55:16 +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-11 05:20:30 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Analysis and Exploration/Interactive descendant browser"
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2006-04-26 03:59:46 +05:30
|
|
|
# GTK/GNOME modules
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-04-26 03:59:46 +05:30
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2006-04-26 03:59:46 +05:30
|
|
|
# GRAMPS modules
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-04-26 03:59:46 +05:30
|
|
|
import NameDisplay
|
|
|
|
from PluginUtils import Tool, register_tool
|
2005-12-13 07:37:16 +05:30
|
|
|
import GrampsDisplay
|
2006-04-19 00:40:13 +05:30
|
|
|
import ManagedWindow
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-04-22 10:18:40 +05:30
|
|
|
class DesBrowse(Tool.ActivePersonTool, ManagedWindow.ManagedWindow):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-04-19 00:40:13 +05:30
|
|
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-04-22 10:18:40 +05:30
|
|
|
Tool.ActivePersonTool.__init__(self, dbstate, options_class, name)
|
|
|
|
if self.fail:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.dbstate = dbstate
|
2006-04-19 00:40:13 +05:30
|
|
|
self.active = dbstate.get_active_person()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.callback = callback
|
2006-04-26 03:59:46 +05:30
|
|
|
self.active_name = _("Descendant Browser: %s") \
|
|
|
|
% NameDisplay.displayer.display(self.active)
|
|
|
|
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
glade_file = base + os.sep + "desbrowse.glade"
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.glade = gtk.glade.XML(glade_file,"top","gramps")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.glade.signal_autoconnect({
|
2006-04-26 03:59:46 +05:30
|
|
|
"destroy_passed_object" : self.close,
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"on_help_clicked" : self.on_help_clicked,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2006-04-26 03:59:46 +05:30
|
|
|
window = self.glade.get_widget("top")
|
|
|
|
self.set_window(window,self.glade.get_widget('title'),
|
|
|
|
self.active_name)
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2004-05-11 05:20:30 +05:30
|
|
|
self.tree = self.glade.get_widget("tree1")
|
2002-12-25 04:06:46 +05:30
|
|
|
col = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0)
|
|
|
|
self.tree.append_column(col)
|
2005-02-24 05:55:34 +05:30
|
|
|
self.tree.set_rules_hint(True)
|
|
|
|
self.tree.set_headers_visible(False)
|
2002-12-25 04:06:46 +05:30
|
|
|
self.tree.connect('event',self.button_press_event)
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.make_new_model()
|
2002-12-25 04:06:46 +05:30
|
|
|
|
2006-04-26 03:59:46 +05:30
|
|
|
self.show()
|
2004-05-11 05:20:30 +05:30
|
|
|
|
2006-04-26 03:59:46 +05:30
|
|
|
def build_menu_names(self,obj):
|
|
|
|
return (self.active_name,_("Descendant Browser tool"))
|
2006-04-22 10:18:40 +05:30
|
|
|
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
def make_new_model(self):
|
2006-04-19 00:40:13 +05:30
|
|
|
self.model = gtk.TreeStore(str, object)
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.tree.set_model(self.model)
|
2006-04-19 00:40:13 +05:30
|
|
|
self.add_to_tree(None, None, self.active.get_handle())
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.tree.expand_all()
|
|
|
|
|
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-13 07:37:16 +05:30
|
|
|
GrampsDisplay.help('tools-ae')
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
|
2006-04-19 00:40:13 +05:30
|
|
|
def add_to_tree(self, parent_id, sib_id, person_handle):
|
|
|
|
item_id = self.model.insert_after(parent_id, sib_id)
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_handle(person_handle)
|
2006-04-19 00:40:13 +05:30
|
|
|
|
|
|
|
self.model.set(item_id, 0, NameDisplay.displayer.display(person))
|
|
|
|
self.model.set(item_id, 1, person_handle)
|
2004-05-11 05:20:30 +05:30
|
|
|
prev_id = None
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2006-04-19 00:40:13 +05:30
|
|
|
for child_ref in family.get_child_ref_list():
|
|
|
|
prev_id = self.add_to_tree(item_id, prev_id, child_ref.ref)
|
2004-05-11 05:20:30 +05:30
|
|
|
return item_id
|
2002-12-25 04:06:46 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def button_press_event(self,obj,event):
|
2006-04-19 00:40:13 +05:30
|
|
|
from Editors import EditPerson
|
2002-12-25 04:06:46 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
2006-04-19 00:40:13 +05:30
|
|
|
store, node = self.tree.get_selection().get_selected()
|
2002-12-25 04:06:46 +05:30
|
|
|
if iter:
|
2006-04-19 00:40:13 +05:30
|
|
|
person_handle = store.get_value(node, 1)
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_handle(person_handle)
|
2006-04-22 10:18:40 +05:30
|
|
|
EditPerson(self.dbstate, self.uistate, self.track, person,
|
|
|
|
self.this_callback)
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
|
2006-04-19 00:40:13 +05:30
|
|
|
def this_callback(self, epo, val):
|
|
|
|
self.callback(epo, val)
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.make_new_model()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class DesBrowseOptions(Tool.ToolOptions):
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,name,person_id=None):
|
|
|
|
Tool.ToolOptions.__init__(self,name,person_id)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
register_tool(
|
2005-12-06 12:08:09 +05:30
|
|
|
name = 'dbrowse',
|
|
|
|
category = Tool.TOOL_ANAL,
|
|
|
|
tool_class = DesBrowse,
|
|
|
|
options_class = DesBrowseOptions,
|
|
|
|
modes = Tool.MODE_GUI,
|
|
|
|
translated_name = _("Interactive descendant browser"),
|
|
|
|
status = _("Stable"),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
2003-02-24 10:21:57 +05:30
|
|
|
description=_("Provides a browsable hierarchy based on the active person"),
|
2002-10-20 19:55:16 +05:30
|
|
|
)
|