2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2010-05-01 09:42:42 +05:30
|
|
|
# Copyright (C) 2010 Jakim Friant
|
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$
|
|
|
|
|
2008-01-29 13:10:35 +05:30
|
|
|
"""Tools/Analysis and Exploration/Interactive Descendant Browser"""
|
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
|
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
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-02-26 15:38:38 +05:30
|
|
|
import const
|
2010-01-14 09:38:04 +05:30
|
|
|
from gen.display.name import displayer as name_displayer
|
2010-05-01 09:42:42 +05:30
|
|
|
from gui.plug import tool
|
2005-12-13 07:37:16 +05:30
|
|
|
import GrampsDisplay
|
2006-04-19 00:40:13 +05:30
|
|
|
import ManagedWindow
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import sgettext as _
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2009-12-15 11:26:12 +05:30
|
|
|
from gui.editors import EditPerson
|
2009-05-15 01:45:59 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2008-03-03 14:29:52 +05:30
|
|
|
# Constants
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-02-26 15:38:38 +05:30
|
|
|
WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE
|
2008-10-12 00:02:47 +05:30
|
|
|
WIKI_HELP_SEC = _('manual|Interactive_Descendant_Browser...')
|
2008-03-03 14:29:52 +05:30
|
|
|
|
2010-05-01 09:42:42 +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
|
|
|
|
2010-05-01 09:42:42 +05:30
|
|
|
tool.ActivePersonTool.__init__(self, dbstate, uistate, options_class,
|
2010-01-11 00:49:33 +05:30
|
|
|
name)
|
2006-04-22 10:18:40 +05:30
|
|
|
if self.fail:
|
|
|
|
return
|
2006-10-18 08:22:55 +05:30
|
|
|
|
2006-04-22 10:18:40 +05:30
|
|
|
self.dbstate = dbstate
|
2010-01-11 00:49:33 +05:30
|
|
|
active_handle = uistate.get_active('Person')
|
|
|
|
self.active = dbstate.db.get_person_from_handle(active_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.callback = callback
|
2011-01-24 21:57:23 +05:30
|
|
|
self.active_name = _("Descendant Browser: %s") % (
|
|
|
|
name_displayer.display(self.active)
|
|
|
|
)
|
2006-04-26 03:59:46 +05:30
|
|
|
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.glade = Glade()
|
2009-04-09 20:42:35 +05:30
|
|
|
self.glade.connect_signals({
|
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,
|
2010-01-07 19:40:26 +05:30
|
|
|
"on_delete_event" : self.close,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
window = self.glade.toplevel
|
2009-04-09 20:42:35 +05:30
|
|
|
self.set_window(window,self.glade.get_object('title'),
|
2006-04-26 03:59:46 +05:30
|
|
|
self.active_name)
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2009-04-09 20:42:35 +05:30
|
|
|
self.tree = self.glade.get_object("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
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2006-04-26 03:59:46 +05:30
|
|
|
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()
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_help_clicked(self, obj):
|
* 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
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2008-04-05 19:47:15 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
* 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
|
|
|
|
2007-06-28 11:11:40 +05:30
|
|
|
self.model.set(item_id, 0, name_displayer.display(person))
|
2006-04-19 00:40:13 +05:30
|
|
|
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
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def button_press_event(self, obj,event):
|
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()
|
2006-12-19 03:55:19 +05:30
|
|
|
if node:
|
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-10-18 08:22:55 +05:30
|
|
|
def this_callback(self, obj):
|
|
|
|
self.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
|
|
|
self.make_new_model()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2010-05-01 09:42:42 +05:30
|
|
|
class DesBrowseOptions(tool.ToolOptions):
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self, name,person_id=None):
|
2010-05-01 09:42:42 +05:30
|
|
|
tool.ToolOptions.__init__(self, name,person_id)
|