2008-04-20 10:22:53 +05:30
|
|
|
|
2006-10-31 23:06:38 +05:30
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2001-2007 Donald N. Allingham
|
2006-10-31 23:06:38 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
"""
|
|
|
|
Relationship View
|
|
|
|
"""
|
|
|
|
|
2005-02-16 19:19:32 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-11-08 21:06:35 +05:30
|
|
|
from TransUtils import sgettext as _
|
2009-01-31 16:59:44 +05:30
|
|
|
from gettext import ngettext
|
2006-01-05 00:26:06 +05:30
|
|
|
import cgi
|
2005-02-16 19:19:32 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
2009-01-06 04:09:40 +05:30
|
|
|
import pango
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2005-12-05 10:24:40 +05:30
|
|
|
# Gramps Modules
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2005-12-05 10:24:40 +05:30
|
|
|
import PageView
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2009-01-01 06:28:18 +05:30
|
|
|
from Utils import media_path_full, probably_alive
|
2006-01-04 11:09:39 +05:30
|
|
|
import DateHandler
|
2007-09-11 03:44:33 +05:30
|
|
|
import ThumbNails
|
2006-03-03 05:40:52 +05:30
|
|
|
import Config
|
2008-05-09 01:10:56 +05:30
|
|
|
import widgets
|
2006-03-01 10:38:11 +05:30
|
|
|
import Errors
|
2007-10-08 09:32:34 +05:30
|
|
|
import gen.utils
|
2006-04-22 08:53:57 +05:30
|
|
|
|
2006-05-31 07:33:29 +05:30
|
|
|
from ReportBase import ReportUtils
|
2006-01-05 10:42:48 +05:30
|
|
|
|
2006-01-07 03:38:40 +05:30
|
|
|
_GenderCode = {
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.Person.MALE : u'\u2642',
|
|
|
|
gen.lib.Person.FEMALE : u'\u2640',
|
|
|
|
gen.lib.Person.UNKNOWN : u'\u2650',
|
2006-01-07 03:38:40 +05:30
|
|
|
}
|
|
|
|
|
2006-01-11 00:40:39 +05:30
|
|
|
_NAME_START = 0
|
2007-09-09 03:36:30 +05:30
|
|
|
_LABEL_START = 0
|
|
|
|
_LABEL_STOP = 1
|
2006-01-11 00:40:39 +05:30
|
|
|
_DATA_START = _LABEL_STOP
|
|
|
|
_DATA_STOP = _DATA_START+1
|
|
|
|
_BTN_START = _DATA_STOP
|
|
|
|
_BTN_STOP = _BTN_START+2
|
2007-09-09 03:36:30 +05:30
|
|
|
_PLABEL_START = 1
|
2006-01-11 00:40:39 +05:30
|
|
|
_PLABEL_STOP = _PLABEL_START+1
|
|
|
|
_PDATA_START = _PLABEL_STOP
|
|
|
|
_PDATA_STOP = _PDATA_START+2
|
|
|
|
_PDTLS_START = _PLABEL_STOP
|
|
|
|
_PDTLS_STOP = _PDTLS_START+2
|
|
|
|
_CLABEL_START = _PLABEL_START+1
|
|
|
|
_CLABEL_STOP = _CLABEL_START+1
|
|
|
|
_CDATA_START = _CLABEL_STOP
|
|
|
|
_CDATA_STOP = _CDATA_START+1
|
|
|
|
_CDTLS_START = _CDATA_START
|
|
|
|
_CDTLS_STOP = _CDTLS_START+1
|
2007-09-09 03:36:30 +05:30
|
|
|
_ALABEL_START = 0
|
2006-01-11 00:40:39 +05:30
|
|
|
_ALABEL_STOP = _ALABEL_START+1
|
|
|
|
_ADATA_START = _ALABEL_STOP
|
|
|
|
_ADATA_STOP = _ADATA_START+3
|
2007-09-09 03:36:30 +05:30
|
|
|
_SDATA_START = 2
|
|
|
|
_SDATA_STOP = 4
|
2007-10-02 02:20:36 +05:30
|
|
|
_RETURN = gtk.gdk.keyval_from_name("Return")
|
|
|
|
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
|
2008-02-23 03:39:39 +05:30
|
|
|
_LEFT_BUTTON = 1
|
|
|
|
_RIGHT_BUTTON = 3
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2009-05-21 22:49:50 +05:30
|
|
|
class AttachList(object):
|
2006-01-08 06:55:04 +05:30
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.list = []
|
|
|
|
self.max_x = 0
|
|
|
|
self.max_y = 0
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def attach(self, widget, x0, x1, y0, y1, xoptions=gtk.EXPAND|gtk.FILL,
|
2006-01-08 06:55:04 +05:30
|
|
|
yoptions=gtk.EXPAND|gtk.FILL):
|
2006-05-24 01:16:02 +05:30
|
|
|
assert(widget)
|
2006-01-11 00:40:39 +05:30
|
|
|
assert(x1>x0)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.list.append((widget, x0, x1, y0, y1, xoptions, yoptions))
|
|
|
|
self.max_x = max(self.max_x, x1)
|
|
|
|
self.max_y = max(self.max_y, y1)
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2006-05-24 01:16:02 +05:30
|
|
|
class RelationshipView(PageView.PersonNavView):
|
2005-12-05 10:24:40 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def __init__(self, dbstate, uistate):
|
|
|
|
|
2006-04-23 03:39:16 +05:30
|
|
|
PageView.PersonNavView.__init__(
|
|
|
|
self, _('Relationships'), dbstate, uistate)
|
2006-04-10 04:23:53 +05:30
|
|
|
|
2007-01-26 05:45:21 +05:30
|
|
|
self.func_list = {
|
|
|
|
'<CONTROL>J' : self.jump,
|
|
|
|
}
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
dbstate.connect('database-changed', self.change_db)
|
2006-04-25 02:34:01 +05:30
|
|
|
self.show_siblings = Config.get(Config.FAMILY_SIBLINGS)
|
|
|
|
self.show_details = Config.get(Config.FAMILY_DETAILS)
|
2006-03-08 05:19:26 +05:30
|
|
|
self.connect_to_db(dbstate.db)
|
2006-03-08 02:48:21 +05:30
|
|
|
self.redrawing = False
|
2006-05-24 10:19:05 +05:30
|
|
|
self.use_shade = Config.get(Config.RELATION_SHADE)
|
2006-12-01 21:47:26 +05:30
|
|
|
self.toolbar_visible = Config.get(Config.TOOLBAR_ON)
|
2007-04-18 07:42:40 +05:30
|
|
|
|
2006-05-23 22:03:42 +05:30
|
|
|
self.color = gtk.TextView().style.white
|
2006-03-08 02:48:21 +05:30
|
|
|
self.child = None
|
2009-08-04 22:27:56 +05:30
|
|
|
self.old_handle = None
|
2007-04-18 07:42:40 +05:30
|
|
|
|
2006-05-24 10:19:05 +05:30
|
|
|
Config.client.notify_add("/apps/gramps/preferences/relation-shade",
|
|
|
|
self.shade_update)
|
2007-09-09 03:36:30 +05:30
|
|
|
Config.client.notify_add("/apps/gramps/interface/releditbtn",
|
2006-11-09 10:25:51 +05:30
|
|
|
self.config_update)
|
2006-12-01 21:47:26 +05:30
|
|
|
Config.client.notify_add("/apps/gramps/interface/toolbar-on",
|
|
|
|
self.shade_update)
|
2007-04-28 19:55:18 +05:30
|
|
|
self.reorder_sensitive = False
|
2007-09-09 03:36:30 +05:30
|
|
|
self.collapsed_items = {}
|
2006-05-24 10:19:05 +05:30
|
|
|
|
2006-08-04 19:21:44 +05:30
|
|
|
def set_active(self):
|
|
|
|
PageView.PersonNavView.set_active(self)
|
|
|
|
self.key_active_changed = self.dbstate.connect('active-changed',
|
|
|
|
self.redraw)
|
|
|
|
self.build_tree()
|
|
|
|
|
|
|
|
def set_inactive(self):
|
|
|
|
PageView.PersonNavView.set_inactive(self)
|
|
|
|
self.dbstate.disconnect(self.key_active_changed)
|
|
|
|
|
2006-05-24 10:19:05 +05:30
|
|
|
def shade_update(self, client, cnxn_id, entry, data):
|
|
|
|
self.use_shade = Config.get(Config.RELATION_SHADE)
|
2006-12-01 21:47:26 +05:30
|
|
|
self.toolbar_visible = Config.get(Config.TOOLBAR_ON)
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
self.uistate.modify_statusbar(self.dbstate)
|
2006-05-24 10:19:05 +05:30
|
|
|
self.redraw()
|
2006-04-18 07:39:43 +05:30
|
|
|
|
2006-11-09 10:25:51 +05:30
|
|
|
def config_update(self, client, cnxn_id, entry, data):
|
|
|
|
self.redraw()
|
|
|
|
|
2006-04-18 07:39:43 +05:30
|
|
|
def build_tree(self):
|
2006-06-20 09:55:44 +05:30
|
|
|
self.redraw()
|
2006-03-08 02:48:21 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def connect_to_db(self, db):
|
2008-01-01 00:53:16 +05:30
|
|
|
# Add a signal to pick up event changes, bug #1416
|
|
|
|
db.connect('event-update', self.family_update)
|
|
|
|
|
2006-03-08 05:19:26 +05:30
|
|
|
db.connect('person-update', self.person_update)
|
2006-04-08 11:26:31 +05:30
|
|
|
db.connect('person-rebuild', self.person_rebuild)
|
2006-03-08 05:19:26 +05:30
|
|
|
db.connect('family-update', self.family_update)
|
|
|
|
db.connect('family-add', self.family_add)
|
|
|
|
db.connect('family-delete', self.family_delete)
|
2006-04-08 11:26:31 +05:30
|
|
|
db.connect('family-rebuild', self.family_rebuild)
|
2006-03-08 05:19:26 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def person_update(self, handle_list):
|
2006-03-08 05:19:26 +05:30
|
|
|
if self.dbstate.active:
|
2006-03-10 04:07:19 +05:30
|
|
|
while not self.change_person(self.dbstate.active.handle):
|
|
|
|
pass
|
2006-04-18 07:39:43 +05:30
|
|
|
else:
|
2006-06-20 08:20:38 +05:30
|
|
|
self.change_person(None)
|
2006-03-08 05:19:26 +05:30
|
|
|
|
|
|
|
def person_rebuild(self):
|
2007-10-03 22:04:51 +05:30
|
|
|
"""Large change to person database"""
|
|
|
|
if self.active:
|
|
|
|
self.bookmarks.redraw()
|
2006-03-08 05:19:26 +05:30
|
|
|
if self.dbstate.active:
|
2006-03-10 04:07:19 +05:30
|
|
|
while not self.change_person(self.dbstate.active.handle):
|
|
|
|
pass
|
2006-04-18 07:39:43 +05:30
|
|
|
else:
|
2006-06-20 08:20:38 +05:30
|
|
|
self.change_person(None)
|
2006-03-08 05:19:26 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def family_update(self, handle_list):
|
2006-03-08 05:19:26 +05:30
|
|
|
if self.dbstate.active:
|
2006-03-10 04:07:19 +05:30
|
|
|
while not self.change_person(self.dbstate.active.handle):
|
|
|
|
pass
|
2006-04-18 07:39:43 +05:30
|
|
|
else:
|
2006-06-20 08:20:38 +05:30
|
|
|
self.change_person(None)
|
2006-03-08 05:19:26 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def family_add(self, handle_list):
|
2006-03-08 05:19:26 +05:30
|
|
|
if self.dbstate.active:
|
2006-03-10 04:07:19 +05:30
|
|
|
while not self.change_person(self.dbstate.active.handle):
|
|
|
|
pass
|
2006-04-18 07:39:43 +05:30
|
|
|
else:
|
2006-06-20 08:20:38 +05:30
|
|
|
self.change_person(None)
|
2006-03-08 05:19:26 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def family_delete(self, handle_list):
|
2006-03-08 05:19:26 +05:30
|
|
|
if self.dbstate.active:
|
2006-03-10 04:07:19 +05:30
|
|
|
while not self.change_person(self.dbstate.active.handle):
|
|
|
|
pass
|
2006-04-18 07:39:43 +05:30
|
|
|
else:
|
2006-06-20 08:20:38 +05:30
|
|
|
self.change_person(None)
|
2006-03-08 05:19:26 +05:30
|
|
|
|
|
|
|
def family_rebuild(self):
|
|
|
|
if self.dbstate.active:
|
2006-03-10 04:07:19 +05:30
|
|
|
while not self.change_person(self.dbstate.active.handle):
|
|
|
|
pass
|
2006-04-18 07:39:43 +05:30
|
|
|
else:
|
2006-06-20 08:20:38 +05:30
|
|
|
self.change_person(None)
|
2007-04-02 04:07:10 +05:30
|
|
|
|
|
|
|
def change_page(self):
|
|
|
|
self.uistate.clear_filter_results()
|
2006-03-10 04:07:19 +05:30
|
|
|
|
2005-12-05 10:24:40 +05:30
|
|
|
def get_stock(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the name of the stock icon to use for the display.
|
2005-12-05 10:24:40 +05:30
|
|
|
This assumes that this icon has already been registered with
|
|
|
|
GNOME as a stock icon.
|
|
|
|
"""
|
2007-02-21 01:28:47 +05:30
|
|
|
return 'gramps-relation'
|
2005-12-05 10:24:40 +05:30
|
|
|
|
|
|
|
def build_widget(self):
|
2006-11-09 11:22:49 +05:30
|
|
|
|
|
|
|
container = gtk.VBox()
|
|
|
|
container.set_border_width(12)
|
|
|
|
|
2006-01-04 03:37:34 +05:30
|
|
|
self.vbox = gtk.VBox()
|
|
|
|
self.vbox.show()
|
2006-11-09 11:22:49 +05:30
|
|
|
|
|
|
|
self.header = gtk.VBox()
|
|
|
|
self.header.show()
|
|
|
|
|
2006-01-04 03:37:34 +05:30
|
|
|
self.child = None
|
2006-11-09 11:22:49 +05:30
|
|
|
|
2007-10-08 01:46:51 +05:30
|
|
|
self.scroll = gtk.ScrolledWindow()
|
|
|
|
self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
self.scroll.show()
|
2006-11-09 11:22:49 +05:30
|
|
|
|
|
|
|
vp = gtk.Viewport()
|
|
|
|
vp.set_shadow_type(gtk.SHADOW_NONE)
|
|
|
|
vp.add(self.vbox)
|
|
|
|
|
2007-10-08 01:46:51 +05:30
|
|
|
self.scroll.add(vp)
|
|
|
|
self.scroll.show_all()
|
2006-11-09 11:22:49 +05:30
|
|
|
|
|
|
|
container.set_spacing(6)
|
|
|
|
container.pack_start(self.header, False, False)
|
|
|
|
container.pack_start(gtk.HSeparator(), False, False)
|
2007-10-08 01:46:51 +05:30
|
|
|
container.add(self.scroll)
|
2006-11-09 11:22:49 +05:30
|
|
|
container.show_all()
|
|
|
|
return container
|
2005-12-05 10:24:40 +05:30
|
|
|
|
|
|
|
def ui_definition(self):
|
|
|
|
"""
|
|
|
|
Specifies the UIManager XML code that defines the menus and buttons
|
|
|
|
associated with the interface.
|
|
|
|
"""
|
|
|
|
return '''<ui>
|
2006-01-05 00:26:06 +05:30
|
|
|
<menubar name="MenuBar">
|
|
|
|
<menu action="GoMenu">
|
|
|
|
<placeholder name="CommonGo">
|
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
|
|
|
<separator/>
|
|
|
|
<menuitem action="HomePerson"/>
|
|
|
|
<separator/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2006-07-03 07:58:44 +05:30
|
|
|
<menu action="EditMenu">
|
2006-12-30 23:19:08 +05:30
|
|
|
<menuitem action="Edit"/>
|
2008-01-18 02:05:18 +05:30
|
|
|
<menuitem action="AddParentsMenu"/>
|
|
|
|
<menuitem action="ShareFamilyMenu"/>
|
|
|
|
<menuitem action="AddSpouseMenu"/>
|
2006-10-31 23:06:38 +05:30
|
|
|
<menuitem action="ChangeOrder"/>
|
2006-07-03 07:58:44 +05:30
|
|
|
<menuitem action="FilterEdit"/>
|
|
|
|
</menu>
|
2006-04-27 03:18:13 +05:30
|
|
|
<menu action="BookMenu">
|
|
|
|
<placeholder name="AddEditBook">
|
|
|
|
<menuitem action="AddBook"/>
|
|
|
|
<menuitem action="EditBook"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2006-01-06 10:38:51 +05:30
|
|
|
<menu action="ViewMenu">
|
|
|
|
<menuitem action="Siblings"/>
|
|
|
|
<menuitem action="Details"/>
|
|
|
|
</menu>
|
2006-01-05 00:26:06 +05:30
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
|
|
|
<placeholder name="CommonNavigation">
|
|
|
|
<toolitem action="Back"/>
|
|
|
|
<toolitem action="Forward"/>
|
|
|
|
<toolitem action="HomePerson"/>
|
|
|
|
</placeholder>
|
2006-10-31 23:06:38 +05:30
|
|
|
<placeholder name="CommonEdit">
|
2006-12-30 23:19:08 +05:30
|
|
|
<toolitem action="Edit"/>
|
2006-11-09 09:48:18 +05:30
|
|
|
<toolitem action="AddParents"/>
|
2006-11-17 10:47:13 +05:30
|
|
|
<toolitem action="ShareFamily"/>
|
2006-11-09 09:48:18 +05:30
|
|
|
<toolitem action="AddSpouse"/>
|
2006-10-31 23:06:38 +05:30
|
|
|
<toolitem action="ChangeOrder"/>
|
|
|
|
</placeholder>
|
2006-01-05 00:26:06 +05:30
|
|
|
</toolbar>
|
|
|
|
<popup name="Popup">
|
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
|
|
|
<menuitem action="HomePerson"/>
|
|
|
|
<separator/>
|
|
|
|
</popup>
|
2005-12-05 10:24:40 +05:30
|
|
|
</ui>'''
|
2004-11-19 06:44:37 +05:30
|
|
|
|
2006-01-05 00:26:06 +05:30
|
|
|
def define_actions(self):
|
|
|
|
PageView.PersonNavView.define_actions(self)
|
|
|
|
|
2006-11-01 01:14:45 +05:30
|
|
|
self.order_action = gtk.ActionGroup(self.title + '/ChangeOrder')
|
|
|
|
self.order_action.add_actions([
|
|
|
|
('ChangeOrder', gtk.STOCK_SORT_ASCENDING, _('_Reorder'), None ,
|
2007-11-23 14:35:04 +05:30
|
|
|
_("Change order of parents and families"), self.reorder),
|
2006-11-01 01:14:45 +05:30
|
|
|
])
|
2006-11-09 09:48:18 +05:30
|
|
|
|
|
|
|
self.family_action = gtk.ActionGroup(self.title + '/Family')
|
|
|
|
self.family_action.add_actions([
|
2008-01-29 02:52:06 +05:30
|
|
|
('Edit', gtk.STOCK_EDIT, _('Edit...'), "<control>Return",
|
2007-11-23 14:35:04 +05:30
|
|
|
_("Edit the active person"), self.edit_active),
|
2008-01-18 02:05:18 +05:30
|
|
|
('AddSpouse', 'gramps-spouse', _('Partner'), None ,
|
2007-11-23 14:35:04 +05:30
|
|
|
_("Add a new family with person as parent"), self.add_spouse),
|
2008-01-29 02:52:06 +05:30
|
|
|
('AddSpouseMenu', 'gramps-spouse', _('Add Partner...'), None ,
|
2008-01-18 02:05:18 +05:30
|
|
|
_("Add a new family with person as parent"), self.add_spouse),
|
|
|
|
('AddParents', 'gramps-parents-add', _('Add'), None ,
|
2007-11-23 14:35:04 +05:30
|
|
|
_("Add a new set of parents"), self.add_parents),
|
2008-01-29 02:52:06 +05:30
|
|
|
('AddParentsMenu', 'gramps-parents-add', _('Add New Parents...'),
|
2008-01-18 02:05:18 +05:30
|
|
|
None, _("Add a new set of parents"), self.add_parents),
|
|
|
|
('ShareFamily', 'gramps-parents-open', _('Share'),
|
2007-11-23 14:35:04 +05:30
|
|
|
None , _("Add person as child to an existing family"),
|
|
|
|
self.select_parents),
|
2008-01-18 02:05:18 +05:30
|
|
|
('ShareFamilyMenu', 'gramps-parents-open',
|
2008-01-29 02:52:06 +05:30
|
|
|
_('Add Existing Parents...'), None ,
|
2008-01-18 02:05:18 +05:30
|
|
|
_("Add person as child to an existing family"),
|
|
|
|
self.select_parents),
|
2006-11-09 09:48:18 +05:30
|
|
|
])
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action_group(self.order_action)
|
|
|
|
self._add_action_group(self.family_action)
|
2006-10-31 23:06:38 +05:30
|
|
|
|
2008-01-29 02:52:06 +05:30
|
|
|
self._add_toggle_action('Details', None, _('Show Details'),
|
2007-09-13 09:50:24 +05:30
|
|
|
None, None, self.details_toggle,
|
|
|
|
self.show_details)
|
2008-01-29 02:52:06 +05:30
|
|
|
self._add_toggle_action('Siblings', None, _('Show Siblings'),
|
2007-09-13 09:50:24 +05:30
|
|
|
None, None, self.siblings_toggle,
|
|
|
|
self.show_siblings)
|
2006-01-06 10:38:51 +05:30
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
self.order_action.set_sensitive(self.reorder_sensitive)
|
2007-02-05 03:10:27 +05:30
|
|
|
self.family_action.set_sensitive(False)
|
2006-12-05 05:23:19 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def siblings_toggle(self, obj):
|
2006-01-06 10:38:51 +05:30
|
|
|
self.show_siblings = obj.get_active()
|
|
|
|
self.change_person(self.dbstate.active.handle)
|
2007-01-09 10:02:07 +05:30
|
|
|
Config.set(Config.FAMILY_SIBLINGS, self.show_siblings)
|
2006-01-06 10:38:51 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def details_toggle(self, obj):
|
2006-01-06 10:38:51 +05:30
|
|
|
self.show_details = obj.get_active()
|
|
|
|
self.change_person(self.dbstate.active.handle)
|
2007-01-09 10:02:07 +05:30
|
|
|
Config.set(Config.FAMILY_DETAILS, self.show_details)
|
2006-01-06 10:38:51 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def change_db(self, db):
|
2006-03-08 05:19:26 +05:30
|
|
|
self.connect_to_db(db)
|
2006-01-05 10:42:48 +05:30
|
|
|
if self.child:
|
2006-06-17 09:50:27 +05:30
|
|
|
for old_child in self.vbox.get_children():
|
|
|
|
self.vbox.remove(old_child)
|
2006-12-03 10:50:15 +05:30
|
|
|
for old_child in self.header.get_children():
|
|
|
|
self.header.remove(old_child)
|
2006-01-05 10:42:48 +05:30
|
|
|
self.child = None
|
2006-04-08 11:26:31 +05:30
|
|
|
self.dbstate.db.connect('family-update', self.redraw)
|
|
|
|
self.dbstate.db.connect('family-add', self.redraw)
|
|
|
|
self.dbstate.db.connect('family-delete', self.redraw)
|
|
|
|
self.dbstate.db.connect('person-update', self.redraw)
|
|
|
|
self.dbstate.db.connect('person-add', self.redraw)
|
|
|
|
self.dbstate.db.connect('person-delete', self.redraw)
|
2006-04-27 03:18:13 +05:30
|
|
|
self.bookmarks.update_bookmarks(db.get_bookmarks())
|
2007-10-03 22:04:51 +05:30
|
|
|
if self.active:
|
|
|
|
self.bookmarks.redraw()
|
2006-06-17 09:50:27 +05:30
|
|
|
self.redraw()
|
2006-04-08 11:26:31 +05:30
|
|
|
|
|
|
|
def get_name(self, handle, use_gender=False):
|
2006-01-04 03:37:34 +05:30
|
|
|
if handle:
|
2007-01-09 10:02:07 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
2007-06-28 11:11:40 +05:30
|
|
|
name = name_displayer.display(person)
|
2006-01-06 04:30:59 +05:30
|
|
|
if use_gender:
|
2007-01-09 10:02:07 +05:30
|
|
|
gender = _GenderCode[person.gender]
|
2006-01-07 03:38:40 +05:30
|
|
|
else:
|
|
|
|
gender = ""
|
2006-04-08 11:26:31 +05:30
|
|
|
return (name, gender)
|
2006-01-04 03:37:34 +05:30
|
|
|
else:
|
2006-04-08 11:26:31 +05:30
|
|
|
return (_(u"Unknown"), "")
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def redraw(self, *obj):
|
2006-03-08 02:48:21 +05:30
|
|
|
if self.dbstate.active:
|
2006-05-14 08:07:15 +05:30
|
|
|
self.handle_history(self.dbstate.active.handle)
|
2006-03-08 02:48:21 +05:30
|
|
|
self.change_person(self.dbstate.active.handle)
|
2006-06-20 08:20:38 +05:30
|
|
|
else:
|
|
|
|
self.change_person(None)
|
2006-03-08 02:48:21 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def change_person(self, obj):
|
2006-12-11 09:40:46 +05:30
|
|
|
try:
|
2006-12-11 19:15:01 +05:30
|
|
|
return self._change_person(obj)
|
2006-12-11 09:40:46 +05:30
|
|
|
except AttributeError, msg:
|
|
|
|
from QuestionDialog import RunDatabaseRepair
|
|
|
|
RunDatabaseRepair(msg)
|
2006-12-11 19:15:01 +05:30
|
|
|
return True
|
2006-12-11 09:40:46 +05:30
|
|
|
|
|
|
|
def _change_person(self, obj):
|
2009-08-04 22:27:56 +05:30
|
|
|
if obj == self.old_handle:
|
|
|
|
#same object, keep present scroll position
|
|
|
|
old_vadjust = self.scroll.get_vadjustment().value
|
|
|
|
self.old_handle = obj
|
|
|
|
else:
|
|
|
|
#different object, scroll to top
|
|
|
|
old_vadjust = self.scroll.get_vadjustment().lower
|
|
|
|
self.old_handle = obj
|
2007-10-08 01:46:51 +05:30
|
|
|
self.scroll.get_vadjustment().value = \
|
|
|
|
self.scroll.get_vadjustment().lower
|
2006-03-08 02:48:21 +05:30
|
|
|
if self.redrawing:
|
2006-03-10 04:07:19 +05:30
|
|
|
return False
|
2006-03-08 02:48:21 +05:30
|
|
|
self.redrawing = True
|
2006-12-04 10:33:58 +05:30
|
|
|
self.tooltips = gtk.Tooltips()
|
2006-03-08 02:48:21 +05:30
|
|
|
|
2006-05-23 09:20:37 +05:30
|
|
|
for old_child in self.vbox.get_children():
|
|
|
|
self.vbox.remove(old_child)
|
2006-12-03 10:50:15 +05:30
|
|
|
for old_child in self.header.get_children():
|
|
|
|
self.header.remove(old_child)
|
2006-01-04 03:37:34 +05:30
|
|
|
|
|
|
|
person = self.dbstate.db.get_person_from_handle(obj)
|
2006-01-04 23:30:02 +05:30
|
|
|
if not person:
|
2006-12-03 10:50:15 +05:30
|
|
|
self.family_action.set_sensitive(False)
|
|
|
|
self.order_action.set_sensitive(False)
|
2006-03-08 02:48:21 +05:30
|
|
|
self.redrawing = False
|
2006-01-04 23:30:02 +05:30
|
|
|
return
|
2006-12-03 10:50:15 +05:30
|
|
|
self.family_action.set_sensitive(True)
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-05-23 09:20:37 +05:30
|
|
|
self.write_title(person)
|
|
|
|
|
|
|
|
self.attach = AttachList()
|
2006-11-09 11:22:49 +05:30
|
|
|
self.row = 0
|
2006-11-01 01:14:45 +05:30
|
|
|
|
2006-01-04 03:37:34 +05:30
|
|
|
family_handle_list = person.get_parent_family_handle_list()
|
2006-11-01 01:14:45 +05:30
|
|
|
|
2006-12-01 21:47:26 +05:30
|
|
|
self.reorder_sensitive = len(family_handle_list)> 1
|
2006-11-01 01:14:45 +05:30
|
|
|
|
2006-01-11 03:58:09 +05:30
|
|
|
if family_handle_list:
|
2006-04-13 16:51:33 +05:30
|
|
|
for family_handle in family_handle_list:
|
2006-01-11 03:58:09 +05:30
|
|
|
if family_handle:
|
2007-09-09 03:36:30 +05:30
|
|
|
self.write_parents(family_handle, person)
|
2006-01-11 03:58:09 +05:30
|
|
|
else:
|
2007-09-09 03:36:30 +05:30
|
|
|
self.write_label("%s:" % _('Parents'), None, True, person)
|
2006-01-11 03:58:09 +05:30
|
|
|
self.row += 1
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2006-01-04 03:37:34 +05:30
|
|
|
family_handle_list = person.get_family_handle_list()
|
2007-09-09 03:36:30 +05:30
|
|
|
|
2006-12-01 21:47:26 +05:30
|
|
|
if not self.reorder_sensitive:
|
|
|
|
self.reorder_sensitive = len(family_handle_list)> 1
|
2006-11-01 01:14:45 +05:30
|
|
|
|
2006-01-11 03:58:09 +05:30
|
|
|
if family_handle_list:
|
|
|
|
for family_handle in family_handle_list:
|
|
|
|
if family_handle:
|
2007-09-09 03:36:30 +05:30
|
|
|
self.write_family(family_handle, person)
|
2006-01-11 03:58:09 +05:30
|
|
|
else:
|
2007-09-09 03:36:30 +05:30
|
|
|
self.write_label("%s:" % _('Family'), None, False, person)
|
2006-01-11 03:58:09 +05:30
|
|
|
self.row += 1
|
2006-01-06 10:38:51 +05:30
|
|
|
|
2006-11-09 11:22:49 +05:30
|
|
|
self.row = 0
|
2006-01-08 06:55:04 +05:30
|
|
|
|
|
|
|
# Here it is necessary to beat GTK into submission. For some
|
2006-04-08 11:26:31 +05:30
|
|
|
# bizzare reason, if you have an empty column that is spanned,
|
2006-01-08 06:55:04 +05:30
|
|
|
# you lose the appropriate FILL handling. So, we need to see if
|
|
|
|
# column 3 is unused (usually if there is no siblings or children.
|
|
|
|
# If so, we need to subtract one index of each x coord > 3.
|
|
|
|
|
|
|
|
found = False
|
|
|
|
for d in self.attach.list:
|
2006-01-11 00:40:39 +05:30
|
|
|
if d[1] == 4 or d[2] == 4:
|
2006-01-08 06:55:04 +05:30
|
|
|
found = True
|
|
|
|
|
|
|
|
if found:
|
|
|
|
cols = self.attach.max_x
|
|
|
|
else:
|
|
|
|
cols = self.attach.max_x-1
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
self.child = gtk.Table(self.attach.max_y, cols)
|
2006-01-08 06:55:04 +05:30
|
|
|
self.child.set_border_width(12)
|
|
|
|
self.child.set_col_spacings(12)
|
2008-04-20 10:22:53 +05:30
|
|
|
self.child.set_row_spacings(0)
|
2006-01-08 06:55:04 +05:30
|
|
|
|
|
|
|
for d in self.attach.list:
|
|
|
|
x0 = d[1]
|
|
|
|
x1 = d[2]
|
|
|
|
if not found:
|
2006-01-11 00:40:39 +05:30
|
|
|
if x0 > 4:
|
2007-09-09 03:36:30 +05:30
|
|
|
x0 -= 1
|
2006-01-11 00:40:39 +05:30
|
|
|
if x1 > 4:
|
2006-01-08 06:55:04 +05:30
|
|
|
x1 -= 1
|
2006-04-08 11:26:31 +05:30
|
|
|
self.child.attach(d[0], x0, x1, d[3], d[4], d[5], d[6])
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2006-01-04 23:30:02 +05:30
|
|
|
self.child.show_all()
|
2006-03-08 02:48:21 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
self.vbox.pack_start(self.child, False)
|
2009-08-04 22:27:56 +05:30
|
|
|
#reset scroll position as it was before
|
|
|
|
self.scroll.get_vadjustment().value = old_vadjust
|
2006-03-08 02:48:21 +05:30
|
|
|
self.redrawing = False
|
2006-08-24 00:25:06 +05:30
|
|
|
self.uistate.modify_statusbar(self.dbstate)
|
2006-11-01 01:14:45 +05:30
|
|
|
|
2006-12-01 21:47:26 +05:30
|
|
|
self.order_action.set_sensitive(self.reorder_sensitive)
|
2006-11-01 01:14:45 +05:30
|
|
|
|
2006-03-10 04:07:19 +05:30
|
|
|
return True
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def write_title(self, person):
|
2006-01-05 00:26:06 +05:30
|
|
|
|
2006-11-09 11:22:49 +05:30
|
|
|
for old_child in self.header.get_children():
|
|
|
|
self.header.remove(old_child)
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
table = gtk.Table(2, 3)
|
2006-05-23 09:20:37 +05:30
|
|
|
table.set_col_spacings(12)
|
2008-04-20 10:22:53 +05:30
|
|
|
table.set_row_spacings(0)
|
2007-09-09 03:36:30 +05:30
|
|
|
|
2006-01-05 00:26:06 +05:30
|
|
|
# name and edit button
|
2007-06-28 11:11:40 +05:30
|
|
|
name = name_displayer.display(person)
|
2006-06-30 19:46:09 +05:30
|
|
|
fmt = '<span size="larger" weight="bold">%s</span>'
|
|
|
|
text = fmt % cgi.escape(name)
|
2008-05-09 01:10:56 +05:30
|
|
|
label = widgets.DualMarkupLabel(text, _GenderCode[person.gender],
|
|
|
|
x_align=1, y_align=0)
|
2006-11-08 10:45:26 +05:30
|
|
|
if Config.get(Config.RELEDITBTN):
|
2008-05-09 01:10:56 +05:30
|
|
|
button = widgets.IconButton(self.edit_button_press,
|
|
|
|
person.handle)
|
2007-01-09 10:02:07 +05:30
|
|
|
self.tooltips.set_tip(button, _('Edit %s') % name)
|
2006-11-08 10:45:26 +05:30
|
|
|
else:
|
|
|
|
button = None
|
2008-05-09 01:10:56 +05:30
|
|
|
hbox = widgets.LinkBox(label, button)
|
2006-05-23 09:20:37 +05:30
|
|
|
|
|
|
|
table.attach(hbox, 0, 2, 0, 1)
|
|
|
|
|
|
|
|
eventbox = gtk.EventBox()
|
2006-05-24 10:19:05 +05:30
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
2006-05-23 09:20:37 +05:30
|
|
|
table.attach(eventbox, 1, 2, 1, 2)
|
|
|
|
subtbl = gtk.Table(3, 3)
|
|
|
|
subtbl.set_col_spacings(12)
|
2008-04-20 10:22:53 +05:30
|
|
|
subtbl.set_row_spacings(0)
|
2006-05-23 09:20:37 +05:30
|
|
|
eventbox.add(subtbl)
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2006-01-05 00:26:06 +05:30
|
|
|
# GRAMPS ID
|
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel("%s:" % _('ID')),
|
2006-05-23 09:20:37 +05:30
|
|
|
1, 2, 0, 1, xoptions=gtk.FILL, yoptions=0)
|
2008-05-09 01:10:56 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel(person.gramps_id),
|
2006-05-23 09:20:37 +05:30
|
|
|
2, 3, 0, 1, yoptions=0)
|
2006-01-05 00:26:06 +05:30
|
|
|
|
2006-05-23 09:20:37 +05:30
|
|
|
# Birth event.
|
2007-01-09 10:02:07 +05:30
|
|
|
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
|
2006-11-23 04:00:47 +05:30
|
|
|
if birth:
|
|
|
|
birth_title = birth.get_type()
|
2006-01-05 00:26:06 +05:30
|
|
|
else:
|
2006-11-30 01:10:43 +05:30
|
|
|
birth_title = _("Birth")
|
2006-11-07 17:35:40 +05:30
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel("%s:" % birth_title),
|
2006-05-23 09:20:37 +05:30
|
|
|
1, 2, 1, 2, xoptions=gtk.FILL, yoptions=0)
|
2008-05-09 01:10:56 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel(self.format_event(birth)),
|
2006-05-23 09:20:37 +05:30
|
|
|
2, 3, 1, 2, yoptions=0)
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
|
2006-11-23 04:00:47 +05:30
|
|
|
if death:
|
|
|
|
death_title = death.get_type()
|
2006-01-05 00:26:06 +05:30
|
|
|
else:
|
2006-11-30 01:10:43 +05:30
|
|
|
death_title = _("Death")
|
2006-11-07 17:35:40 +05:30
|
|
|
|
2008-12-14 20:22:54 +05:30
|
|
|
showed_death = False
|
|
|
|
if birth:
|
|
|
|
birth_date = birth.get_date_object()
|
|
|
|
if (birth_date and birth_date.get_valid()):
|
|
|
|
if death:
|
|
|
|
death_date = death.get_date_object()
|
|
|
|
if (death_date and death_date.get_valid()):
|
|
|
|
age = death_date - birth_date
|
|
|
|
subtbl.attach(widgets.BasicLabel("%s:" % death_title),
|
|
|
|
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
|
2009-01-01 06:28:18 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel("%s (%s)" %
|
2009-01-06 04:09:40 +05:30
|
|
|
(self.format_event(death), age),
|
|
|
|
pango.ELLIPSIZE_END),
|
2008-12-14 20:22:54 +05:30
|
|
|
2, 3, 2, 3, yoptions=0)
|
|
|
|
showed_death = True
|
|
|
|
if not showed_death:
|
|
|
|
age = gen.lib.date.Today() - birth_date
|
2009-01-01 06:28:18 +05:30
|
|
|
if probably_alive(person, self.dbstate.db):
|
|
|
|
subtbl.attach(widgets.BasicLabel("%s:" % _("Alive")),
|
|
|
|
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
|
2009-01-06 04:09:40 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel("(%s)" % age, pango.ELLIPSIZE_END),
|
2009-01-01 06:28:18 +05:30
|
|
|
2, 3, 2, 3, yoptions=0)
|
|
|
|
else:
|
|
|
|
subtbl.attach(widgets.BasicLabel("%s:" % _("Death")),
|
|
|
|
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
|
2009-01-06 04:09:40 +05:30
|
|
|
subtbl.attach(widgets.BasicLabel("%s (%s)" % (_("unknown"), age),
|
|
|
|
pango.ELLIPSIZE_END),
|
2009-01-01 06:28:18 +05:30
|
|
|
2, 3, 2, 3, yoptions=0)
|
2008-12-14 20:22:54 +05:30
|
|
|
showed_death = True
|
|
|
|
|
|
|
|
if not showed_death:
|
|
|
|
subtbl.attach(widgets.BasicLabel("%s:" % death_title),
|
|
|
|
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
|
|
|
|
subtbl.attach(widgets.BasicLabel(self.format_event(death)),
|
|
|
|
2, 3, 2, 3, yoptions=0)
|
2006-05-23 09:20:37 +05:30
|
|
|
|
|
|
|
mbox = gtk.HBox()
|
|
|
|
mbox.add(table)
|
2006-01-04 11:09:39 +05:30
|
|
|
|
2006-01-08 06:55:04 +05:30
|
|
|
# image
|
|
|
|
image_list = person.get_media_list()
|
|
|
|
if image_list:
|
|
|
|
mobj = self.dbstate.db.get_object_from_handle(image_list[0].ref)
|
2007-10-06 18:28:11 +05:30
|
|
|
if mobj and mobj.get_mime_type()[0:5] == "image":
|
2008-02-18 19:36:41 +05:30
|
|
|
pixbuf = ThumbNails.get_thumbnail_image(
|
|
|
|
media_path_full(self.dbstate.db,
|
|
|
|
mobj.get_path()),
|
|
|
|
rectangle=image_list[0].get_rectangle())
|
2006-01-08 06:55:04 +05:30
|
|
|
image = gtk.Image()
|
|
|
|
image.set_from_pixbuf(pixbuf)
|
|
|
|
image.show()
|
2007-01-09 10:02:07 +05:30
|
|
|
mbox.pack_end(image, False)
|
2006-05-23 09:20:37 +05:30
|
|
|
|
|
|
|
mbox.show_all()
|
2007-01-09 10:02:07 +05:30
|
|
|
self.header.pack_start(mbox, False)
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-01-08 06:55:04 +05:30
|
|
|
def write_person_event(self, ename, event):
|
|
|
|
if event:
|
|
|
|
dobj = event.get_date_object()
|
|
|
|
phandle = event.get_place_handle()
|
|
|
|
if phandle:
|
|
|
|
pname = self.place_name(phandle)
|
|
|
|
else:
|
|
|
|
pname = None
|
|
|
|
|
|
|
|
value = {
|
2006-04-08 11:26:31 +05:30
|
|
|
'date' : DateHandler.displayer.display(dobj),
|
|
|
|
'place' : pname,
|
2006-01-08 06:55:04 +05:30
|
|
|
}
|
|
|
|
else:
|
|
|
|
pname = None
|
|
|
|
dobj = None
|
|
|
|
|
|
|
|
if dobj:
|
|
|
|
if pname:
|
2006-04-08 11:26:31 +05:30
|
|
|
self.write_person_data(ename,
|
2006-01-08 06:55:04 +05:30
|
|
|
_('%(date)s in %(place)s') % value)
|
|
|
|
else:
|
2006-04-08 11:26:31 +05:30
|
|
|
self.write_person_data(ename, '%(date)s' % value)
|
2006-01-08 06:55:04 +05:30
|
|
|
elif pname:
|
2006-04-08 11:26:31 +05:30
|
|
|
self.write_person_data(ename, pname)
|
2006-01-08 06:55:04 +05:30
|
|
|
else:
|
2006-04-08 11:26:31 +05:30
|
|
|
self.write_person_data(ename, '')
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-05-23 09:20:37 +05:30
|
|
|
def format_event(self, event):
|
|
|
|
if event:
|
|
|
|
dobj = event.get_date_object()
|
|
|
|
phandle = event.get_place_handle()
|
|
|
|
if phandle:
|
|
|
|
pname = self.place_name(phandle)
|
|
|
|
else:
|
|
|
|
pname = None
|
|
|
|
|
|
|
|
value = {
|
|
|
|
'date' : DateHandler.displayer.display(dobj),
|
|
|
|
'place' : pname,
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
pname = None
|
|
|
|
dobj = None
|
|
|
|
|
|
|
|
if dobj:
|
|
|
|
if pname:
|
|
|
|
return _('%(date)s in %(place)s') % value
|
|
|
|
else:
|
|
|
|
return '%(date)s' % value
|
|
|
|
elif pname:
|
|
|
|
return pname
|
|
|
|
else:
|
|
|
|
return ''
|
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def write_person_data(self, title, data):
|
2008-05-09 01:10:56 +05:30
|
|
|
self.attach.attach(widgets.BasicLabel(title), _ALABEL_START,
|
2006-04-08 11:26:31 +05:30
|
|
|
_ALABEL_STOP, self.row, self.row+1,
|
2006-01-08 06:55:04 +05:30
|
|
|
xoptions=gtk.FILL|gtk.SHRINK)
|
2008-05-09 01:10:56 +05:30
|
|
|
self.attach.attach(widgets.BasicLabel(data),
|
2006-04-08 11:26:31 +05:30
|
|
|
_ADATA_START, _ADATA_STOP,
|
|
|
|
self.row, self.row+1)
|
2006-01-05 00:26:06 +05:30
|
|
|
self.row += 1
|
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
def write_label(self, title, family, is_parent, person = None):
|
|
|
|
msg = '<span style="italic" weight="heavy">%s</span>' % cgi.escape(title)
|
|
|
|
hbox = gtk.HBox()
|
2008-05-09 01:10:56 +05:30
|
|
|
label = widgets.MarkupLabel(msg, x_align=1)
|
2007-09-09 03:36:30 +05:30
|
|
|
# Draw the collapse/expand button:
|
2008-06-16 20:31:46 +05:30
|
|
|
if family is not None:
|
2008-04-20 10:22:53 +05:30
|
|
|
if self.check_collapsed(person.handle, family.handle):
|
2008-05-09 01:10:56 +05:30
|
|
|
arrow = widgets.ExpandCollapseArrow(True,
|
|
|
|
self.expand_collapse_press,
|
|
|
|
(person, family.handle))
|
2007-09-09 03:36:30 +05:30
|
|
|
else:
|
2008-05-09 01:10:56 +05:30
|
|
|
arrow = widgets.ExpandCollapseArrow(False,
|
|
|
|
self.expand_collapse_press,
|
|
|
|
(person, family.handle))
|
2007-09-09 03:36:30 +05:30
|
|
|
else :
|
|
|
|
arrow = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_OUT)
|
|
|
|
hbox.pack_start(arrow, False)
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox.pack_start(label, True)
|
2007-09-09 03:36:30 +05:30
|
|
|
self.attach.attach(hbox,
|
2006-04-08 11:26:31 +05:30
|
|
|
_LABEL_START, _LABEL_STOP,
|
|
|
|
self.row, self.row+1, gtk.SHRINK|gtk.FILL)
|
2006-01-11 00:40:39 +05:30
|
|
|
|
2006-01-11 03:58:09 +05:30
|
|
|
if family:
|
|
|
|
value = family.gramps_id
|
|
|
|
else:
|
|
|
|
value = ""
|
2008-05-09 01:10:56 +05:30
|
|
|
self.attach.attach(widgets.BasicLabel(value),
|
2006-04-08 11:26:31 +05:30
|
|
|
_DATA_START, _DATA_STOP,
|
|
|
|
self.row, self.row+1, gtk.SHRINK|gtk.FILL)
|
2006-01-11 00:40:39 +05:30
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
if family and self.check_collapsed(person.handle, family.handle):
|
2007-09-09 03:36:30 +05:30
|
|
|
# show family names later
|
|
|
|
pass
|
2006-03-07 09:05:46 +05:30
|
|
|
else:
|
2007-09-09 03:36:30 +05:30
|
|
|
hbox = gtk.HBox()
|
|
|
|
hbox.set_spacing(12)
|
2006-12-01 21:47:26 +05:30
|
|
|
if is_parent:
|
2007-09-09 03:36:30 +05:30
|
|
|
call_fcn = self.add_parent_family
|
|
|
|
del_fcn = self.delete_parent_family
|
2007-11-23 14:35:04 +05:30
|
|
|
add_msg = _('Add a new set of parents')
|
2007-12-14 18:31:49 +05:30
|
|
|
sel_msg = _('Add person as child to an existing family')
|
2007-09-09 03:36:30 +05:30
|
|
|
edit_msg = _('Edit parents')
|
2007-11-23 14:35:04 +05:30
|
|
|
ord_msg = _('Reorder parents')
|
|
|
|
del_msg = _('Remove person as child of these parents')
|
2007-09-09 03:36:30 +05:30
|
|
|
else:
|
2007-11-23 14:35:04 +05:30
|
|
|
add_msg = _('Add a new family with person as parent')
|
|
|
|
sel_msg = None
|
2007-09-09 03:36:30 +05:30
|
|
|
edit_msg = _('Edit family')
|
2007-11-23 14:35:04 +05:30
|
|
|
ord_msg = _('Reorder families')
|
|
|
|
del_msg = _('Remove person as parent in this family')
|
2007-09-09 03:36:30 +05:30
|
|
|
call_fcn = self.add_family
|
|
|
|
del_fcn = self.delete_family
|
|
|
|
|
|
|
|
if not self.toolbar_visible and not self.dbstate.db.readonly:
|
|
|
|
# Show edit-Buttons if toolbar is not visible
|
|
|
|
if self.reorder_sensitive:
|
2009-03-25 17:31:50 +05:30
|
|
|
add = widgets.IconButton(self.reorder_button_press, None,
|
2008-05-09 01:10:56 +05:30
|
|
|
gtk.STOCK_SORT_ASCENDING)
|
2007-11-23 14:35:04 +05:30
|
|
|
self.tooltips.set_tip(add, ord_msg)
|
2007-09-09 03:36:30 +05:30
|
|
|
hbox.pack_start(add, False)
|
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
add = widgets.IconButton(call_fcn, None, gtk.STOCK_ADD)
|
2007-09-09 03:36:30 +05:30
|
|
|
self.tooltips.set_tip(add, add_msg)
|
2006-12-01 21:47:26 +05:30
|
|
|
hbox.pack_start(add, False)
|
2006-04-07 08:24:33 +05:30
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
if is_parent:
|
2008-05-09 01:10:56 +05:30
|
|
|
add = widgets.IconButton(self.select_family, None,
|
|
|
|
gtk.STOCK_INDEX)
|
2007-09-09 03:36:30 +05:30
|
|
|
self.tooltips.set_tip(add, sel_msg)
|
|
|
|
hbox.pack_start(add, False)
|
|
|
|
|
|
|
|
if family:
|
2008-05-09 01:10:56 +05:30
|
|
|
edit = widgets.IconButton(self.edit_family, family.handle,
|
|
|
|
gtk.STOCK_EDIT)
|
2007-09-09 03:36:30 +05:30
|
|
|
self.tooltips.set_tip(edit, edit_msg)
|
|
|
|
hbox.pack_start(edit, False)
|
|
|
|
if not self.dbstate.db.readonly:
|
2008-05-09 01:10:56 +05:30
|
|
|
delete = widgets.IconButton(del_fcn, family.handle,
|
|
|
|
gtk.STOCK_REMOVE)
|
2007-09-09 03:36:30 +05:30
|
|
|
self.tooltips.set_tip(delete, del_msg)
|
|
|
|
hbox.pack_start(delete, False)
|
|
|
|
self.attach.attach(hbox, _BTN_START, _BTN_STOP, self.row, self.row+1)
|
2006-01-11 00:40:39 +05:30
|
|
|
self.row += 1
|
|
|
|
|
2006-01-08 06:55:04 +05:30
|
|
|
######################################################################
|
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
def write_parents(self, family_handle, person = None):
|
2006-01-08 06:55:04 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
2006-03-10 04:07:19 +05:30
|
|
|
if not family:
|
|
|
|
return
|
2008-04-20 10:22:53 +05:30
|
|
|
if person and self.check_collapsed(person.handle, family_handle):
|
2007-09-09 03:36:30 +05:30
|
|
|
# don't show rest
|
|
|
|
self.write_label("%s:" % _('Parents'), family, True, person)
|
|
|
|
self.row -= 1 # back up one row for summary names
|
2006-01-08 06:55:04 +05:30
|
|
|
active = self.dbstate.active.handle
|
2007-09-09 03:36:30 +05:30
|
|
|
child_list = [ref.ref for ref in family.get_child_ref_list()
|
2006-04-13 21:46:00 +05:30
|
|
|
if ref.ref != active]
|
2006-01-08 06:55:04 +05:30
|
|
|
if child_list:
|
2007-09-09 03:36:30 +05:30
|
|
|
count = len(child_list)
|
|
|
|
else:
|
|
|
|
count = 0
|
|
|
|
if count > 1 :
|
2009-02-03 21:51:42 +05:30
|
|
|
childmsg = ngettext(" (%d sibling)", " (%d siblings)", count) % count
|
2007-09-09 03:36:30 +05:30
|
|
|
elif count == 1 :
|
|
|
|
gender = self.dbstate.db.get_person_from_handle(\
|
|
|
|
child_list[0]).gender
|
2007-10-08 22:11:39 +05:30
|
|
|
if gender == gen.lib.Person.MALE :
|
2007-09-09 03:36:30 +05:30
|
|
|
childmsg = _(" (1 brother)")
|
2007-10-08 22:11:39 +05:30
|
|
|
elif gender == gen.lib.Person.FEMALE :
|
2007-09-09 03:36:30 +05:30
|
|
|
childmsg = _(" (1 sister)")
|
|
|
|
else :
|
|
|
|
childmsg = _(" (1 sibling)")
|
|
|
|
else :
|
|
|
|
childmsg = _(" (only child)")
|
|
|
|
box = self.get_people_box(family.get_father_handle(),
|
|
|
|
family.get_mother_handle(),
|
|
|
|
post_msg=childmsg)
|
|
|
|
eventbox = gtk.EventBox()
|
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
eventbox.add(box)
|
|
|
|
self.attach.attach(
|
|
|
|
eventbox, _PDATA_START, _PDATA_STOP,
|
|
|
|
self.row, self.row+1)
|
|
|
|
self.row += 1 # now advance it
|
|
|
|
else:
|
|
|
|
self.write_label("%s:" % _('Parents'), family, True, person)
|
|
|
|
self.write_person(_('Father'), family.get_father_handle())
|
|
|
|
self.write_person(_('Mother'), family.get_mother_handle())
|
|
|
|
|
|
|
|
if self.show_siblings:
|
|
|
|
active = self.dbstate.active.handle
|
2008-02-14 18:28:57 +05:30
|
|
|
hbox = gtk.HBox()
|
2008-04-20 10:22:53 +05:30
|
|
|
if self.check_collapsed(person.handle, "SIBLINGS"):
|
2008-05-09 01:10:56 +05:30
|
|
|
arrow = widgets.ExpandCollapseArrow(True,
|
|
|
|
self.expand_collapse_press,
|
|
|
|
(person, "SIBLINGS"))
|
2008-04-20 10:22:53 +05:30
|
|
|
else:
|
2008-05-09 01:10:56 +05:30
|
|
|
arrow = widgets.ExpandCollapseArrow(False,
|
|
|
|
self.expand_collapse_press,
|
|
|
|
(person, "SIBLINGS"))
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox.pack_start(arrow, False)
|
|
|
|
label_cell = self.build_label_cell(_('Siblings'))
|
|
|
|
hbox.pack_start(label_cell, True)
|
2008-02-14 18:28:57 +05:30
|
|
|
self.attach.attach(
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox, _CLABEL_START-1, _CLABEL_STOP-1, self.row,
|
2008-02-14 18:28:57 +05:30
|
|
|
self.row+1, xoptions=gtk.FILL|gtk.SHRINK,
|
|
|
|
yoptions=gtk.FILL)
|
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
if self.check_collapsed(person.handle, "SIBLINGS"):
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
child_list = [ref.ref for ref in family.get_child_ref_list()
|
|
|
|
if ref.ref != active]
|
|
|
|
if child_list:
|
|
|
|
count = len(child_list)
|
|
|
|
else:
|
|
|
|
count = 0
|
|
|
|
if count > 1 :
|
2009-02-03 21:51:42 +05:30
|
|
|
childmsg = ngettext(" (%d sibling)"," (%d siblings)", count) % count
|
2008-04-20 10:22:53 +05:30
|
|
|
elif count == 1 :
|
|
|
|
gender = self.dbstate.db.get_person_from_handle(\
|
|
|
|
child_list[0]).gender
|
|
|
|
if gender == gen.lib.Person.MALE :
|
|
|
|
childmsg = _(" (1 brother)")
|
|
|
|
elif gender == gen.lib.Person.FEMALE :
|
|
|
|
childmsg = _(" (1 sister)")
|
|
|
|
else :
|
|
|
|
childmsg = _(" (1 sibling)")
|
|
|
|
else :
|
|
|
|
childmsg = _(" (only child)")
|
|
|
|
box = self.get_people_box(post_msg=childmsg)
|
|
|
|
eventbox = gtk.EventBox()
|
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
eventbox.add(box)
|
|
|
|
self.attach.attach(
|
|
|
|
eventbox, _PDATA_START, _PDATA_STOP,
|
|
|
|
self.row, self.row+1)
|
|
|
|
self.row += 1 # now advance it
|
|
|
|
else:
|
|
|
|
hbox = gtk.HBox()
|
2008-05-09 01:10:56 +05:30
|
|
|
addchild = widgets.IconButton(self.add_child_to_fam,
|
|
|
|
family.handle,
|
|
|
|
gtk.STOCK_ADD)
|
2008-04-20 10:22:53 +05:30
|
|
|
self.tooltips.set_tip(addchild,
|
|
|
|
_('Add new child to family'))
|
2008-05-09 01:10:56 +05:30
|
|
|
selchild = widgets.IconButton(self.sel_child_to_fam,
|
|
|
|
family.handle,
|
|
|
|
gtk.STOCK_INDEX)
|
2008-04-20 10:22:53 +05:30
|
|
|
self.tooltips.set_tip(selchild,
|
|
|
|
_('Add existing child to family'))
|
|
|
|
hbox.pack_start(addchild, False)
|
|
|
|
hbox.pack_start(selchild, False)
|
|
|
|
|
|
|
|
self.attach.attach(
|
|
|
|
hbox, _CLABEL_START, _CLABEL_STOP, self.row,
|
|
|
|
self.row+1, xoptions=gtk.FILL|gtk.SHRINK,
|
|
|
|
yoptions=gtk.FILL)
|
|
|
|
|
|
|
|
self.row += 1
|
|
|
|
vbox = gtk.VBox()
|
|
|
|
i = 1
|
|
|
|
child_list = [ref.ref for ref in family.get_child_ref_list()]
|
|
|
|
for child_handle in child_list:
|
|
|
|
child_should_be_linked = (child_handle != active)
|
|
|
|
self.write_child(vbox, child_handle, i, child_should_be_linked)
|
|
|
|
i += 1
|
|
|
|
eventbox = gtk.EventBox()
|
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
eventbox.add(vbox)
|
|
|
|
self.attach.attach(
|
2009-03-14 17:53:53 +05:30
|
|
|
eventbox, _CDATA_START-1, _CDATA_STOP, self.row,
|
2008-04-20 10:22:53 +05:30
|
|
|
self.row+1)
|
2006-05-24 01:16:02 +05:30
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
self.row += 1
|
2006-05-24 01:16:02 +05:30
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
def get_people_box(self, *handles, **kwargs):
|
|
|
|
vbox = gtk.HBox()
|
|
|
|
initial_name = True
|
|
|
|
for handle in handles:
|
|
|
|
if not initial_name:
|
|
|
|
link_label = gtk.Label(" %s " % _('and'))
|
|
|
|
link_label.show()
|
|
|
|
vbox.pack_start(link_label, expand=False)
|
|
|
|
initial_name = False
|
|
|
|
if handle:
|
|
|
|
name = self.get_name(handle, True)
|
2008-05-09 01:10:56 +05:30
|
|
|
link_label = widgets.LinkLabel(name, self._button_press, handle)
|
2007-09-09 03:36:30 +05:30
|
|
|
if self.use_shade:
|
|
|
|
link_label.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
if Config.get(Config.RELEDITBTN):
|
2008-05-09 01:10:56 +05:30
|
|
|
button = widgets.IconButton(self.edit_button_press,
|
|
|
|
handle)
|
2007-09-09 03:36:30 +05:30
|
|
|
self.tooltips.set_tip(button, _('Edit %s') % name[0])
|
|
|
|
else:
|
|
|
|
button = None
|
2008-05-09 01:10:56 +05:30
|
|
|
vbox.pack_start(widgets.LinkBox(link_label, button),
|
2007-09-09 03:36:30 +05:30
|
|
|
expand=False)
|
|
|
|
else:
|
|
|
|
link_label = gtk.Label(_('Unknown'))
|
|
|
|
link_label.show()
|
|
|
|
vbox.pack_start(link_label, expand=False)
|
|
|
|
if "post_msg" in kwargs and kwargs["post_msg"]:
|
|
|
|
link_label = gtk.Label(kwargs["post_msg"])
|
|
|
|
link_label.show()
|
|
|
|
vbox.pack_start(link_label, expand=False)
|
|
|
|
return vbox
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def write_person(self, title, handle):
|
2006-01-04 03:37:34 +05:30
|
|
|
if title:
|
|
|
|
format = '<span weight="bold">%s: </span>'
|
|
|
|
else:
|
|
|
|
format = "%s"
|
2006-01-04 11:09:39 +05:30
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
label = widgets.MarkupLabel(format % cgi.escape(title),
|
|
|
|
x_align=1, y_align=0)
|
2006-11-08 10:45:26 +05:30
|
|
|
if Config.get(Config.RELEDITBTN):
|
2007-01-09 10:02:07 +05:30
|
|
|
label.set_padding(0, 5)
|
2006-04-08 11:26:31 +05:30
|
|
|
self.attach.attach(label, _PLABEL_START, _PLABEL_STOP, self.row,
|
2006-05-23 22:03:42 +05:30
|
|
|
self.row+1, xoptions=gtk.FILL|gtk.SHRINK,
|
|
|
|
yoptions=gtk.FILL|gtk.SHRINK)
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-05-23 22:03:42 +05:30
|
|
|
vbox = gtk.VBox()
|
|
|
|
|
2006-03-24 00:20:43 +05:30
|
|
|
if handle:
|
2006-12-04 10:33:58 +05:30
|
|
|
name = self.get_name(handle, True)
|
2008-12-27 23:06:58 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
|
|
|
parent = len(person.get_parent_family_handle_list()) > 0
|
|
|
|
format = ''
|
|
|
|
relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME)
|
|
|
|
if parent:
|
|
|
|
if relation_display_theme == "CLASSIC":
|
|
|
|
format = 'underline="single" weight="heavy" style="italic"'
|
|
|
|
elif relation_display_theme == "WEBPAGE":
|
|
|
|
format = 'foreground="blue" weight="heavy"'
|
|
|
|
else:
|
|
|
|
if relation_display_theme == "CLASSIC":
|
|
|
|
format = 'underline="single"'
|
|
|
|
elif relation_display_theme == "WEBPAGE":
|
|
|
|
format = 'foreground="blue"'
|
|
|
|
link_label = widgets.LinkLabel(name, self._button_press,
|
|
|
|
handle, format)
|
2006-05-24 10:19:05 +05:30
|
|
|
if self.use_shade:
|
|
|
|
link_label.modify_bg(gtk.STATE_NORMAL, self.color)
|
2006-11-08 10:45:26 +05:30
|
|
|
if Config.get(Config.RELEDITBTN):
|
2008-05-09 01:10:56 +05:30
|
|
|
button = widgets.IconButton(self.edit_button_press, handle)
|
2006-12-04 10:33:58 +05:30
|
|
|
self.tooltips.set_tip(button, _('Edit %s') % name[0])
|
2006-11-08 10:45:26 +05:30
|
|
|
else:
|
|
|
|
button = None
|
2008-05-09 01:10:56 +05:30
|
|
|
vbox.pack_start(widgets.LinkBox(link_label, button))
|
2006-03-24 00:20:43 +05:30
|
|
|
else:
|
|
|
|
link_label = gtk.Label(_('Unknown'))
|
2006-05-23 22:10:08 +05:30
|
|
|
link_label.set_alignment(0, 1)
|
2006-03-24 00:20:43 +05:30
|
|
|
link_label.show()
|
2006-05-23 22:03:42 +05:30
|
|
|
vbox.pack_start(link_label)
|
2006-03-24 00:20:43 +05:30
|
|
|
|
2006-05-23 22:03:42 +05:30
|
|
|
if self.show_details:
|
|
|
|
value = self.info_string(handle)
|
|
|
|
if value:
|
2008-05-09 01:10:56 +05:30
|
|
|
vbox.pack_start(widgets.MarkupLabel(value))
|
2006-05-23 22:03:42 +05:30
|
|
|
|
|
|
|
eventbox = gtk.EventBox()
|
2006-05-24 10:19:05 +05:30
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
2006-05-23 22:03:42 +05:30
|
|
|
eventbox.add(vbox)
|
|
|
|
|
|
|
|
self.attach.attach(eventbox, _PDATA_START, _PDATA_STOP,
|
|
|
|
self.row, self.row+1)
|
2006-01-05 10:42:48 +05:30
|
|
|
self.row += 1
|
2006-05-24 01:16:02 +05:30
|
|
|
return vbox
|
2006-01-05 10:42:48 +05:30
|
|
|
|
2006-05-24 01:16:02 +05:30
|
|
|
def build_label_cell(self, title):
|
2006-01-05 10:42:48 +05:30
|
|
|
if title:
|
|
|
|
format = '<span weight="bold">%s: </span>'
|
|
|
|
else:
|
|
|
|
format = "%s"
|
|
|
|
|
2008-05-09 01:10:56 +05:30
|
|
|
lbl = widgets.MarkupLabel(format % cgi.escape(title),
|
|
|
|
x_align=1, y_align=.5)
|
2006-11-08 10:45:26 +05:30
|
|
|
if Config.get(Config.RELEDITBTN):
|
2007-01-09 10:02:07 +05:30
|
|
|
lbl.set_padding(0, 5)
|
2006-11-03 09:42:12 +05:30
|
|
|
return lbl
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2007-11-08 14:42:01 +05:30
|
|
|
def write_child(self, vbox, handle, index, child_should_be_linked):
|
2008-04-20 10:22:53 +05:30
|
|
|
if not child_should_be_linked:
|
|
|
|
original_vbox = vbox
|
|
|
|
vbox = gtk.VBox()
|
|
|
|
frame = gtk.Frame()
|
|
|
|
frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
2008-10-22 15:21:37 +05:30
|
|
|
if self.use_shade:
|
|
|
|
ev = gtk.EventBox()
|
|
|
|
ev.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
ev.add(vbox)
|
|
|
|
frame.add(ev)
|
|
|
|
else:
|
|
|
|
frame.add(vbox)
|
2008-04-20 10:22:53 +05:30
|
|
|
original_vbox.add(frame)
|
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
parent = has_children(self.dbstate.db,
|
|
|
|
self.dbstate.db.get_person_from_handle(handle))
|
2007-11-08 14:42:01 +05:30
|
|
|
|
|
|
|
format = ''
|
2008-04-20 10:22:53 +05:30
|
|
|
relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME)
|
2007-11-08 14:42:01 +05:30
|
|
|
if child_should_be_linked and parent:
|
2008-04-20 10:22:53 +05:30
|
|
|
if relation_display_theme == "CLASSIC":
|
|
|
|
format = 'underline="single" weight="heavy" style="italic"'
|
|
|
|
elif relation_display_theme == "WEBPAGE":
|
|
|
|
format = 'foreground="blue" weight="heavy"'
|
|
|
|
else:
|
|
|
|
raise AttributeError("invalid relation-display-theme: '%s'" % relation_display_theme)
|
2007-11-08 14:42:01 +05:30
|
|
|
elif child_should_be_linked and not parent:
|
2008-04-20 10:22:53 +05:30
|
|
|
if relation_display_theme == "CLASSIC":
|
|
|
|
format = 'underline="single"'
|
|
|
|
elif relation_display_theme == "WEBPAGE":
|
|
|
|
format = 'foreground="blue"'
|
|
|
|
else:
|
|
|
|
raise AttributeError("invalid relation-display-theme: '%s'" % relation_display_theme)
|
2007-11-08 14:42:01 +05:30
|
|
|
elif parent and not child_should_be_linked:
|
2008-04-20 10:22:53 +05:30
|
|
|
format = 'weight="heavy"'
|
2007-11-08 14:42:01 +05:30
|
|
|
|
|
|
|
if child_should_be_linked:
|
|
|
|
link_func = self._button_press
|
|
|
|
else:
|
|
|
|
link_func = None
|
|
|
|
|
2007-11-23 14:35:04 +05:30
|
|
|
name = self.get_name(handle, True)
|
2008-05-09 01:10:56 +05:30
|
|
|
link_label = widgets.LinkLabel(name, link_func, handle, format)
|
2007-11-08 14:42:01 +05:30
|
|
|
|
2006-05-24 10:19:05 +05:30
|
|
|
if self.use_shade:
|
|
|
|
link_label.modify_bg(gtk.STATE_NORMAL, self.color)
|
2006-05-24 02:37:26 +05:30
|
|
|
link_label.set_padding(3, 0)
|
2007-11-08 14:42:01 +05:30
|
|
|
if child_should_be_linked and Config.get(Config.RELEDITBTN):
|
2008-05-09 01:10:56 +05:30
|
|
|
button = widgets.IconButton(self.edit_button_press, handle)
|
2007-11-23 14:35:04 +05:30
|
|
|
self.tooltips.set_tip(button, _('Edit %s') % name[0])
|
2006-11-08 10:45:26 +05:30
|
|
|
else:
|
|
|
|
button = None
|
2006-07-22 09:42:09 +05:30
|
|
|
|
|
|
|
hbox = gtk.HBox()
|
2008-05-09 01:10:56 +05:30
|
|
|
l = widgets.BasicLabel("%d." % index)
|
2008-04-20 10:22:53 +05:30
|
|
|
l.set_width_chars(3)
|
2007-12-15 20:46:33 +05:30
|
|
|
l.set_alignment(1.0, 0.5)
|
|
|
|
hbox.pack_start(l, False, False, 0)
|
2008-05-09 01:10:56 +05:30
|
|
|
hbox.pack_start(widgets.LinkBox(link_label, button),
|
2006-07-22 09:42:09 +05:30
|
|
|
False, False, 4)
|
|
|
|
hbox.show()
|
|
|
|
vbox.pack_start(hbox)
|
2006-01-04 04:58:36 +05:30
|
|
|
|
2006-01-06 10:38:51 +05:30
|
|
|
if self.show_details:
|
|
|
|
value = self.info_string(handle)
|
|
|
|
if value:
|
2008-05-09 01:10:56 +05:30
|
|
|
l = widgets.MarkupLabel(value)
|
2007-12-15 20:46:33 +05:30
|
|
|
l.set_padding(48, 0)
|
2006-05-24 02:37:26 +05:30
|
|
|
vbox.add(l)
|
2008-04-20 10:22:53 +05:30
|
|
|
|
2006-05-24 01:16:02 +05:30
|
|
|
def write_data(self, box, title, start_col=_SDATA_START,
|
|
|
|
stop_col=_SDATA_STOP):
|
2008-05-09 01:10:56 +05:30
|
|
|
box.add(widgets.BasicLabel(title))
|
2006-01-08 06:55:04 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def info_string(self, handle):
|
2008-04-19 07:58:14 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
|
|
|
if not person:
|
2006-03-03 14:13:02 +05:30
|
|
|
return None
|
2006-11-07 19:25:32 +05:30
|
|
|
|
2008-04-19 07:58:14 +05:30
|
|
|
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
|
2007-10-08 22:11:39 +05:30
|
|
|
if birth and birth.get_type != gen.lib.EventType.BIRTH:
|
2008-04-19 07:58:14 +05:30
|
|
|
sdate = DateHandler.get_date(birth)
|
|
|
|
if sdate:
|
|
|
|
bdate = "<i>%s</i>" % cgi.escape(sdate)
|
|
|
|
else:
|
|
|
|
bdate = ""
|
2006-11-07 19:25:32 +05:30
|
|
|
elif birth:
|
2006-12-12 17:35:19 +05:30
|
|
|
bdate = cgi.escape(DateHandler.get_date(birth))
|
2006-11-07 19:25:32 +05:30
|
|
|
else:
|
|
|
|
bdate = ""
|
2006-11-23 04:00:47 +05:30
|
|
|
|
2008-04-19 07:58:14 +05:30
|
|
|
death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
|
2007-10-08 22:11:39 +05:30
|
|
|
if death and death.get_type != gen.lib.EventType.DEATH:
|
2008-04-19 07:58:14 +05:30
|
|
|
sdate = DateHandler.get_date(death)
|
|
|
|
if sdate:
|
|
|
|
ddate = "<i>%s</i>" % cgi.escape(sdate)
|
|
|
|
else:
|
|
|
|
ddate = ""
|
2006-11-07 19:25:32 +05:30
|
|
|
elif death:
|
2006-12-12 17:35:19 +05:30
|
|
|
ddate = cgi.escape(DateHandler.get_date(death))
|
2006-11-07 19:25:32 +05:30
|
|
|
else:
|
|
|
|
ddate = ""
|
|
|
|
|
|
|
|
if bdate and ddate:
|
2007-07-03 06:15:28 +05:30
|
|
|
value = _("b. %(birthdate)s, d. %(deathdate)s") % {
|
2007-06-25 10:27:53 +05:30
|
|
|
'birthdate' : bdate,
|
|
|
|
'deathdate' : ddate
|
|
|
|
}
|
2006-11-07 19:25:32 +05:30
|
|
|
elif bdate:
|
2008-11-12 14:40:13 +05:30
|
|
|
value = _("short for born|b. %s") % (bdate)
|
2006-11-07 19:25:32 +05:30
|
|
|
elif ddate:
|
2008-11-08 21:06:35 +05:30
|
|
|
value = _("short for dead|d. %s") % (ddate)
|
2006-11-08 02:18:15 +05:30
|
|
|
else:
|
|
|
|
value = ""
|
2006-01-06 04:30:59 +05:30
|
|
|
return value
|
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
def check_collapsed(self, person_handle, handle):
|
2008-02-24 19:25:55 +05:30
|
|
|
""" Return true if collapsed. """
|
2008-04-20 10:22:53 +05:30
|
|
|
return (handle in self.collapsed_items.get(person_handle, []))
|
2007-09-09 03:36:30 +05:30
|
|
|
|
|
|
|
def expand_collapse_press(self, obj, event, pair):
|
2009-02-09 18:02:57 +05:30
|
|
|
""" Calback function for ExpandCollapseArrow, user param is
|
|
|
|
pair, which is a tuple (object, handle) which handles the
|
|
|
|
section of which the collapse state must change, so a
|
|
|
|
parent, siblings id, family id, family children id, etc.
|
|
|
|
NOTE: object must be a thing that has a handle field.
|
2007-09-09 03:36:30 +05:30
|
|
|
"""
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2009-02-09 18:02:57 +05:30
|
|
|
object, handle = pair
|
|
|
|
if object.handle in self.collapsed_items:
|
|
|
|
if handle in self.collapsed_items[object.handle]:
|
|
|
|
self.collapsed_items[object.handle].remove(handle)
|
2007-09-09 03:36:30 +05:30
|
|
|
else:
|
2009-02-09 18:02:57 +05:30
|
|
|
self.collapsed_items[object.handle].append(handle)
|
2007-09-09 03:36:30 +05:30
|
|
|
else:
|
2009-02-09 18:02:57 +05:30
|
|
|
self.collapsed_items[object.handle] = [handle]
|
2007-09-09 03:36:30 +05:30
|
|
|
self.redraw()
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _button_press(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-01-04 04:58:36 +05:30
|
|
|
self.dbstate.change_active_handle(handle)
|
2008-02-23 03:39:39 +05:30
|
|
|
elif button_activated(event, _RIGHT_BUTTON):
|
2007-01-09 10:02:07 +05:30
|
|
|
myMenu = gtk.Menu()
|
|
|
|
myMenu.append(self.build_menu_item(handle))
|
|
|
|
myMenu.popup(None, None, None, event.button, event.time)
|
2006-11-01 04:33:58 +05:30
|
|
|
|
|
|
|
def build_menu_item(self, handle):
|
2007-01-09 10:02:07 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
2007-06-28 11:11:40 +05:30
|
|
|
name = name_displayer.display(person)
|
2006-11-01 04:33:58 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
item = gtk.ImageMenuItem(None)
|
|
|
|
image = gtk.image_new_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU)
|
|
|
|
image.show()
|
|
|
|
label = gtk.Label(_("Edit %s") % name)
|
|
|
|
label.show()
|
|
|
|
label.set_alignment(0, 0)
|
2006-11-01 04:33:58 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
item.set_image(image)
|
|
|
|
item.add(label)
|
2006-11-01 04:33:58 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
item.connect('activate', self.edit_menu, handle)
|
|
|
|
item.show()
|
|
|
|
return item
|
2006-11-01 04:33:58 +05:30
|
|
|
|
|
|
|
def edit_menu(self, obj, handle):
|
2007-01-09 10:02:07 +05:30
|
|
|
from Editors import EditPerson
|
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
|
|
|
try:
|
|
|
|
EditPerson(self.dbstate, self.uistate, [], person)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-04 05:32:29 +05:30
|
|
|
|
2006-05-24 01:16:02 +05:30
|
|
|
def write_relationship(self, box, family):
|
2006-12-12 17:19:57 +05:30
|
|
|
msg = _('Relationship type: %s') % cgi.escape(str(family.get_relationship()))
|
2008-05-09 01:10:56 +05:30
|
|
|
box.add(widgets.MarkupLabel(msg))
|
2006-01-04 11:09:39 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def place_name(self, handle):
|
2006-01-04 11:09:39 +05:30
|
|
|
p = self.dbstate.db.get_place_from_handle(handle)
|
|
|
|
return p.get_title()
|
|
|
|
|
2006-05-24 01:16:02 +05:30
|
|
|
def write_marriage(self, vbox, family):
|
2006-01-11 03:58:09 +05:30
|
|
|
value = False
|
2006-01-04 11:09:39 +05:30
|
|
|
for event_ref in family.get_event_ref_list():
|
|
|
|
handle = event_ref.ref
|
|
|
|
event = self.dbstate.db.get_event_from_handle(handle)
|
2007-10-08 22:11:39 +05:30
|
|
|
if event.get_type() == gen.lib.EventType.MARRIAGE:
|
2006-05-24 01:16:02 +05:30
|
|
|
self.write_event_ref(vbox, _('Marriage'), event)
|
2006-01-11 03:58:09 +05:30
|
|
|
value = True
|
|
|
|
return value
|
2006-01-05 00:26:06 +05:30
|
|
|
|
2006-05-24 01:16:02 +05:30
|
|
|
def write_event_ref(self, vbox, ename, event, start_col=_SDATA_START,
|
2006-03-09 08:37:41 +05:30
|
|
|
stop_col=_SDATA_STOP):
|
2006-01-05 00:26:06 +05:30
|
|
|
if event:
|
|
|
|
dobj = event.get_date_object()
|
|
|
|
phandle = event.get_place_handle()
|
|
|
|
if phandle:
|
|
|
|
pname = self.place_name(phandle)
|
|
|
|
else:
|
|
|
|
pname = None
|
|
|
|
|
|
|
|
value = {
|
2006-04-08 11:26:31 +05:30
|
|
|
'date' : DateHandler.displayer.display(dobj),
|
|
|
|
'place' : pname,
|
|
|
|
'event_type' : ename,
|
2006-01-05 00:26:06 +05:30
|
|
|
}
|
|
|
|
else:
|
|
|
|
pname = None
|
|
|
|
dobj = None
|
2006-03-18 07:00:23 +05:30
|
|
|
value = { 'event_type' : ename, }
|
2006-01-05 00:26:06 +05:30
|
|
|
|
|
|
|
if dobj:
|
|
|
|
if pname:
|
2006-09-13 08:27:45 +05:30
|
|
|
self.write_data(
|
|
|
|
vbox, _('%(event_type)s: %(date)s in %(place)s') %
|
|
|
|
value, start_col, stop_col)
|
2006-01-05 00:26:06 +05:30
|
|
|
else:
|
2006-09-13 08:27:45 +05:30
|
|
|
self.write_data(
|
|
|
|
vbox, _('%(event_type)s: %(date)s') % value,
|
|
|
|
start_col, stop_col)
|
2006-01-05 00:26:06 +05:30
|
|
|
elif pname:
|
2006-09-13 08:27:45 +05:30
|
|
|
self.write_data(
|
|
|
|
vbox, _('%(event_type)s: %(place)s') % value,
|
|
|
|
start_col, stop_col)
|
2006-01-05 00:26:06 +05:30
|
|
|
else:
|
2006-09-13 08:27:45 +05:30
|
|
|
self.write_data(
|
2006-11-03 22:35:24 +05:30
|
|
|
vbox, '%(event_type)s:' % value, start_col, stop_col)
|
2006-01-05 00:26:06 +05:30
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
def write_family(self, family_handle, person = None):
|
2006-01-04 03:37:34 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
2008-06-16 20:31:46 +05:30
|
|
|
if family is None:
|
2006-09-13 08:27:45 +05:30
|
|
|
from QuestionDialog import WarningDialog
|
|
|
|
WarningDialog(
|
|
|
|
_('Broken family detected'),
|
|
|
|
_('Please run the Check and Repair Database tool'))
|
|
|
|
return
|
|
|
|
|
2006-01-04 03:37:34 +05:30
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
mother_handle = family.get_mother_handle()
|
|
|
|
if self.dbstate.active.handle == father_handle:
|
2006-01-06 04:30:59 +05:30
|
|
|
handle = mother_handle
|
2006-01-04 03:37:34 +05:30
|
|
|
else:
|
2006-01-06 04:30:59 +05:30
|
|
|
handle = father_handle
|
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
# collapse button
|
2008-04-20 10:22:53 +05:30
|
|
|
if self.check_collapsed(person.handle, family_handle):
|
2007-09-09 03:36:30 +05:30
|
|
|
# show "> Family: ..." and nothing else
|
|
|
|
self.write_label("%s:" % _('Family'), family, False, person)
|
|
|
|
self.row -= 1 # back up
|
|
|
|
child_list = family.get_child_ref_list()
|
|
|
|
if child_list:
|
|
|
|
count = len(child_list)
|
|
|
|
else:
|
|
|
|
count = 0
|
2009-01-31 16:59:44 +05:30
|
|
|
if count >= 1 :
|
2009-02-03 21:51:42 +05:30
|
|
|
childmsg = ngettext(" (%d child)"," (%d children)", count) % count
|
2007-09-09 03:36:30 +05:30
|
|
|
else :
|
|
|
|
childmsg = _(" (no children)")
|
|
|
|
box = self.get_people_box(handle, post_msg=childmsg)
|
2006-05-24 01:16:02 +05:30
|
|
|
eventbox = gtk.EventBox()
|
2006-05-24 10:19:05 +05:30
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
2007-09-09 03:36:30 +05:30
|
|
|
eventbox.add(box)
|
2006-05-24 01:16:02 +05:30
|
|
|
self.attach.attach(
|
2007-09-09 03:36:30 +05:30
|
|
|
eventbox, _PDATA_START, _PDATA_STOP,
|
|
|
|
self.row, self.row+1)
|
|
|
|
self.row += 1 # now advance it
|
|
|
|
else:
|
|
|
|
# show "V Family: ..." and the rest
|
|
|
|
self.write_label("%s:" % _('Family'), family, False, person)
|
|
|
|
if handle:
|
|
|
|
box = self.write_person(_('Spouse'), handle)
|
2006-05-24 01:16:02 +05:30
|
|
|
|
2007-09-09 03:36:30 +05:30
|
|
|
if not self.write_marriage(box, family):
|
|
|
|
self.write_relationship(box, family)
|
2006-05-24 01:16:02 +05:30
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox = gtk.HBox()
|
2009-02-09 18:02:57 +05:30
|
|
|
if self.check_collapsed(family.handle, "CHILDREN"):
|
2008-05-09 01:10:56 +05:30
|
|
|
arrow = widgets.ExpandCollapseArrow(True,
|
|
|
|
self.expand_collapse_press,
|
2009-02-09 18:02:57 +05:30
|
|
|
(family, "CHILDREN"))
|
2008-04-20 10:22:53 +05:30
|
|
|
else:
|
2008-05-09 01:10:56 +05:30
|
|
|
arrow = widgets.ExpandCollapseArrow(False,
|
|
|
|
self.expand_collapse_press,
|
2009-02-09 18:02:57 +05:30
|
|
|
(family, "CHILDREN"))
|
2008-04-20 19:16:06 +05:30
|
|
|
hbox.pack_start(arrow, False)
|
2008-02-14 18:28:57 +05:30
|
|
|
label_cell = self.build_label_cell(_('Children'))
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox.pack_start(label_cell, True)
|
2008-02-14 18:28:57 +05:30
|
|
|
self.attach.attach(
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox, _CLABEL_START-1, _CLABEL_STOP-1, self.row,
|
2008-02-14 18:28:57 +05:30
|
|
|
self.row+1, xoptions=gtk.FILL|gtk.SHRINK,
|
|
|
|
yoptions=gtk.FILL)
|
2007-09-09 03:36:30 +05:30
|
|
|
|
2009-02-09 18:02:57 +05:30
|
|
|
if self.check_collapsed(family.handle, "CHILDREN"):
|
2008-04-20 10:22:53 +05:30
|
|
|
hbox = gtk.HBox()
|
|
|
|
child_list = family.get_child_ref_list()
|
|
|
|
if child_list:
|
|
|
|
count = len(child_list)
|
|
|
|
else:
|
|
|
|
count = 0
|
2009-01-31 16:59:44 +05:30
|
|
|
if count >= 1 :
|
2009-02-03 21:51:42 +05:30
|
|
|
childmsg = ngettext(" (%d child)"," (%d children)", count) % count
|
2008-04-20 10:22:53 +05:30
|
|
|
else :
|
|
|
|
childmsg = _(" (no children)")
|
|
|
|
box = self.get_people_box(post_msg=childmsg)
|
|
|
|
eventbox = gtk.EventBox()
|
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
eventbox.add(box)
|
|
|
|
self.attach.attach(
|
|
|
|
eventbox, _PDATA_START, _PDATA_STOP,
|
|
|
|
self.row, self.row+1)
|
|
|
|
self.row += 1 # now advance it
|
|
|
|
else:
|
|
|
|
hbox = gtk.HBox()
|
2008-05-09 01:10:56 +05:30
|
|
|
addchild = widgets.IconButton(self.add_child_to_fam,
|
|
|
|
family.handle,
|
|
|
|
gtk.STOCK_ADD)
|
2008-04-20 10:22:53 +05:30
|
|
|
self.tooltips.set_tip(addchild,
|
|
|
|
_('Add new child to family'))
|
2008-05-09 01:10:56 +05:30
|
|
|
selchild = widgets.IconButton(self.sel_child_to_fam,
|
|
|
|
family.handle,
|
|
|
|
gtk.STOCK_INDEX)
|
2008-04-20 10:22:53 +05:30
|
|
|
self.tooltips.set_tip(selchild,
|
|
|
|
_('Add existing child to family'))
|
|
|
|
hbox.pack_start(addchild, False)
|
|
|
|
hbox.pack_start(selchild, False)
|
|
|
|
self.attach.attach(
|
|
|
|
hbox, _CLABEL_START, _CLABEL_STOP, self.row,
|
|
|
|
self.row+1, xoptions=gtk.FILL|gtk.SHRINK,
|
|
|
|
yoptions=gtk.FILL)
|
2008-02-14 18:28:57 +05:30
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
vbox = gtk.VBox()
|
|
|
|
i = 1
|
|
|
|
child_list = family.get_child_ref_list()
|
|
|
|
for child_ref in child_list:
|
|
|
|
self.write_child(vbox, child_ref.ref, i, True)
|
|
|
|
i += 1
|
2008-02-14 18:28:57 +05:30
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
self.row += 1
|
|
|
|
eventbox = gtk.EventBox()
|
|
|
|
if self.use_shade:
|
|
|
|
eventbox.modify_bg(gtk.STATE_NORMAL, self.color)
|
|
|
|
eventbox.add(vbox)
|
|
|
|
self.attach.attach(
|
2009-03-14 17:53:53 +05:30
|
|
|
eventbox, _CDATA_START-1, _CDATA_STOP, self.row,
|
2008-04-20 10:22:53 +05:30
|
|
|
self.row+1)
|
|
|
|
self.row += 1
|
2006-01-11 00:40:39 +05:30
|
|
|
|
2006-01-05 10:42:48 +05:30
|
|
|
def edit_button_press(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-12-30 23:19:08 +05:30
|
|
|
self.edit_person(obj, handle)
|
2006-01-05 10:42:48 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def edit_person(self, obj, handle):
|
2006-03-04 10:54:16 +05:30
|
|
|
from Editors import EditPerson
|
2006-01-04 03:37:34 +05:30
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
2006-03-01 10:38:11 +05:30
|
|
|
try:
|
2006-03-04 10:54:16 +05:30
|
|
|
EditPerson(self.dbstate, self.uistate, [], person)
|
2006-03-01 10:38:11 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-04 03:37:34 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def edit_family(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-03-04 10:54:16 +05:30
|
|
|
from Editors import EditFamily
|
2006-01-12 05:36:33 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(handle)
|
2006-03-01 10:38:11 +05:30
|
|
|
try:
|
2006-04-08 11:26:31 +05:30
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-01 10:38:11 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-11 00:40:39 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def add_family(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-03-04 10:54:16 +05:30
|
|
|
from Editors import EditFamily
|
2007-10-08 22:11:39 +05:30
|
|
|
family = gen.lib.Family()
|
2006-03-07 09:05:46 +05:30
|
|
|
person = self.dbstate.active
|
2007-02-05 03:10:27 +05:30
|
|
|
if not person:
|
|
|
|
return
|
2006-03-07 09:05:46 +05:30
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
if person.gender == gen.lib.Person.MALE:
|
2006-03-07 09:05:46 +05:30
|
|
|
family.set_father_handle(person.handle)
|
|
|
|
else:
|
|
|
|
family.set_mother_handle(person.handle)
|
|
|
|
|
|
|
|
try:
|
2006-04-08 11:26:31 +05:30
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-07 09:05:46 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
|
2006-11-09 09:48:18 +05:30
|
|
|
def add_spouse(self, obj):
|
|
|
|
from Editors import EditFamily
|
2007-10-08 22:11:39 +05:30
|
|
|
family = gen.lib.Family()
|
2006-11-09 09:48:18 +05:30
|
|
|
person = self.dbstate.active
|
2007-05-15 09:47:12 +05:30
|
|
|
|
|
|
|
if not person:
|
|
|
|
return
|
2006-11-09 09:48:18 +05:30
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
if person.gender == gen.lib.Person.MALE:
|
2006-11-09 09:48:18 +05:30
|
|
|
family.set_father_handle(person.handle)
|
|
|
|
else:
|
|
|
|
family.set_mother_handle(person.handle)
|
|
|
|
|
|
|
|
try:
|
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
|
2006-12-30 23:19:08 +05:30
|
|
|
def edit_active(self, obj):
|
|
|
|
phandle = self.dbstate.get_active_person().handle
|
|
|
|
self.edit_person(obj, phandle)
|
|
|
|
|
2008-02-14 18:28:57 +05:30
|
|
|
def add_child_to_fam(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2008-02-16 04:14:39 +05:30
|
|
|
callback = lambda x: self.callback_add_child(x, handle)
|
|
|
|
from Editors import EditPerson
|
|
|
|
person = gen.lib.Person()
|
|
|
|
family = self.dbstate.db.get_family_from_handle(handle)
|
|
|
|
father = self.dbstate.db.get_person_from_handle(
|
|
|
|
family.get_father_handle())
|
|
|
|
if father:
|
|
|
|
name = father.get_primary_name().get_surname()
|
|
|
|
person.get_primary_name().set_surname(name)
|
|
|
|
try:
|
|
|
|
EditPerson(self.dbstate, self.uistate, [], person,
|
|
|
|
callback=callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2008-02-14 18:28:57 +05:30
|
|
|
|
|
|
|
def callback_add_child(self, person, family_handle):
|
|
|
|
ref = gen.lib.ChildRef()
|
|
|
|
ref.ref = person.get_handle()
|
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
|
|
|
family.add_child_ref(ref)
|
|
|
|
|
|
|
|
trans = self.dbstate.db.transaction_begin()
|
|
|
|
#add parentref to child
|
|
|
|
person.add_parent_family_handle(family_handle)
|
|
|
|
#default relationship is used
|
|
|
|
self.dbstate.db.commit_person(person, trans)
|
|
|
|
#add child to family
|
|
|
|
self.dbstate.db.commit_family(family, trans)
|
|
|
|
self.dbstate.db.transaction_commit(trans, _("Add Child to Family"))
|
|
|
|
|
2008-04-20 10:22:53 +05:30
|
|
|
def sel_child_to_fam(self, obj, event, handle, surname=None):
|
2008-02-14 18:28:57 +05:30
|
|
|
from Selectors import selector_factory
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2008-02-16 04:14:39 +05:30
|
|
|
SelectPerson = selector_factory('Person')
|
|
|
|
family = self.dbstate.db.get_family_from_handle(handle)
|
|
|
|
# it only makes sense to skip those who are already in the family
|
|
|
|
skip_list = [family.get_father_handle(), \
|
|
|
|
family.get_mother_handle()] + \
|
|
|
|
[x.ref for x in family.get_child_ref_list() ]
|
|
|
|
|
|
|
|
sel = SelectPerson(self.dbstate, self.uistate, [],
|
|
|
|
_("Select Child"), skip=skip_list)
|
|
|
|
person = sel.run()
|
|
|
|
|
|
|
|
if person:
|
|
|
|
self.callback_add_child(person, handle)
|
2008-02-14 18:28:57 +05:30
|
|
|
|
2006-04-07 08:24:33 +05:30
|
|
|
def select_family(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-05-15 21:23:42 +05:30
|
|
|
from Selectors import selector_factory
|
|
|
|
SelectFamily = selector_factory('Family')
|
2006-04-07 08:24:33 +05:30
|
|
|
|
2006-05-27 02:18:40 +05:30
|
|
|
phandle = self.dbstate.get_active_person().handle
|
|
|
|
person = self.dbstate.db.get_person_from_handle(phandle)
|
|
|
|
skip = set(person.get_family_handle_list())
|
|
|
|
|
|
|
|
dialog = SelectFamily(self.dbstate, self.uistate, skip=skip)
|
2006-04-07 08:24:33 +05:30
|
|
|
family = dialog.run()
|
|
|
|
|
2006-04-07 08:27:05 +05:30
|
|
|
if family:
|
2006-04-22 08:53:57 +05:30
|
|
|
active_handle = self.dbstate.active.handle
|
|
|
|
child = self.dbstate.db.get_person_from_handle(active_handle)
|
2006-04-24 09:36:17 +05:30
|
|
|
|
2007-10-08 09:32:34 +05:30
|
|
|
gen.utils.add_child_to_family(
|
2006-04-24 09:36:17 +05:30
|
|
|
self.dbstate.db,
|
|
|
|
family,
|
|
|
|
child)
|
2006-11-09 09:48:18 +05:30
|
|
|
|
2006-11-17 10:47:13 +05:30
|
|
|
def select_parents(self, obj):
|
|
|
|
from Selectors import selector_factory
|
|
|
|
SelectFamily = selector_factory('Family')
|
|
|
|
|
|
|
|
phandle = self.dbstate.get_active_person().handle
|
|
|
|
person = self.dbstate.db.get_person_from_handle(phandle)
|
2008-01-17 15:27:57 +05:30
|
|
|
skip = set(person.get_family_handle_list()+
|
|
|
|
person.get_parent_family_handle_list())
|
2006-11-17 10:47:13 +05:30
|
|
|
|
|
|
|
dialog = SelectFamily(self.dbstate, self.uistate, skip=skip)
|
|
|
|
family = dialog.run()
|
|
|
|
|
|
|
|
if family:
|
|
|
|
active_handle = self.dbstate.active.handle
|
|
|
|
child = self.dbstate.db.get_person_from_handle(active_handle)
|
|
|
|
|
2007-10-08 09:32:34 +05:30
|
|
|
gen.utils.add_child_to_family(
|
2006-11-17 10:47:13 +05:30
|
|
|
self.dbstate.db,
|
|
|
|
family,
|
|
|
|
child)
|
|
|
|
|
2006-11-09 09:48:18 +05:30
|
|
|
def add_parents(self, obj):
|
|
|
|
from Editors import EditFamily
|
2007-10-08 22:11:39 +05:30
|
|
|
family = gen.lib.Family()
|
2006-11-09 09:48:18 +05:30
|
|
|
person = self.dbstate.active
|
|
|
|
|
2007-05-15 09:47:12 +05:30
|
|
|
if not person:
|
|
|
|
return
|
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
ref = gen.lib.ChildRef()
|
2006-11-09 09:48:18 +05:30
|
|
|
ref.ref = person.handle
|
|
|
|
family.add_child_ref(ref)
|
|
|
|
|
|
|
|
try:
|
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-04-07 08:24:33 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def add_parent_family(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-03-07 09:05:46 +05:30
|
|
|
from Editors import EditFamily
|
2007-10-08 22:11:39 +05:30
|
|
|
family = gen.lib.Family()
|
2006-03-07 09:05:46 +05:30
|
|
|
person = self.dbstate.active
|
2006-04-13 21:46:00 +05:30
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
ref = gen.lib.ChildRef()
|
2006-04-13 21:46:00 +05:30
|
|
|
ref.ref = person.handle
|
|
|
|
family.add_child_ref(ref)
|
2006-03-07 09:05:46 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
try:
|
2006-04-08 11:26:31 +05:30
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-01 10:38:11 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-11 00:40:39 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def delete_family(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2007-10-08 09:32:34 +05:30
|
|
|
gen.utils.remove_parent_from_family(self.dbstate.db,
|
|
|
|
self.dbstate.active.handle,
|
|
|
|
handle)
|
2006-03-18 07:00:23 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def delete_parent_family(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2007-10-08 09:32:34 +05:30
|
|
|
gen.utils.remove_child_from_family(self.dbstate.db,
|
|
|
|
self.dbstate.active.handle,
|
|
|
|
handle)
|
2006-01-11 00:40:39 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def change_to(self, obj, handle):
|
2006-01-04 03:37:34 +05:30
|
|
|
self.dbstate.change_active_handle(handle)
|
2006-10-31 23:06:38 +05:30
|
|
|
|
2009-03-25 17:31:50 +05:30
|
|
|
def reorder_button_press(self, obj, event, handle):
|
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
|
|
|
self.reorder(obj)
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def reorder(self, obj, dumm1=None, dummy2=None):
|
2006-10-31 23:06:38 +05:30
|
|
|
if self.dbstate.active:
|
|
|
|
try:
|
2007-01-09 10:02:07 +05:30
|
|
|
import Reorder
|
|
|
|
Reorder.Reorder(self.dbstate, self.uistate, [],
|
|
|
|
self.dbstate.active.handle)
|
2006-10-31 23:06:38 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2007-09-09 03:36:30 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Function to return if person has children
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def has_children(db,p):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return if a person has children.
|
2007-09-09 03:36:30 +05:30
|
|
|
"""
|
|
|
|
for family_handle in p.get_family_handle_list():
|
|
|
|
family = db.get_family_from_handle(family_handle)
|
|
|
|
childlist = family.get_child_ref_list()
|
|
|
|
if childlist and len(childlist) > 0:
|
|
|
|
return True
|
|
|
|
return False
|
2008-02-23 03:39:39 +05:30
|
|
|
|
|
|
|
def button_activated(event, mouse_button):
|
|
|
|
if (event.type == gtk.gdk.BUTTON_PRESS and \
|
|
|
|
event.button == mouse_button) or \
|
|
|
|
(event.type == gtk.gdk.KEY_PRESS and \
|
|
|
|
event.keyval in (_RETURN, _KP_ENTER)):
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|