svn: r2913
This commit is contained in:
Alex Roitman 2004-02-25 04:34:20 +00:00
parent 125654323a
commit 9ca33d8bbc
3 changed files with 60 additions and 19 deletions

View File

@ -692,7 +692,7 @@ class FamilyView:
if not self.person: if not self.person:
return return
try: try:
SelectChild.SelectChild(self.parent.db, self.family, SelectChild.SelectChild(self.parent, self.parent.db, self.family,
self.person, self.load_family, self.person, self.load_family,
self.update_person_list) self.update_person_list)
except: except:

View File

@ -55,7 +55,8 @@ from RelLib import Person
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class SelectChild: class SelectChild:
def __init__(self,db,family,person,redraw,add_person): def __init__(self,parent,db,family,person,redraw,add_person):
self.parent = parent
self.db = db self.db = db
self.person = person self.person = person
self.family = family self.family = family
@ -72,7 +73,8 @@ class SelectChild:
"on_save_child_clicked" : self.on_save_child_clicked, "on_save_child_clicked" : self.on_save_child_clicked,
"on_child_help_clicked" : self.on_child_help_clicked, "on_child_help_clicked" : self.on_child_help_clicked,
"on_show_toggled" : self.on_show_toggled, "on_show_toggled" : self.on_show_toggled,
"destroy_passed_object" : self.close "destroy_passed_object" : self.close,
"on_select_child_delete_event" : self.on_delete_event,
}) })
self.select_child_list = {} self.select_child_list = {}
@ -122,19 +124,47 @@ class SelectChild:
self.refmodel = ListModel.ListModel(self.add_child,titles) self.refmodel = ListModel.ListModel(self.add_child,titles)
self.redraw_child_list(2) self.redraw_child_list(2)
self.add_itself_to_menu()
self.top.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
def close(self,obj):
self.remove_itself_from_menu()
self.top.destroy()
def add_itself_to_menu(self):
self.parent.child_windows[self] = self
self.parent_menu_item = gtk.MenuItem(_('Add Child to Family'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.child_windows[self]
self.parent_menu_item.destroy()
def present(self,obj):
self.top.present()
def on_child_help_clicked(self,obj): def on_child_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""
gnome.help_display('gramps-manual','gramps-edit-quick') gnome.help_display('gramps-manual','gramps-edit-quick')
def close(self,obj):
self.top.destroy()
def redraw_child_list(self,filter): def redraw_child_list(self,filter):
self.refmodel.clear() self.refmodel.clear()
self.refmodel.new_model() self.refmodel.new_model()
bday = self.person.get_birth().get_date_object() birth = self.db.find_event_from_id(self.person.get_birth_id())
dday = self.person.get_death().get_date_object() death = self.db.find_event_from_id(self.person.get_death_id())
if birth:
bday = birth.get_date_object()
else:
bday = None
if death:
dday = death.get_date_object()
else:
dday = None
slist = {} slist = {}
for f in self.person.get_parent_family_id_list(): for f in self.person.get_parent_family_id_list():
@ -154,11 +184,20 @@ class SelectChild:
if slist.has_key(key) or person.get_main_parents_family_id(): if slist.has_key(key) or person.get_main_parents_family_id():
continue continue
pdday = person.get_death().get_date_object() birth_event = self.db.find_event_from_id(person.get_birth_id())
pbday = person.get_birth().get_date_object() if birth_event:
pbday = birth_event.get_date_object()
else:
pbday = None
if bday.getYearValid(): death_event = self.db.find_event_from_id(person.get_death_id())
if pbday.getYearValid(): if death_event:
pdday = death_event.get_date_object()
else:
pdday = None
if bday and bday.getYearValid():
if pbday and pbday.getYearValid():
# reject if child birthdate < parents birthdate + 10 # reject if child birthdate < parents birthdate + 10
if pbday.getLowYear() < bday.getHighYear()+10: if pbday.getLowYear() < bday.getHighYear()+10:
continue continue
@ -167,18 +206,18 @@ class SelectChild:
if pbday.getLowYear() > bday.getHighYear()+90: if pbday.getLowYear() > bday.getHighYear()+90:
continue continue
if pdday.getYearValid(): if pdday and pdday.getYearValid():
# reject if child deathdate < parents birthdate+ 10 # reject if child deathdate < parents birthdate+ 10
if pdday.getLowYear() < bday.getHighYear()+10: if pdday.getLowYear() < bday.getHighYear()+10:
continue continue
if dday.getYearValid(): if dday and dday.getYearValid():
if pbday.getYearValid(): if pbday and pbday.getYearValid():
# reject if childs birth date > parents deathday + 3 # reject if childs birth date > parents deathday + 3
if pbday.getLowYear() > dday.getHighYear()+3: if pbday.getLowYear() > dday.getHighYear()+3:
continue continue
if pdday.getYearValid(): if pdday and pdday.getYearValid():
# reject if childs death date > parents deathday + 150 # reject if childs death date > parents deathday + 150
if pdday.getLowYear() > dday.getHighYear() + 150: if pdday.getLowYear() > dday.getHighYear() + 150:
continue continue
@ -237,9 +276,9 @@ class SelectChild:
select_child.add_parent_family_id(self.family.get_id(),mrel,frel) select_child.add_parent_family_id(self.family.get_id(),mrel,frel)
Utils.modified() self.db.commit_person(select_child)
self.top.destroy()
self.redraw(self.family) self.redraw(self.family)
self.close(obj)
def on_show_toggled(self,obj): def on_show_toggled(self,obj):
self.redraw_child_list(not obj.get_active()) self.redraw_child_list(not obj.get_active())
@ -367,5 +406,6 @@ class EditRel:
frel = "Unknown" frel = "Unknown"
self.child.change_parent_family_id(self.family.get_id(),mrel,frel) self.child.change_parent_family_id(self.family.get_id(),mrel,frel)
self.db.commit_person(self.child)
self.update() self.update()
self.top.destroy() self.top.destroy()

View File

@ -4907,13 +4907,14 @@
<property name="title" translatable="yes"></property> <property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">True</property> <property name="modal">False</property>
<property name="default_width">500</property> <property name="default_width">500</property>
<property name="default_height">400</property> <property name="default_height">400</property>
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
<property name="icon">gramps.png</property> <property name="icon">gramps.png</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<signal name="delete_event" handler="on_select_child_delete_event" last_modification_time="Wed, 25 Feb 2004 03:36:55 GMT"/>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="vbox15"> <widget class="GtkVBox" id="vbox15">