2006-01-08 11:14:19 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-05-02 11:20:46 +05:30
|
|
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
2006-01-08 11:14:19 +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
|
|
|
"""
|
2009-11-08 22:11:49 +05:30
|
|
|
Family View.
|
2007-01-09 10:02:07 +05:30
|
|
|
"""
|
|
|
|
|
2008-02-19 01:37:09 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
2009-11-08 22:11:49 +05:30
|
|
|
import logging
|
|
|
|
_LOG = logging.getLogger(".plugins.eventview")
|
2008-02-19 01:37:09 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK+ modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
2006-01-08 11:14:19 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2009-10-08 02:21:12 +05:30
|
|
|
from gui.views.listview import ListView
|
2009-11-08 22:11:49 +05:30
|
|
|
from gui.views.treemodels import FamilyModel
|
2009-12-15 11:26:12 +05:30
|
|
|
from gui.editors import EditFamily
|
2006-04-27 03:18:13 +05:30
|
|
|
import Bookmarks
|
2006-03-01 10:38:11 +05:30
|
|
|
import Errors
|
2009-10-08 06:42:51 +05:30
|
|
|
import config
|
2006-08-05 10:11:56 +05:30
|
|
|
from Filters.SideBar import FamilySidebarFilter
|
2009-10-24 19:23:20 +05:30
|
|
|
from gen.plug import CATEGORY_QR_FAMILY
|
2006-01-08 11:14:19 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2009-11-08 22:11:49 +05:30
|
|
|
# FamilyView
|
2006-01-08 11:14:19 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-11-08 22:11:49 +05:30
|
|
|
class FamilyView(ListView):
|
2007-09-25 17:39:25 +05:30
|
|
|
|
|
|
|
COLUMN_NAMES = [
|
|
|
|
_('ID'),
|
|
|
|
_('Father'),
|
|
|
|
_('Mother'),
|
|
|
|
_('Relationship'),
|
|
|
|
_('Marriage Date'),
|
|
|
|
_('Last Changed'),
|
|
|
|
]
|
2006-05-08 06:45:19 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
ADD_MSG = _("Add a new family")
|
|
|
|
EDIT_MSG = _("Edit the selected family")
|
|
|
|
DEL_MSG = _("Delete the selected family")
|
|
|
|
FILTER_TYPE = "Family"
|
2007-08-31 01:19:04 +05:30
|
|
|
QR_CATEGORY = CATEGORY_QR_FAMILY
|
2007-01-09 10:02:07 +05:30
|
|
|
|
|
|
|
def __init__(self, dbstate, uistate):
|
2006-01-08 11:14:19 +05:30
|
|
|
|
|
|
|
signal_map = {
|
2007-01-20 09:52:31 +05:30
|
|
|
'family-add' : self.row_add,
|
|
|
|
'family-update' : self.row_update,
|
|
|
|
'family-delete' : self.row_delete,
|
2007-10-03 22:04:51 +05:30
|
|
|
'family-rebuild' : self.object_build,
|
2006-01-08 11:14:19 +05:30
|
|
|
}
|
|
|
|
|
2009-10-08 02:21:12 +05:30
|
|
|
ListView.__init__(
|
2008-01-25 01:32:09 +05:30
|
|
|
self, _('Families'), dbstate, uistate,
|
2009-11-08 22:11:49 +05:30
|
|
|
FamilyView.COLUMN_NAMES, len(FamilyView.COLUMN_NAMES),
|
|
|
|
FamilyModel,
|
2006-04-27 03:18:13 +05:30
|
|
|
signal_map, dbstate.db.get_family_bookmarks(),
|
2006-07-10 09:04:19 +05:30
|
|
|
Bookmarks.FamilyBookmarks, filter_class=FamilySidebarFilter)
|
2009-06-29 19:07:15 +05:30
|
|
|
|
2009-10-08 02:21:12 +05:30
|
|
|
self.func_list = {
|
|
|
|
'<CONTROL>J' : self.jump,
|
|
|
|
'<CONTROL>BackSpace' : self.key_delete,
|
|
|
|
}
|
|
|
|
|
2009-10-08 06:42:51 +05:30
|
|
|
config.connect("interface.filter",
|
|
|
|
self.filter_toggle)
|
2006-07-11 03:16:46 +05:30
|
|
|
|
2009-06-29 19:07:15 +05:30
|
|
|
def column_ord_setfunc(self, clist):
|
2009-06-30 19:12:25 +05:30
|
|
|
self.dbstate.db.set_family_list_column_order(clist)
|
2009-06-29 19:07:15 +05:30
|
|
|
|
2006-01-08 11:14:19 +05:30
|
|
|
def column_order(self):
|
|
|
|
return self.dbstate.db.get_family_list_column_order()
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _column_editor(self, obj):
|
2006-08-25 01:41:23 +05:30
|
|
|
import ColumnOrder
|
|
|
|
|
|
|
|
ColumnOrder.ColumnOrder(
|
2008-01-25 01:32:09 +05:30
|
|
|
_('Select Family Columns'),
|
2006-08-25 01:41:23 +05:30
|
|
|
self.uistate,
|
|
|
|
self.dbstate.db.get_family_list_column_order(),
|
2009-11-08 22:11:49 +05:30
|
|
|
FamilyView.COLUMN_NAMES,
|
2006-08-25 01:41:23 +05:30
|
|
|
self.set_column_order)
|
|
|
|
|
2006-01-08 11:14:19 +05:30
|
|
|
def get_stock(self):
|
2007-02-21 01:28:47 +05:30
|
|
|
return 'gramps-family'
|
2006-07-12 02:26:59 +05:30
|
|
|
|
2006-01-08 11:14:19 +05:30
|
|
|
def ui_definition(self):
|
|
|
|
return '''<ui>
|
|
|
|
<menubar name="MenuBar">
|
2007-02-06 10:49:16 +05:30
|
|
|
<menu action="FileMenu">
|
|
|
|
<placeholder name="LocalExport">
|
|
|
|
<menuitem action="ExportTab"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2006-01-08 11:14:19 +05:30
|
|
|
<menu action="EditMenu">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</placeholder>
|
2006-05-03 23:09:06 +05:30
|
|
|
<menuitem action="ColumnEdit"/>
|
2006-07-10 23:15:18 +05:30
|
|
|
<menuitem action="FilterEdit"/>
|
2006-01-08 11:14:19 +05:30
|
|
|
</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-08 11:14:19 +05:30
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<toolitem action="Add"/>
|
|
|
|
<toolitem action="Edit"/>
|
|
|
|
<toolitem action="Remove"/>
|
|
|
|
</placeholder>
|
|
|
|
</toolbar>
|
|
|
|
<popup name="Popup">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
2007-08-31 01:19:04 +05:30
|
|
|
<separator/>
|
|
|
|
<menu name="QuickReport" action="QuickReport">
|
|
|
|
<menuitem action="Dummy"/>
|
|
|
|
</menu>
|
2006-01-08 11:14:19 +05:30
|
|
|
</popup>
|
|
|
|
</ui>'''
|
|
|
|
|
2007-07-08 08:57:06 +05:30
|
|
|
def define_actions(self):
|
2008-01-25 01:32:09 +05:30
|
|
|
"""Add the Forward action group to handle the Forward button."""
|
2007-07-08 08:57:06 +05:30
|
|
|
|
2009-10-08 02:21:12 +05:30
|
|
|
ListView.define_actions(self)
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
2008-01-29 02:52:06 +05:30
|
|
|
_('_Column Editor...'), callback=self._column_editor)
|
2007-07-08 08:57:06 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action('FilterEdit', None, _('Family Filter Editor'),
|
2007-07-08 08:57:06 +05:30
|
|
|
callback=self.filter_editor,)
|
2007-08-31 01:19:04 +05:30
|
|
|
|
|
|
|
self.all_action = gtk.ActionGroup(self.title + "/FamilyAll")
|
|
|
|
self.all_action.add_actions([
|
2009-01-11 01:03:55 +05:30
|
|
|
('QuickReport', None, _("Quick View"), None, None, None),
|
2007-08-31 01:19:04 +05:30
|
|
|
('Dummy', None, ' ', None, None, self.dummy_report),
|
|
|
|
])
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action_group(self.all_action)
|
2007-07-08 08:57:06 +05:30
|
|
|
|
|
|
|
def get_bookmarks(self):
|
|
|
|
return self.dbstate.db.get_family_bookmarks()
|
|
|
|
|
|
|
|
def add_bookmark(self, obj):
|
2008-07-26 17:29:37 +05:30
|
|
|
mlist = self.selected_handles()
|
2007-07-08 08:57:06 +05:30
|
|
|
if mlist:
|
|
|
|
self.bookmarks.add(mlist[0])
|
|
|
|
else:
|
|
|
|
from QuestionDialog import WarningDialog
|
|
|
|
WarningDialog(
|
|
|
|
_("Could Not Set a Bookmark"),
|
|
|
|
_("A bookmark could not be set because "
|
|
|
|
"no one was selected."))
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def add(self, obj):
|
2007-10-08 22:11:39 +05:30
|
|
|
family = gen.lib.Family()
|
2006-03-01 10:38:11 +05:30
|
|
|
try:
|
2007-01-09 10:02:07 +05:30
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-01 10:38:11 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-08 11:14:19 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def remove(self, obj):
|
2009-09-23 18:37:12 +05:30
|
|
|
from QuestionDialog import QuestionDialog2
|
|
|
|
from Utils import data_recover_msg
|
|
|
|
msg = _('Deleting item will remove it from the database.')
|
|
|
|
msg = msg + '\n' + data_recover_msg
|
|
|
|
q = QuestionDialog2(_('Delete %s?') % _('family'), msg,
|
|
|
|
_('_Delete Item'), _('Cancel'))
|
|
|
|
if q.run():
|
|
|
|
self.uistate.set_busy_cursor(1)
|
|
|
|
for handle in self.selected_handles():
|
2009-12-21 09:48:31 +05:30
|
|
|
self.dbstate.db.remove_family_relationships(handle)
|
2009-09-23 18:37:12 +05:30
|
|
|
self.build_tree()
|
|
|
|
self.uistate.set_busy_cursor(0)
|
2006-01-12 11:10:44 +05:30
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def edit(self, obj):
|
2008-07-26 17:29:37 +05:30
|
|
|
for handle in self.selected_handles():
|
2006-01-12 11:10:44 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(handle)
|
2006-03-01 10:38:11 +05:30
|
|
|
try:
|
2007-01-09 10:02:07 +05:30
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-01 10:38:11 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2007-08-31 01:19:04 +05:30
|
|
|
|
|
|
|
def dummy_report(self, obj):
|
2008-02-18 21:22:40 +05:30
|
|
|
""" For the xml UI definition of popup to work, the submenu
|
2007-08-31 01:19:04 +05:30
|
|
|
Quick Report must have an entry in the xml
|
|
|
|
As this submenu will be dynamically built, we offer a dummy action
|
2008-02-18 21:22:40 +05:30
|
|
|
"""
|
2007-08-31 01:19:04 +05:30
|
|
|
pass
|