add family selector

svn: r6277
This commit is contained in:
Don Allingham 2006-04-06 03:35:19 +00:00
parent 20a55cdaa2
commit a3f8782e32
3 changed files with 163 additions and 1 deletions

View File

@ -1,9 +1,11 @@
2006-04-05 Don Allingham <don@gramps-project.org>
* src/SelectFamily.py: added
* src/GrampsDb/_ReadXML.py: support new lds stuff
* src/GrampsDb/_WriteXML.py: support new lds stuff
* src/GrampsDb/_ReadGedcom.py: support new lds stuff
* src/GrampsDb/_WriteGedcom.py: support new lds stuff
* src/Editors/_EditLdsOrd.py: save place information
* src/Editors/_EditLdsOrd.py: save place information, connect
family dialog (SelectFamily)
* src/GrampsWidgets.py: select default value in menu
* src/BaseDoc.py: pylint
* src/DisplayTabs.py: handle temple not set for LdsOrd

View File

@ -51,6 +51,7 @@ import const
import Utils
import RelLib
import GrampsDisplay
import NameDisplay
import lds
from _EditSecondary import EditSecondary
@ -122,6 +123,7 @@ class EditLdsOrd(EditSecondary):
_('LDS Ordinance Editor'))
def _connect_signals(self):
self.parents_select.connect('clicked',self.select_parents_clicked)
self.define_cancel_button(self.top.get_widget('cancel'))
self.define_help_button(self.top.get_widget('help'),'adv-at')
self.define_ok_button(self.top.get_widget('ok'),self.save)
@ -176,6 +178,9 @@ class EditLdsOrd(EditSecondary):
self._data_map[self.obj.get_type()],
self.db.readonly)
self.ord_type_changed()
self.update_parent_label()
def ord_type_changed(self):
if self.obj.get_type() == RelLib.LdsOrd.BAPTISM:
self.parents.hide()
@ -206,6 +211,46 @@ class EditLdsOrd(EditSecondary):
notebook.show_all()
vbox = self.top.get_widget('vbox').pack_start(notebook,True)
def select_parents_clicked(self, obj):
from SelectFamily import SelectFamily
dialog = SelectFamily(self.dbstate.db, _('Select Family'))
family = dialog.run()
if family:
self.obj.set_family_handle(family.handle)
self.update_parent_label()
def update_parent_label(self):
handle = self.obj.get_family_handle()
if handle:
family = self.dbstate.db.get_family_from_handle(handle)
f = self.dbstate.db.get_person_from_handle(family.get_father_handle())
m = self.dbstate.db.get_person_from_handle(family.get_mother_handle())
if f and m:
label = _("%(father)s and %(mother)s [%(gramps_id)s]") % {
'father' : NameDisplay.displayer.display(f),
'mother' : NameDisplay.displayer.display(m),
'gramps_id' : family.gramps_id,
}
elif f:
label = _("%(father)s [%(gramps_id)s]") % {
'father' : NameDisplay.displayer.display(f),
'gramps_id' : family.gramps_id,
}
elif m:
label = _("%(mother)s [%(gramps_id)s]") % {
'mother' : NameDisplay.displayer.display(m),
'gramps_id' : family.gramps_id,
}
else:
label = _("[%(gramps_id)s]") % {
'gramps_id' : family.gramps_id,
}
else:
label = ""
self.parents.set_text(label)
def build_menu_names(self, attrib):
label = _("LDS Ordinance")
return (label, _('LDS Ordinance Editor'))

115
src/SelectFamily.py Normal file
View File

@ -0,0 +1,115 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2004 Donald N. Allingham
#
# 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: SelectFamily.py 6183 2006-03-21 02:39:01Z dallingham $
#-------------------------------------------------------------------------
#
# internationalization
#
#-------------------------------------------------------------------------
from TransUtils import sgettext as _
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import pango
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
import const
import Utils
import DisplayModels
#-------------------------------------------------------------------------
#
# SelectFamily
#
#-------------------------------------------------------------------------
class SelectFamily:
def __init__(self, db, title, filter=None, skip=[], parent_window=None):
self.renderer = gtk.CellRendererText()
self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
self.db = db
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
self.top = self.glade.get_widget('select_person')
self.plist = self.glade.get_widget('plist')
self.notebook = self.glade.get_widget('notebook')
Utils.set_titles(self.top,
self.glade.get_widget('title'),
title)
self.model = DisplayModels.FamilyModel(self.db)
self.add_columns(self.plist)
self.plist.set_model(self.model)
self.top.show()
if parent_window:
self.top.set_transient_for(parent_window)
def add_columns(self,tree):
column = gtk.TreeViewColumn(_('ID'), self.renderer, text=0)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(75)
tree.append_column(column)
tree.set_fixed_height_mode(True)
column = gtk.TreeViewColumn(_('Father'), self.renderer, text=1)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(200)
tree.append_column(column)
column = gtk.TreeViewColumn(_('Mother'), self.renderer, text=2)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(200)
tree.append_column(column)
def select_function(self,store,path,iter,id_list):
id_list.append(self.model.get_value(iter,5))
def get_selected_ids(self):
mlist = []
self.plist.get_selection().selected_foreach(self.select_function,mlist)
return mlist
def run(self):
val = self.top.run()
if val == gtk.RESPONSE_OK:
idlist = self.get_selected_ids()
self.top.destroy()
if idlist and idlist[0]:
return_value = self.db.get_family_from_handle(idlist[0])
else:
return_value = None
return return_value
else:
self.top.destroy()
return None