2006-01-12 05:37:11 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2005 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$
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import cPickle as pickle
|
|
|
|
import gc
|
|
|
|
import sys
|
2006-01-13 06:15:22 +05:30
|
|
|
from gettext import gettext as _
|
2006-01-12 05:37:11 +05:30
|
|
|
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gobject
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import NameDisplay
|
|
|
|
import DisplayState
|
|
|
|
import Spell
|
|
|
|
import GrampsDisplay
|
|
|
|
import RelLib
|
|
|
|
import ReportUtils
|
2006-01-13 06:15:22 +05:30
|
|
|
import DisplayTabs
|
2006-01-14 03:58:54 +05:30
|
|
|
import AutoComp
|
|
|
|
import GrampsWidgets
|
2006-01-12 05:37:11 +05:30
|
|
|
|
|
|
|
from DdTargets import DdTargets
|
|
|
|
from WindowUtils import GladeIf
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-13 09:24:31 +05:30
|
|
|
class AttrEmbedList(DisplayTabs.EmbeddedList):
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
_HANDLE_COL = -1
|
|
|
|
|
2006-01-13 09:24:31 +05:30
|
|
|
column_names = [
|
|
|
|
(_('Type'),0),
|
|
|
|
(_('Value'),1),
|
|
|
|
]
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
def __init__(self,dbstate,uistate,track,data):
|
2006-01-13 09:24:31 +05:30
|
|
|
self.data = data
|
|
|
|
self.hbox = gtk.HBox()
|
|
|
|
self.label = gtk.Label(_('Attributes'))
|
|
|
|
self.hbox.show_all()
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
DisplayTabs.EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
DisplayTabs.FamilyAttrModel)
|
|
|
|
|
2006-01-13 09:24:31 +05:30
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1))
|
|
|
|
|
|
|
|
def set_label(self):
|
|
|
|
if len(self.get_data()):
|
|
|
|
self.label.set_text("<b>%s</b>" % _('Attributes'))
|
|
|
|
self.label.set_use_markup(True)
|
|
|
|
else:
|
|
|
|
self.label.set_text(_('Attributes'))
|
|
|
|
|
|
|
|
def get_tab_widget(self):
|
|
|
|
return self.label
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
class ChildEmbedList(DisplayTabs.EmbeddedList):
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
_HANDLE_COL = 8
|
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
column_names = [
|
|
|
|
(_('#'),0) ,
|
|
|
|
(_('ID'),1) ,
|
|
|
|
(_('Name'),9),
|
|
|
|
(_('Gender'),3),
|
|
|
|
(_('Birth Date'),10),
|
|
|
|
(_('Death Date'),11),
|
|
|
|
(_('Birth Place'),6),
|
|
|
|
(_('Death Place'),7),
|
|
|
|
]
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
def __init__(self,dbstate,uistate,track,family):
|
2006-01-13 06:15:22 +05:30
|
|
|
self.family = family
|
|
|
|
self.hbox = gtk.HBox()
|
|
|
|
self.label = gtk.Label(_('Children'))
|
|
|
|
self.hbox.show_all()
|
2006-01-14 10:57:48 +05:30
|
|
|
DisplayTabs.EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
DisplayTabs.ChildModel)
|
2006-01-13 09:24:31 +05:30
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
def get_data(self):
|
|
|
|
return self.family.get_child_handle_list()
|
|
|
|
|
|
|
|
def column_order(self):
|
2006-01-14 10:57:48 +05:30
|
|
|
return self.dbstate.db.get_child_column_order()
|
2006-01-13 06:15:22 +05:30
|
|
|
|
|
|
|
def set_label(self):
|
|
|
|
if len(self.get_data()):
|
|
|
|
self.label.set_text("<b>%s</b>" % _('Children'))
|
|
|
|
self.label.set_use_markup(True)
|
|
|
|
else:
|
|
|
|
self.label.set_text(_('Children'))
|
|
|
|
|
|
|
|
def get_tab_widget(self):
|
|
|
|
return self.label
|
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
def add_button_clicked(self,obj):
|
|
|
|
print "Add Button Clicked"
|
|
|
|
|
|
|
|
def del_button_clicked(self,obj):
|
2006-01-14 23:32:07 +05:30
|
|
|
handle = self.get_selected()
|
|
|
|
if handle:
|
|
|
|
self.family.remove_child_handle(handle)
|
|
|
|
self.rebuild()
|
2006-01-14 10:57:48 +05:30
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
handle = self.get_selected()
|
|
|
|
if handle:
|
|
|
|
import EditPerson
|
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
|
|
|
EditPerson.EditPerson(self.dbstate,self.uistate,self.track,person)
|
|
|
|
|
2006-01-12 05:37:11 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-01-13 06:15:22 +05:30
|
|
|
# EditFamily
|
2006-01-12 05:37:11 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EditFamily(DisplayState.ManagedWindow):
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,family):
|
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
|
|
|
self.family = family
|
|
|
|
|
|
|
|
DisplayState.ManagedWindow.__init__(self, uistate, track, family)
|
|
|
|
if self.already_exist:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.build_interface()
|
|
|
|
if self.family:
|
|
|
|
self.load_data()
|
|
|
|
|
2006-01-14 03:58:54 +05:30
|
|
|
self.mname = None
|
|
|
|
self.fname = None
|
|
|
|
|
2006-01-12 05:37:11 +05:30
|
|
|
self.show()
|
|
|
|
|
|
|
|
def build_menu_names(self,obj):
|
|
|
|
return ('Edit Family','Undefined Submenu')
|
|
|
|
|
|
|
|
def build_window_key(self,obj):
|
|
|
|
return id(self.family.handle)
|
|
|
|
|
|
|
|
def build_interface(self):
|
|
|
|
self.top = gtk.glade.XML(const.placesFile,"marriageEditor","gramps")
|
|
|
|
self.gladeif = GladeIf(self.top)
|
|
|
|
self.window = self.top.get_widget("marriageEditor")
|
|
|
|
|
|
|
|
self.fbirth = self.top.get_widget('fbirth')
|
|
|
|
self.fdeath = self.top.get_widget('fdeath')
|
|
|
|
|
|
|
|
self.mbirth = self.top.get_widget('mbirth')
|
|
|
|
self.mdeath = self.top.get_widget('mdeath')
|
|
|
|
|
|
|
|
self.gid = self.top.get_widget('gid')
|
2006-01-14 03:58:54 +05:30
|
|
|
self.reltype= self.top.get_widget('marriage_type')
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
self.mbutton= self.top.get_widget('mbutton')
|
|
|
|
self.fbutton= self.top.get_widget('fbutton')
|
|
|
|
|
2006-01-14 03:58:54 +05:30
|
|
|
self.mbox = self.top.get_widget('mbox')
|
|
|
|
self.fbox = self.top.get_widget('fbox')
|
|
|
|
|
2006-01-12 05:37:11 +05:30
|
|
|
self.ok = self.top.get_widget('ok')
|
|
|
|
self.cancel = self.top.get_widget('cancel')
|
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
self.vbox = self.top.get_widget('vbox')
|
2006-01-14 03:58:54 +05:30
|
|
|
self.child_list = self.top.get_widget('child_list')
|
|
|
|
|
|
|
|
rel_types = dict(Utils.family_relations)
|
|
|
|
|
|
|
|
mtype = self.family.get_relationship()
|
|
|
|
if mtype:
|
|
|
|
defval = mtype[0]
|
|
|
|
else:
|
|
|
|
defval = None
|
|
|
|
|
|
|
|
self.type_sel = AutoComp.StandardCustomSelector(
|
|
|
|
rel_types, self.reltype, RelLib.Family.CUSTOM, defval)
|
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
self.notebook = gtk.Notebook()
|
|
|
|
self.notebook.show()
|
|
|
|
|
|
|
|
self.vbox.pack_start(self.notebook,True)
|
2006-01-12 05:37:11 +05:30
|
|
|
self.cancel.connect('clicked', self.close_window)
|
|
|
|
|
|
|
|
def load_data(self):
|
2006-01-14 03:58:54 +05:30
|
|
|
self.update_father(self.family.get_father_handle())
|
|
|
|
self.update_mother(self.family.get_mother_handle())
|
|
|
|
|
|
|
|
self.mbutton.connect('clicked',self.mother_clicked)
|
|
|
|
self.fbutton.connect('clicked',self.father_clicked)
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2006-01-14 10:57:48 +05:30
|
|
|
self.child_list = ChildEmbedList(self.dbstate,self.uistate,
|
|
|
|
self.track, self.family)
|
2006-01-15 06:56:47 +05:30
|
|
|
self.event_list = DisplayTabs.EventEmbedList(self.dbstate,self.uistate,
|
|
|
|
self.track,self.family)
|
2006-01-14 10:57:48 +05:30
|
|
|
self.attr_list = AttrEmbedList(self.dbstate, self.uistate, self.track,
|
|
|
|
self.family.get_attribute_list())
|
2006-01-13 09:24:31 +05:30
|
|
|
self.note_tab = DisplayTabs.NoteTab(self.family.get_note_object())
|
2006-01-14 03:58:54 +05:30
|
|
|
self.gallery_tab = DisplayTabs.GalleryTab(self.dbstate.db,
|
|
|
|
self.family.get_media_list())
|
2006-01-13 06:15:22 +05:30
|
|
|
|
|
|
|
self.notebook.insert_page(self.child_list)
|
|
|
|
self.notebook.set_tab_label(self.child_list,self.child_list.get_tab_widget())
|
|
|
|
|
|
|
|
self.notebook.insert_page(self.event_list)
|
|
|
|
self.notebook.set_tab_label(self.event_list,self.event_list.get_tab_widget())
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2006-01-13 09:24:31 +05:30
|
|
|
self.notebook.insert_page(self.attr_list)
|
|
|
|
self.notebook.set_tab_label(self.attr_list,self.attr_list.get_tab_widget())
|
|
|
|
|
|
|
|
self.notebook.insert_page(self.note_tab)
|
|
|
|
self.notebook.set_tab_label(self.note_tab,self.note_tab.get_tab_widget())
|
|
|
|
|
|
|
|
self.notebook.insert_page(self.gallery_tab)
|
|
|
|
self.notebook.set_tab_label(self.gallery_tab,self.gallery_tab.get_tab_widget())
|
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
self.gid.set_text(self.family.get_gramps_id())
|
|
|
|
|
2006-01-14 03:58:54 +05:30
|
|
|
def update_father(self,handle):
|
|
|
|
self.load_parent(handle, self.fbox, self.fbirth, self.fdeath, self.fbutton)
|
|
|
|
|
|
|
|
def update_mother(self,handle):
|
|
|
|
self.load_parent(handle, self.mbox, self.mbirth, self.mdeath, self.mbutton)
|
|
|
|
|
|
|
|
def mother_clicked(self,obj):
|
|
|
|
handle = self.family.get_mother_handle()
|
|
|
|
if handle:
|
|
|
|
self.family.set_mother_handle(None)
|
|
|
|
self.update_mother(None)
|
|
|
|
else:
|
|
|
|
print "Call person selector"
|
|
|
|
|
|
|
|
def father_clicked(self,obj):
|
|
|
|
handle = self.family.get_father_handle()
|
|
|
|
if handle:
|
|
|
|
self.family.set_father_handle(None)
|
|
|
|
self.update_father(None)
|
|
|
|
else:
|
|
|
|
print "Call person selector"
|
|
|
|
|
|
|
|
def edit_person(self,obj,event,handle):
|
|
|
|
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
|
|
|
|
import EditPerson
|
|
|
|
person = self.dbstate.db.get_person_from_handle(handle)
|
|
|
|
EditPerson.EditPerson(self.dbstate, self.uistate, self.track, person)
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2006-01-14 03:58:54 +05:30
|
|
|
def load_parent(self,handle,box,birth_obj,death_obj,btn_obj):
|
2006-01-13 06:15:22 +05:30
|
|
|
|
|
|
|
is_used = handle != None
|
2006-01-14 03:58:54 +05:30
|
|
|
|
|
|
|
for i in box.get_children():
|
|
|
|
box.remove(i)
|
2006-01-13 06:15:22 +05:30
|
|
|
|
|
|
|
btn_obj.remove(btn_obj.get_children()[0])
|
|
|
|
|
|
|
|
if is_used:
|
2006-01-12 05:37:11 +05:30
|
|
|
db = self.dbstate.db
|
|
|
|
person = db.get_person_from_handle(handle)
|
|
|
|
name = "%s [%s]" % (NameDisplay.displayer.display(person),
|
|
|
|
person.gramps_id)
|
|
|
|
data = ReportUtils.get_birth_death_strings(db,person)
|
|
|
|
birth = data[0]
|
|
|
|
death = data[4]
|
2006-01-13 06:15:22 +05:30
|
|
|
|
|
|
|
del_image = gtk.Image()
|
|
|
|
del_image.show()
|
|
|
|
del_image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON)
|
|
|
|
btn_obj.add(del_image)
|
2006-01-14 03:58:54 +05:30
|
|
|
|
|
|
|
box.pack_start(GrampsWidgets.LinkBox(
|
|
|
|
GrampsWidgets.BasicLabel(name),
|
|
|
|
GrampsWidgets.IconButton(self.edit_person,person.handle)
|
|
|
|
))
|
2006-01-12 05:37:11 +05:30
|
|
|
else:
|
|
|
|
name = ""
|
|
|
|
birth = ""
|
|
|
|
death = ""
|
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
add_image = gtk.Image()
|
|
|
|
add_image.show()
|
|
|
|
add_image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_BUTTON)
|
|
|
|
btn_obj.add(add_image)
|
|
|
|
|
2006-01-12 05:37:11 +05:30
|
|
|
birth_obj.set_text(birth)
|
|
|
|
death_obj.set_text(death)
|
|
|
|
|
|
|
|
def close_window(self,obj):
|
|
|
|
self.close()
|