2006-01-08 05:44:19 +00:00
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-05-02 05:50:46 +00:00
|
|
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
2006-01-08 05:44:19 +00:00
|
|
|
#
|
|
|
|
# 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 04:32:07 +00:00
|
|
|
"""
|
|
|
|
FamilyList View
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Don Allingham"
|
|
|
|
__revision__ = "$Revision$"
|
|
|
|
|
2006-01-08 05:44:19 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import PageView
|
|
|
|
import DisplayModels
|
2006-04-26 21:48:13 +00:00
|
|
|
import Bookmarks
|
2006-03-01 05:08:11 +00:00
|
|
|
import Errors
|
2006-07-10 21:46:46 +00:00
|
|
|
import Config
|
2006-08-05 04:41:56 +00:00
|
|
|
from Filters.SideBar import FamilySidebarFilter
|
2006-01-08 05:44:19 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-06 22:02:46 +00:00
|
|
|
from gettext import gettext as _
|
2006-08-24 20:11:23 +00:00
|
|
|
import gtk
|
2006-01-08 05:44:19 +00:00
|
|
|
|
|
|
|
column_names = [
|
2006-01-09 00:54:04 +00:00
|
|
|
_('ID'),
|
2006-01-08 05:44:19 +00:00
|
|
|
_('Father'),
|
|
|
|
_('Mother'),
|
|
|
|
_('Relationship'),
|
|
|
|
_('Last Changed'),
|
|
|
|
]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# FamilyListView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class FamilyListView(PageView.ListView):
|
2006-05-08 01:15:19 +00:00
|
|
|
|
2007-01-09 04:32:07 +00:00
|
|
|
ADD_MSG = _("Add a new family")
|
|
|
|
EDIT_MSG = _("Edit the selected family")
|
|
|
|
DEL_MSG = _("Delete the selected family")
|
|
|
|
FILTER_TYPE = "Family"
|
|
|
|
|
|
|
|
def __init__(self, dbstate, uistate):
|
2006-01-08 05:44:19 +00:00
|
|
|
|
|
|
|
signal_map = {
|
2007-01-20 04:22:31 +00:00
|
|
|
'family-add' : self.row_add,
|
|
|
|
'family-update' : self.row_update,
|
|
|
|
'family-delete' : self.row_delete,
|
2006-01-08 05:44:19 +00:00
|
|
|
'family-rebuild' : self.build_tree,
|
|
|
|
}
|
|
|
|
|
2007-01-26 00:15:21 +00:00
|
|
|
self.func_list = {
|
|
|
|
'<CONTROL>J' : self.jump,
|
2007-01-26 05:09:25 +00:00
|
|
|
'<CONTROL>BackSpace' : self.key_delete,
|
2007-01-26 00:15:21 +00:00
|
|
|
}
|
|
|
|
|
2006-04-22 22:09:16 +00:00
|
|
|
PageView.ListView.__init__(
|
|
|
|
self, _('Family List'), dbstate, uistate,
|
|
|
|
column_names, len(column_names), DisplayModels.FamilyModel,
|
2006-04-26 21:48:13 +00:00
|
|
|
signal_map, dbstate.db.get_family_bookmarks(),
|
2006-07-10 03:34:19 +00:00
|
|
|
Bookmarks.FamilyBookmarks, filter_class=FamilySidebarFilter)
|
2006-04-22 22:09:16 +00:00
|
|
|
|
2006-03-10 21:13:48 +00:00
|
|
|
self.updating = False
|
2006-01-08 05:44:19 +00:00
|
|
|
|
2006-07-10 21:46:46 +00:00
|
|
|
Config.client.notify_add("/apps/gramps/interface/filter",
|
|
|
|
self.filter_toggle)
|
|
|
|
|
2006-07-10 17:45:18 +00:00
|
|
|
def define_actions(self):
|
2007-01-09 04:32:07 +00:00
|
|
|
"""
|
|
|
|
add the Forward action group to handle the Forward button
|
|
|
|
"""
|
2006-07-10 17:45:18 +00:00
|
|
|
|
|
|
|
PageView.ListView.define_actions(self)
|
2006-08-24 20:11:23 +00:00
|
|
|
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
|
|
|
_('_Column Editor'), callback=self.column_editor)
|
2006-07-10 17:45:18 +00:00
|
|
|
|
|
|
|
self.add_action('FilterEdit', None, _('Family Filter Editor'),
|
|
|
|
callback=self.filter_editor,)
|
|
|
|
|
2006-04-26 21:48:13 +00:00
|
|
|
def add_bookmark(self, obj):
|
|
|
|
mlist = []
|
|
|
|
self.selection.selected_foreach(self.blist, mlist)
|
|
|
|
|
|
|
|
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."))
|
|
|
|
|
|
|
|
def get_bookmarks(self):
|
|
|
|
return self.dbstate.db.get_family_bookmarks()
|
|
|
|
|
2006-01-08 05:44:19 +00:00
|
|
|
def column_order(self):
|
|
|
|
return self.dbstate.db.get_family_list_column_order()
|
|
|
|
|
2007-01-09 04:32:07 +00:00
|
|
|
def column_editor(self, obj):
|
2006-08-24 20:11:23 +00:00
|
|
|
import ColumnOrder
|
|
|
|
|
|
|
|
ColumnOrder.ColumnOrder(
|
|
|
|
_('Select Family List Columns'),
|
|
|
|
self.uistate,
|
|
|
|
self.dbstate.db.get_family_list_column_order(),
|
|
|
|
column_names,
|
|
|
|
self.set_column_order)
|
|
|
|
|
2007-01-09 04:32:07 +00:00
|
|
|
def set_column_order(self, clist):
|
|
|
|
self.dbstate.db.set_family_list_column_order(clist)
|
2006-08-24 20:11:23 +00:00
|
|
|
self.build_columns()
|
|
|
|
|
2006-01-08 05:44:19 +00:00
|
|
|
def get_stock(self):
|
|
|
|
return 'gramps-family-list'
|
2006-07-11 20:56:59 +00:00
|
|
|
|
2006-01-08 05:44:19 +00:00
|
|
|
def ui_definition(self):
|
|
|
|
return '''<ui>
|
|
|
|
<menubar name="MenuBar">
|
|
|
|
<menu action="EditMenu">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</placeholder>
|
2006-05-03 17:39:06 +00:00
|
|
|
<menuitem action="ColumnEdit"/>
|
2006-07-10 17:45:18 +00:00
|
|
|
<menuitem action="FilterEdit"/>
|
2006-01-08 05:44:19 +00:00
|
|
|
</menu>
|
2006-04-26 21:48:13 +00:00
|
|
|
<menu action="BookMenu">
|
|
|
|
<placeholder name="AddEditBook">
|
|
|
|
<menuitem action="AddBook"/>
|
|
|
|
<menuitem action="EditBook"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2006-01-08 05:44:19 +00:00
|
|
|
</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"/>
|
|
|
|
</popup>
|
|
|
|
</ui>'''
|
|
|
|
|
2007-01-09 04:32:07 +00:00
|
|
|
def add(self, obj):
|
2006-03-04 05:24:16 +00:00
|
|
|
from Editors import EditFamily
|
2006-02-06 23:44:09 +00:00
|
|
|
family = RelLib.Family()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2007-01-09 04:32:07 +00:00
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-08 05:44:19 +00:00
|
|
|
|
2007-01-09 04:32:07 +00:00
|
|
|
def remove(self, obj):
|
2007-01-23 03:37:13 +00:00
|
|
|
self.uistate.set_busy_cursor(1)
|
2006-03-18 01:30:23 +00:00
|
|
|
import GrampsDb
|
|
|
|
|
2006-03-10 22:38:45 +00:00
|
|
|
mlist = []
|
2006-03-18 03:21:03 +00:00
|
|
|
self.selection.selected_foreach(self.blist, mlist)
|
2006-03-10 22:38:45 +00:00
|
|
|
|
|
|
|
for handle in mlist:
|
2006-03-18 03:21:03 +00:00
|
|
|
GrampsDb.remove_family_relationships(self.dbstate.db, handle)
|
2006-03-10 22:38:45 +00:00
|
|
|
self.build_tree()
|
2007-01-23 03:37:13 +00:00
|
|
|
self.uistate.set_busy_cursor(0)
|
2006-01-12 05:40:44 +00:00
|
|
|
|
2007-01-09 04:32:07 +00:00
|
|
|
def edit(self, obj):
|
2006-01-12 05:40:44 +00:00
|
|
|
mlist = []
|
2007-01-09 04:32:07 +00:00
|
|
|
self.selection.selected_foreach(self.blist, mlist)
|
2006-01-12 05:40:44 +00:00
|
|
|
|
|
|
|
for handle in mlist:
|
2006-03-04 05:24:16 +00:00
|
|
|
from Editors import EditFamily
|
2006-01-12 05:40:44 +00:00
|
|
|
family = self.dbstate.db.get_family_from_handle(handle)
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2007-01-09 04:32:07 +00:00
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2007-01-26 00:15:21 +00:00
|
|
|
|
|
|
|
def get_handle_from_gramps_id(self, gid):
|
|
|
|
obj = self.dbstate.db.get_family_from_gramps_id(gid)
|
|
|
|
if obj:
|
|
|
|
return obj.get_handle()
|
|
|
|
else:
|
|
|
|
return None
|