2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000 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
|
|
|
|
#
|
|
|
|
|
2003-05-18 09:48:12 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk.glade
|
|
|
|
|
2003-05-18 09:48:12 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import Utils
|
|
|
|
import AutoComp
|
|
|
|
import const
|
|
|
|
import RelLib
|
2003-03-05 11:31:31 +05:30
|
|
|
from intl import gettext as _
|
|
|
|
|
2003-05-18 09:48:12 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# QuickAdd
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
class QuickAdd:
|
2003-05-18 09:48:12 +05:30
|
|
|
def __init__(self,db,sex,callback,default_name = ""):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = db
|
|
|
|
self.callback = callback
|
|
|
|
|
|
|
|
self.xml = gtk.glade.XML(const.gladeFile,"addperson")
|
|
|
|
self.xml.get_widget(sex).set_active(1)
|
|
|
|
self.xml.signal_autoconnect({
|
|
|
|
"on_addfather_close": self.close,
|
|
|
|
"destroy_passed_object" : Utils.destroy_passed_object
|
|
|
|
})
|
|
|
|
|
|
|
|
self.window = self.xml.get_widget("addperson")
|
2003-03-06 11:42:51 +05:30
|
|
|
title = self.xml.get_widget('title')
|
2003-05-18 09:48:12 +05:30
|
|
|
combo = self.xml.get_widget("surnameCombo")
|
|
|
|
self.surname = self.xml.get_widget("surname")
|
|
|
|
self.given = self.xml.get_widget("given")
|
2003-03-06 11:42:51 +05:30
|
|
|
|
|
|
|
Utils.set_titles(self.window,title, _('Add Person'))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2003-05-18 09:48:12 +05:30
|
|
|
self.c = AutoComp.AutoCombo(combo,self.db.getSurnames())
|
|
|
|
if default_name:
|
|
|
|
self.surname.set_text(default_name)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def close(self,obj):
|
2003-05-18 09:48:12 +05:30
|
|
|
surname = self.surname.get_text()
|
|
|
|
given = self.given.get_text()
|
2002-10-20 19:55:16 +05:30
|
|
|
person = RelLib.Person()
|
|
|
|
name = person.getPrimaryName()
|
|
|
|
name.setSurname(surname)
|
|
|
|
name.setFirstName(given)
|
2002-11-15 09:19:39 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.xml.get_widget("male").get_active():
|
|
|
|
person.setGender(RelLib.Person.male)
|
|
|
|
else:
|
|
|
|
person.setGender(RelLib.Person.female)
|
2002-11-15 09:19:39 +05:30
|
|
|
self.db.addPerson(person)
|
2002-10-20 19:55:16 +05:30
|
|
|
Utils.modified()
|
|
|
|
Utils.destroy_passed_object(self.window)
|
|
|
|
self.callback(person)
|