Convert to new GenericTreeView models
svn: r3040
This commit is contained in:
parent
2c03888381
commit
aceaffcc97
@ -121,8 +121,6 @@ class AddMediaObject:
|
||||
mobj = RelLib.MediaObject()
|
||||
mobj.set_description(description)
|
||||
mobj.set_mime_type(type)
|
||||
if type[0:5] == "image":
|
||||
mobj.set_thumbnail(RelImage.build_thumbnail(filename,const.thumbScale))
|
||||
self.db.add_object(mobj)
|
||||
|
||||
name = filename
|
||||
|
@ -52,7 +52,7 @@ import RelLib
|
||||
import const
|
||||
import Utils
|
||||
import GrampsCfg
|
||||
import ListModel
|
||||
import PeopleModel
|
||||
import Date
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -79,23 +79,49 @@ class AddSpouse:
|
||||
self.db = db
|
||||
self.update = update
|
||||
self.person = person
|
||||
self.gender = self.person.get_gender()
|
||||
self.addperson = addperson
|
||||
self.active_family = family
|
||||
|
||||
self.filter_func = self.likely_filter
|
||||
|
||||
# determine the gender of the people to be loaded into
|
||||
# the potential spouse list. If Partners is selected, use
|
||||
# the same gender as the current person.
|
||||
|
||||
birth_id = self.person.get_birth_id()
|
||||
death_id = self.person.get_death_id()
|
||||
|
||||
self.bday = self.db.find_event_from_id(birth_id)
|
||||
self.dday = self.db.find_event_from_id(death_id)
|
||||
if birth_id:
|
||||
self.bday = self.db.find_event_from_id(birth_id).get_date_object()
|
||||
else:
|
||||
self.bday = Date.Date()
|
||||
|
||||
if death_id:
|
||||
self.dday = self.db.find_event_from_id(death_id).get_date_object()
|
||||
else:
|
||||
self.dday = Date.Date()
|
||||
|
||||
self.glade = gtk.glade.XML(const.gladeFile, "spouseDialog","gramps")
|
||||
|
||||
self.relation_def = self.glade.get_widget("reldef")
|
||||
self.rel_combo = self.glade.get_widget("rel_combo")
|
||||
self.relation_type = self.glade.get_widget("rel_type")
|
||||
self.spouse_list = self.glade.get_widget("spouse_list")
|
||||
self.showall = self.glade.get_widget('showall')
|
||||
|
||||
titles = [ (_('Name'),3,200), (_('ID'),1,50), (_('Birth date'),4,50),
|
||||
('',0,50), ('',0,0)]
|
||||
self.set_gender()
|
||||
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
self.slist = PeopleModel.PeopleModel(self.db,self.filter_func)
|
||||
self.spouse_list.set_model(self.slist)
|
||||
self.selection = self.spouse_list.get_selection()
|
||||
self.selection.connect('changed',self.select_row)
|
||||
self.add_columns(self.spouse_list)
|
||||
|
||||
self.slist = ListModel.ListModel(self.spouse_list, titles,
|
||||
self.select_row )
|
||||
|
||||
self.relation_def = self.glade.get_widget("reldef")
|
||||
self.ok = self.glade.get_widget('spouse_ok')
|
||||
self.ok.set_sensitive(0)
|
||||
|
||||
@ -106,6 +132,7 @@ class AddSpouse:
|
||||
self.glade.get_widget('title'),title,
|
||||
_('Choose Spouse/Partner'))
|
||||
|
||||
|
||||
self.glade.signal_autoconnect({
|
||||
"on_select_spouse_clicked" : self.select_spouse_clicked,
|
||||
"on_spouse_help_clicked" : self.on_spouse_help_clicked,
|
||||
@ -116,20 +143,43 @@ class AddSpouse:
|
||||
})
|
||||
|
||||
self.relation_type.set_text(_("Married"))
|
||||
self.relation_type_changed(None)
|
||||
self.update_data()
|
||||
|
||||
def add_columns(self,tree):
|
||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(225)
|
||||
tree.append_column(column)
|
||||
column = gtk.TreeViewColumn(_('ID'), self.renderer,text=1)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(75)
|
||||
tree.append_column(column)
|
||||
column = gtk.TreeViewColumn(_('Birth date'), self.renderer,text=3)
|
||||
#column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
tree.append_column(column)
|
||||
|
||||
def on_spouse_help_clicked(self,obj):
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
gnome.help_display('gramps-manual','gramps-edit-quick')
|
||||
|
||||
def get_selected_ids(self):
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.select_function,mlist)
|
||||
return mlist
|
||||
|
||||
def select_function(self,store,path,iter,id_list):
|
||||
id_list.append(store.get_value(iter,1))
|
||||
|
||||
def select_row(self,obj):
|
||||
"""
|
||||
Called with a row has be unselected. Used to enable the OK button
|
||||
when a row has been selected.
|
||||
"""
|
||||
|
||||
model,iter = self.slist.get_selected()
|
||||
if iter:
|
||||
idlist = self.get_selected_ids()
|
||||
if idlist and idlist[0]:
|
||||
self.ok.set_sensitive(1)
|
||||
else:
|
||||
self.ok.set_sensitive(0)
|
||||
@ -156,7 +206,7 @@ class AddSpouse:
|
||||
person.set_gender(gen)
|
||||
EditPerson.EditPerson(self.parent,person,self.db,self.update_list)
|
||||
|
||||
def update_list(self,epo):
|
||||
def update_list(self,epo,change):
|
||||
"""
|
||||
Updates the potential spouse list after a person has been added
|
||||
to database. Called by the QuickAdd class when the dialog has
|
||||
@ -170,7 +220,7 @@ class AddSpouse:
|
||||
self.db.build_person_display(person.get_id())
|
||||
self.addperson(person)
|
||||
self.update_data(person.get_id())
|
||||
self.slist.center_selected()
|
||||
#self.slist.center_selected()
|
||||
|
||||
def select_spouse_clicked(self,obj):
|
||||
"""
|
||||
@ -178,12 +228,11 @@ class AddSpouse:
|
||||
selected from the list.
|
||||
"""
|
||||
|
||||
model,iter = self.slist.get_selected()
|
||||
if not iter:
|
||||
idlist = self.get_selected_ids()
|
||||
if not idlist or not idlist[0]:
|
||||
return
|
||||
|
||||
id = self.slist.get_object(iter)
|
||||
spouse = self.db.get_person(id)
|
||||
spouse = self.db.get_person(idlist[0])
|
||||
|
||||
# don't do anything if the marriage already exists
|
||||
for f in self.person.get_family_id_list():
|
||||
@ -214,98 +263,84 @@ class AddSpouse:
|
||||
def relation_type_changed(self,obj):
|
||||
self.update_data()
|
||||
|
||||
def all_filter(self, person):
|
||||
return person.get_gender() != self.sgender
|
||||
|
||||
def likely_filter(self, person):
|
||||
if person.get_gender() == self.sgender:
|
||||
return 0
|
||||
|
||||
pd_id = person.get_death_id()
|
||||
pb_id = person.get_birth_id()
|
||||
|
||||
if pd_id:
|
||||
pdday = self.db.find_event_from_id(pd_id).get_date_object()
|
||||
else:
|
||||
pdday = Date.Date()
|
||||
|
||||
if pb_id:
|
||||
pbday = self.db.find_event_from_id(pb_id).get_date_object()
|
||||
else:
|
||||
pbday = Date.Date()
|
||||
|
||||
if self.bday.get_year_valid():
|
||||
if pbday.get_year_valid():
|
||||
# reject if person birthdate differs more than
|
||||
# 100 years from spouse birthdate
|
||||
if abs(pbday.get_year() - self.bday.get_year()) > 100:
|
||||
return 0
|
||||
|
||||
if pdday.get_year_valid():
|
||||
# reject if person birthdate is after the spouse deathdate
|
||||
if self.bday.get_low_year() + 10 > pdday.get_high_year():
|
||||
return 0
|
||||
|
||||
# reject if person birthdate is more than 100 years
|
||||
# before the spouse deathdate
|
||||
if self.bday.get_high_year() + 100 < pdday.get_low_year():
|
||||
return 0
|
||||
|
||||
if self.dday.get_year_valid():
|
||||
if pbday.get_year_valid():
|
||||
# reject if person deathdate was prior to
|
||||
# the spouse birthdate
|
||||
if self.dday.get_high_year() < pbday.get_low_year() + 10:
|
||||
return 0
|
||||
|
||||
if pdday.get_year_valid():
|
||||
# reject if person deathdate differs more than
|
||||
# 100 years from spouse deathdate
|
||||
if abs(pdday.get_year() - self.dday.get_year()) > 100:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
def set_gender(self):
|
||||
text = unicode(self.relation_type.get_text())
|
||||
self.relation_def.set_text(const.relationship_def(text))
|
||||
if text == _("Partners"):
|
||||
if self.gender == RelLib.Person.male:
|
||||
self.sgender = RelLib.Person.female
|
||||
else:
|
||||
self.sgender = RelLib.Person.male
|
||||
else:
|
||||
if self.gender == RelLib.Person.male:
|
||||
self.sgender = RelLib.Person.male
|
||||
else:
|
||||
self.sgender = RelLib.Person.female
|
||||
|
||||
def update_data(self,person = None):
|
||||
"""
|
||||
Called whenever the relationship type changes. Rebuilds the
|
||||
the potential spouse list.
|
||||
"""
|
||||
|
||||
text = unicode(self.relation_type.get_text())
|
||||
self.relation_def.set_text(const.relationship_def(text))
|
||||
|
||||
# determine the gender of the people to be loaded into
|
||||
# the potential spouse list. If Partners is selected, use
|
||||
# the same gender as the current person.
|
||||
gender = self.person.get_gender()
|
||||
|
||||
birth_id = self.person.get_birth_id()
|
||||
death_id = self.person.get_death_id()
|
||||
|
||||
bday = self.db.find_event_from_id(birth_id)
|
||||
dday = self.db.find_event_from_id(death_id)
|
||||
if birth_id:
|
||||
bday = self.db.find_event_from_id(birth_id).get_date_object()
|
||||
else:
|
||||
bday = Date.Date()
|
||||
|
||||
if death_id:
|
||||
dday = self.db.find_event_from_id(death_id).get_date_object()
|
||||
else:
|
||||
dday = Date.Date()
|
||||
|
||||
if text == _("Partners"):
|
||||
if gender == RelLib.Person.male:
|
||||
sgender = const.female
|
||||
else:
|
||||
sgender = const.male
|
||||
else:
|
||||
if gender == RelLib.Person.male:
|
||||
sgender = const.male
|
||||
else:
|
||||
sgender = const.female
|
||||
|
||||
self.entries = []
|
||||
self.slist.clear()
|
||||
self.slist.new_model()
|
||||
for key in self.db.sort_person_keys():
|
||||
data = self.db.get_person_display(key)
|
||||
if data[2] == sgender:
|
||||
continue
|
||||
|
||||
if not self.showall.get_active():
|
||||
pd_id = self.db.get_person(key).get_death_id()
|
||||
pb_id = self.db.get_person(key).get_birth_id()
|
||||
|
||||
if pd_id:
|
||||
pdday = self.db.find_event_from_id(pd_id).get_date_object()
|
||||
else:
|
||||
pdday = Date.Date()
|
||||
if pb_id:
|
||||
pbday = self.db.find_event_from_id(pb_id).get_date_object()
|
||||
else:
|
||||
pbday = Date.Date()
|
||||
|
||||
if bday.getYearValid():
|
||||
if pbday.getYearValid():
|
||||
# reject if person birthdate differs more than
|
||||
# 100 years from spouse birthdate
|
||||
if abs(pbday.getYear() - bday.getYear()) > 100:
|
||||
continue
|
||||
|
||||
if pdday.getYearValid():
|
||||
# reject if person birthdate is after the spouse deathdate
|
||||
if bday.getLowYear() + 10 > pdday.getHighYear():
|
||||
continue
|
||||
|
||||
# reject if person birthdate is more than 100 years
|
||||
# before the spouse deathdate
|
||||
if bday.getHighYear() + 100 < pdday.getLowYear():
|
||||
continue
|
||||
|
||||
if dday.getYearValid():
|
||||
if pbday.getYearValid():
|
||||
# reject if person deathdate was prior to
|
||||
# the spouse birthdate
|
||||
if dday.getHighYear() < pbday.getLowYear() + 10:
|
||||
continue
|
||||
|
||||
if pdday.getYearValid():
|
||||
# reject if person deathdate differs more than
|
||||
# 100 years from spouse deathdate
|
||||
if abs(pdday.getYear() - dday.getYear()) > 100:
|
||||
continue
|
||||
self.slist.add([data[0],data[1],data[3],data[5],data[6]],key,person==key)
|
||||
self.slist.connect_model()
|
||||
self.slist = PeopleModel.PeopleModel(self.db,self.filter_func)
|
||||
self.spouse_list.set_model(self.slist)
|
||||
|
||||
def on_show_toggled(self,obj):
|
||||
if self.filter_func == self.likely_filter:
|
||||
self.filter_func = self.all_filter
|
||||
else:
|
||||
self.filter_func = self.likely_filter
|
||||
print self.filter_func
|
||||
self.update_data()
|
||||
|
@ -53,9 +53,7 @@ import RelLib
|
||||
import const
|
||||
import Utils
|
||||
import GrampsCfg
|
||||
import ListModel
|
||||
|
||||
_titles = [(_('Name'),3,200),(_('ID'),1,50),(_('Birth date'),4,50),('',0,50),('',0,0)]
|
||||
import PeopleModel
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -87,12 +85,23 @@ class ChooseParents:
|
||||
self.old_type = ""
|
||||
self.type = ""
|
||||
self.parent_selected = 0
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
birth_event = self.db.find_event_from_id(person.get_birth_id())
|
||||
# set default filters
|
||||
self.father_filter = self.likely_father_filter
|
||||
self.mother_filter = self.likely_mother_filter
|
||||
|
||||
birth_event = self.db.find_event_from_id(self.person.get_birth_id())
|
||||
if birth_event:
|
||||
self.date = birth_event.get_date_object()
|
||||
self.bday = birth_event.get_date_object()
|
||||
else:
|
||||
self.date = None
|
||||
self.bday = None
|
||||
|
||||
death_event = self.db.find_event_from_id(self.person.get_death_id())
|
||||
if death_event:
|
||||
self.dday = death_event.get_date_object()
|
||||
else:
|
||||
self.dday = None
|
||||
|
||||
if self.family:
|
||||
self.father = self.family.get_father_id()
|
||||
@ -113,7 +122,6 @@ class ChooseParents:
|
||||
self.fcombo = self.glade.get_widget("prel_combo")
|
||||
self.prel = self.glade.get_widget("prel")
|
||||
self.title = self.glade.get_widget("chooseTitle")
|
||||
self.father_list = self.glade.get_widget("father_list")
|
||||
self.mother_list = self.glade.get_widget("mother_list")
|
||||
self.flabel = self.glade.get_widget("flabel")
|
||||
self.mlabel = self.glade.get_widget("mlabel")
|
||||
@ -122,10 +130,8 @@ class ChooseParents:
|
||||
|
||||
self.fcombo.set_popdown_strings(const.familyRelations)
|
||||
|
||||
self.fmodel = ListModel.ListModel(self.father_list, _titles,
|
||||
self.father_list_select_row)
|
||||
self.mmodel = ListModel.ListModel(self.mother_list, _titles,
|
||||
self.mother_list_select_row)
|
||||
self.build_father_list()
|
||||
self.build_mother_list()
|
||||
|
||||
for (f,mr,fr) in self.person.get_parent_family_id_list():
|
||||
if f == self.family:
|
||||
@ -142,7 +148,6 @@ class ChooseParents:
|
||||
self.type = "Married"
|
||||
|
||||
self.prel.set_text(_(self.type))
|
||||
self.redrawf()
|
||||
self.redrawm()
|
||||
|
||||
self.glade.signal_autoconnect({
|
||||
@ -159,6 +164,36 @@ class ChooseParents:
|
||||
self.add_itself_to_menu()
|
||||
self.top.show()
|
||||
|
||||
def build_father_list(self):
|
||||
self.father_list = self.glade.get_widget("father_list")
|
||||
self.father_selection = self.father_list.get_selection()
|
||||
self.father_selection.connect('changed',self.father_list_select_row)
|
||||
self.add_columns(self.father_list)
|
||||
self.redrawf()
|
||||
|
||||
def build_mother_list(self):
|
||||
self.mother_list = self.glade.get_widget("mother_list")
|
||||
self.mother_selection = self.mother_list.get_selection()
|
||||
self.mother_selection.connect('changed',self.mother_list_select_row)
|
||||
self.add_columns(self.mother_list)
|
||||
self.redrawm()
|
||||
|
||||
def add_columns(self,tree):
|
||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(225)
|
||||
tree.append_column(column)
|
||||
column = gtk.TreeViewColumn(_('ID'), self.renderer,text=1)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(75)
|
||||
tree.append_column(column)
|
||||
column = gtk.TreeViewColumn(_('Birth date'), self.renderer,text=3)
|
||||
#column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
tree.append_column(column)
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.close_child_windows()
|
||||
self.remove_itself_from_menu()
|
||||
@ -198,187 +233,79 @@ class ChooseParents:
|
||||
"""Display the relevant portion of GRAMPS manual"""
|
||||
gnome.help_display('gramps-manual','gramps-edit-quick')
|
||||
|
||||
def all_males_filter(self,person):
|
||||
return (person.get_gender() == RelLib.Person.male)
|
||||
|
||||
def all_females_filter(self,person):
|
||||
return (person.get_gender() == RelLib.Person.female)
|
||||
|
||||
def likely_father_filter(self,person):
|
||||
if person.get_gender() != RelLib.Person.male:
|
||||
return 0
|
||||
return self.likely_filter(person)
|
||||
|
||||
def likely_mother_filter(self,person):
|
||||
if person.get_gender() != RelLib.Person.female:
|
||||
return 0
|
||||
return self.likely_filter(person)
|
||||
|
||||
def likely_filter(self,person):
|
||||
birth_event = self.db.find_event_from_id(person.get_birth_id())
|
||||
if birth_event:
|
||||
pbday = birth_event.get_date_object()
|
||||
else:
|
||||
pbday = None
|
||||
|
||||
death_event = self.db.find_event_from_id(person.get_death_id())
|
||||
if death_event:
|
||||
pdday = death_event.get_date_object()
|
||||
else:
|
||||
pdday = None
|
||||
|
||||
if self.bday and self.bday.get_year_valid():
|
||||
if pbday and pbday.get_year_valid():
|
||||
# reject if parents birthdate + 10 > child birthdate
|
||||
if pbday.get_low_year()+10 > self.bday.get_high_year():
|
||||
return 0
|
||||
|
||||
# reject if parents birthdate + 90 < child birthdate
|
||||
if pbday.get_high_year()+90 < self.bday.get_low_year():
|
||||
return 0
|
||||
|
||||
if pdday and pdday.get_year_valid():
|
||||
# reject if parents birthdate + 10 > child deathdate
|
||||
if self.dday and pbday.get_low_year()+10 > self.dday.get_high_year():
|
||||
return 0
|
||||
|
||||
if self.dday and dday.get_year_valid():
|
||||
if pbday and pbday.get_year_valid():
|
||||
# reject if parents deathday + 3 < childs birth date
|
||||
if pdday and self.bday and pdday.get_high_year()+3 < self.bday.get_low_year():
|
||||
return 0
|
||||
|
||||
if pdday and pdday.get_year_valid():
|
||||
# reject if parents deathday + 150 < childs death date
|
||||
if pdday.get_high_year() + 150 < self.dday.get_low_year():
|
||||
return 0
|
||||
return 1
|
||||
|
||||
def redrawf(self):
|
||||
"""Redraws the potential father list"""
|
||||
|
||||
self.fmodel.clear()
|
||||
self.fmodel.new_model()
|
||||
|
||||
person_id = self.person.get_id()
|
||||
|
||||
if self.father:
|
||||
father_id = self.father.get_id()
|
||||
else:
|
||||
father_id = None
|
||||
|
||||
birth_event = self.db.find_event_from_id(self.person.get_birth_id())
|
||||
if birth_event:
|
||||
bday = birth_event.get_date_object()
|
||||
else:
|
||||
bday = None
|
||||
death_event = self.db.find_event_from_id(self.person.get_death_id())
|
||||
if death_event:
|
||||
dday = death_event.get_date_object()
|
||||
else:
|
||||
dday = None
|
||||
|
||||
person_list = []
|
||||
for key in self.db.sort_person_keys():
|
||||
if person_id == key:
|
||||
continue
|
||||
|
||||
person = self.db.get_person(key)
|
||||
if person.get_gender() != RelLib.Person.male:
|
||||
continue
|
||||
|
||||
if not self.showallf.get_active():
|
||||
|
||||
birth_event = self.db.find_event_from_id(person.get_birth_id())
|
||||
if birth_event:
|
||||
pbday = birth_event.get_date_object()
|
||||
else:
|
||||
pbday = None
|
||||
|
||||
death_event = self.db.find_event_from_id(person.get_death_id())
|
||||
if death_event:
|
||||
pdday = death_event.get_date_object()
|
||||
else:
|
||||
pdday = None
|
||||
|
||||
if bday and bday.getYearValid():
|
||||
if pbday and pbday.getYearValid():
|
||||
# reject if parents birthdate + 10 > child birthdate
|
||||
if pbday.getLowYear()+10 > bday.getHighYear():
|
||||
continue
|
||||
|
||||
# reject if parents birthdate + 90 < child birthdate
|
||||
if pbday.getHighYear()+90 < bday.getLowYear():
|
||||
continue
|
||||
|
||||
if pdday and pdday.getYearValid():
|
||||
# reject if parents birthdate + 10 > child deathdate
|
||||
if dday and pbday.getLowYear()+10 > dday.getHighYear():
|
||||
continue
|
||||
|
||||
if dday and dday.getYearValid():
|
||||
if pbday and pbday.getYearValid():
|
||||
# reject if parents deathday + 3 < childs birth date
|
||||
if pdday and bday and pdday.getHighYear()+3 < bday.getLowYear():
|
||||
continue
|
||||
|
||||
if pdday and pdday.getYearValid():
|
||||
# reject if parents deathday + 150 < childs death date
|
||||
if pdday.getHighYear() + 150 < dday.getLowYear():
|
||||
continue
|
||||
|
||||
person_list.append(person.get_id())
|
||||
|
||||
for idval in person_list:
|
||||
d = self.db.get_person_display(idval)
|
||||
info = [d[0],d[1],d[3],d[5],d[6]]
|
||||
if self.type == "Partners":
|
||||
self.fmodel.add(info,d[1],father_id==d[1])
|
||||
elif d[2] == const.male:
|
||||
self.fmodel.add(info,d[1],father_id==d[1])
|
||||
|
||||
self.father_model = PeopleModel.PeopleModel(self.db, self.father_filter)
|
||||
self.father_list.set_model(self.father_model)
|
||||
if self.type == "Partners":
|
||||
self.flabel.set_label("<b>%s</b>" % _("Par_ent"))
|
||||
else:
|
||||
self.flabel.set_label("<b>%s</b>" % _("Fath_er"))
|
||||
|
||||
self.fmodel.connect_model()
|
||||
|
||||
|
||||
def redrawm(self):
|
||||
"""Redraws the potential mother list"""
|
||||
|
||||
self.mmodel.clear()
|
||||
self.mmodel.new_model()
|
||||
|
||||
person_id = self.person.get_id()
|
||||
|
||||
if self.mother:
|
||||
mid = self.mother.get_id()
|
||||
else:
|
||||
mid = None
|
||||
|
||||
birth_event = self.db.find_event_from_id(self.person.get_birth_id())
|
||||
if birth_event:
|
||||
bday = birth_event.get_date_object()
|
||||
else:
|
||||
bday = Date.Date()
|
||||
death_event = self.db.find_event_from_id(self.person.get_death_id())
|
||||
if death_event:
|
||||
dday = death_event.get_date_object()
|
||||
else:
|
||||
dday = Date.Date()
|
||||
|
||||
person_list = []
|
||||
for key in self.db.sort_person_keys():
|
||||
if person_id == key:
|
||||
continue
|
||||
|
||||
person = self.db.get_person(key)
|
||||
if person.get_gender() != RelLib.Person.female:
|
||||
continue
|
||||
|
||||
person = self.db.get_person(key)
|
||||
|
||||
if not self.showallm.get_active():
|
||||
|
||||
birth_event = self.db.find_event_from_id(person.get_birth_id())
|
||||
if birth_event:
|
||||
pbday = birth_event.get_date_object()
|
||||
else:
|
||||
pbday = Date.Date()
|
||||
|
||||
death_event = self.db.find_event_from_id(person.get_death_id())
|
||||
if death_event:
|
||||
pdday = death_event.get_date_object()
|
||||
else:
|
||||
pdday = Date.Date()
|
||||
|
||||
if bday and bday.getYearValid():
|
||||
if pbday and pbday.getYearValid():
|
||||
# reject if parents birthdate + 10 > child birthdate
|
||||
if pbday.getLowYear()+10 > bday.getHighYear():
|
||||
continue
|
||||
|
||||
# reject if parents birthdate + 90 < child birthdate
|
||||
if pbday.getHighYear()+90 < bday.getLowYear():
|
||||
continue
|
||||
|
||||
if pdday and pdday.getYearValid():
|
||||
# reject if parents birthdate + 10 > child deathdate
|
||||
if pbday.getLowYear()+10 > dday.getHighYear():
|
||||
continue
|
||||
|
||||
if dday and dday.getYearValid():
|
||||
if pbday and pbday.getYearValid():
|
||||
# reject if parents deathday + 3 < childs birth date
|
||||
if pdday and bday and pdday.getHighYear()+3 < bday.getLowYear():
|
||||
continue
|
||||
|
||||
if pdday and pdday.getYearValid():
|
||||
# reject if parents deathday + 150 < childs death date
|
||||
if pdday.getHighYear() + 150 < dday.getLowYear():
|
||||
continue
|
||||
|
||||
person_list.append(person.get_id())
|
||||
|
||||
for idval in person_list:
|
||||
d = self.db.get_person_display(idval)
|
||||
info = [d[0],d[1],d[3],d[5],d[6]]
|
||||
if self.type == "Partners":
|
||||
self.mmodel.add(info,d[1],mid==d[1])
|
||||
elif d[2] == const.female:
|
||||
self.mmodel.add(info,d[1],mid==d[1])
|
||||
|
||||
self.mother_model = PeopleModel.PeopleModel(self.db, self.mother_filter)
|
||||
self.mother_list.set_model(self.mother_model)
|
||||
if self.type == "Partners":
|
||||
self.mlabel.set_label("<b>%s</b>" % _("Pa_rent"))
|
||||
else:
|
||||
self.mlabel.set_label("<b>%s</b>" % _("Mothe_r"))
|
||||
self.mmodel.connect_model()
|
||||
|
||||
def parent_relation_changed(self,obj):
|
||||
"""Called everytime the parent relationship information is changegd"""
|
||||
@ -389,9 +316,17 @@ class ChooseParents:
|
||||
self.redrawm()
|
||||
|
||||
def showallf_toggled(self,obj):
|
||||
if self.father_filter == self.likely_father_filter:
|
||||
self.father_filter = self.all_males_filter
|
||||
else:
|
||||
self.father_filter = self.likely_father_filter
|
||||
self.redrawf()
|
||||
|
||||
def showallm_toggled(self,obj):
|
||||
if self.mother_filter == self.likely_mother_filter:
|
||||
self.mother_filter = self.all_females_filter
|
||||
else:
|
||||
self.mother_filter = self.likely_mother_filter
|
||||
self.redrawm()
|
||||
|
||||
def find_family(self,father_id,mother_id):
|
||||
@ -430,10 +365,9 @@ class ChooseParents:
|
||||
"""Called when a row is selected in the mother list. Sets the
|
||||
active mother based off the id associated with the row."""
|
||||
|
||||
model, iter = self.mmodel.get_selected()
|
||||
if iter:
|
||||
id = model.get_value(iter,1)
|
||||
self.mother = self.db.get_person(id)
|
||||
idlist = self.get_selected_mother_ids()
|
||||
if idlist and idlist[0]:
|
||||
self.mother = self.db.get_person(idlist[0])
|
||||
else:
|
||||
self.mother = None
|
||||
|
||||
@ -443,16 +377,32 @@ class ChooseParents:
|
||||
if len(family_id_list) >= 1:
|
||||
family = self.db.find_family_from_id(family_id_list[0])
|
||||
father_id = family.get_father_id()
|
||||
self.fmodel.find(father_id)
|
||||
self.fmodel.center_selected()
|
||||
self.father_selection.select(father_id)
|
||||
#self.father_model.center_selected()
|
||||
|
||||
def father_select_function(self,store,path,iter,id_list):
|
||||
id_list.append(self.father_model.get_value(iter,1))
|
||||
|
||||
def mother_select_function(self,store,path,iter,id_list):
|
||||
id_list.append(self.mother_model.get_value(iter,1))
|
||||
|
||||
def get_selected_father_ids(self):
|
||||
mlist = []
|
||||
self.father_selection.selected_foreach(self.father_select_function,mlist)
|
||||
return mlist
|
||||
|
||||
def get_selected_mother_ids(self):
|
||||
mlist = []
|
||||
self.mother_selection.selected_foreach(self.mother_select_function,mlist)
|
||||
return mlist
|
||||
|
||||
def father_list_select_row(self,obj):
|
||||
"""Called when a row is selected in the father list. Sets the
|
||||
active father based off the id associated with the row."""
|
||||
model, iter = self.fmodel.get_selected()
|
||||
if iter:
|
||||
id = model.get_value(iter,1)
|
||||
self.father = self.db.get_person(id)
|
||||
|
||||
idlist = self.get_selected_father_ids()
|
||||
if idlist and idlist[0]:
|
||||
self.father = self.db.get_person(idlist[0])
|
||||
else:
|
||||
self.father = None
|
||||
|
||||
@ -462,8 +412,27 @@ class ChooseParents:
|
||||
if len(family_id_list) >= 1:
|
||||
family = self.db.find_family_from_id(family_id_list[0])
|
||||
mother_id = family.get_mother_id()
|
||||
self.mmodel.find(mother_id)
|
||||
self.mmodel.center_selected()
|
||||
self.mother_selection.select(mother_id)
|
||||
#self.mother_model.center_selected()
|
||||
|
||||
def mother_list_select_row(self,obj):
|
||||
"""Called when a row is selected in the father list. Sets the
|
||||
active father based off the id associated with the row."""
|
||||
|
||||
idlist = self.get_selected_mother_ids()
|
||||
if idlist and idlist[0]:
|
||||
self.mother = self.db.get_person(idlist[0])
|
||||
else:
|
||||
self.mother = None
|
||||
|
||||
if not self.parent_selected and self.mother:
|
||||
self.parent_selected = 1
|
||||
family_id_list = self.mother.get_family_id_list()
|
||||
if len(family_id_list) >= 1:
|
||||
family = self.db.find_family_from_id(family_id_list[0])
|
||||
father_id = family.get_father_id()
|
||||
self.father_selection.select(father_id)
|
||||
#self.father_model.center_selected()
|
||||
|
||||
def save_parents_clicked(self,obj):
|
||||
"""
|
||||
@ -529,11 +498,11 @@ class ChooseParents:
|
||||
if self.type == "Partners":
|
||||
self.parent_relation_changed(self.prel)
|
||||
elif person.get_gender() == RelLib.Person.male:
|
||||
self.fmodel.add(rdata,None,1)
|
||||
self.fmodel.center_selected()
|
||||
self.father_model.add(rdata,None,1)
|
||||
self.father_model.center_selected()
|
||||
else:
|
||||
self.mmodel.add(rdata,None,1)
|
||||
self.mmodel.center_selected()
|
||||
self.mother_model.add(rdata,None,1)
|
||||
self.mother_model.center_selected()
|
||||
self.full_update()
|
||||
|
||||
def add_parent_clicked(self,obj):
|
||||
|
@ -28,25 +28,17 @@ import gtk.glade
|
||||
import const
|
||||
from gettext import gettext as _
|
||||
|
||||
column_names = [
|
||||
_('Name'),
|
||||
_('ID') ,
|
||||
_('Gender'),
|
||||
_('Birth Date'),
|
||||
_('Birth Place'),
|
||||
_('Death Date'),
|
||||
_('Death Place'),
|
||||
]
|
||||
|
||||
class ColumnOrder:
|
||||
|
||||
def __init__(self,arglist,callback):
|
||||
def __init__(self,arglist,column_names,callback):
|
||||
self.glade = gtk.glade.XML(const.gladeFile,"columns","gramps")
|
||||
self.top = self.glade.get_widget('columns')
|
||||
self.tree = self.glade.get_widget('list')
|
||||
self.arglist = arglist
|
||||
self.callback = callback
|
||||
|
||||
self.top.set_title("%s - GRAMPS" % _('Select Columns'))
|
||||
|
||||
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT)
|
||||
|
@ -77,9 +77,9 @@ class DateEdit:
|
||||
|
||||
text = unicode(self.text_obj.get_text())
|
||||
self.checkval.set(text)
|
||||
if not self.checkval.isValid():
|
||||
if not self.checkval.is_valid():
|
||||
self.pixmap_obj.set_from_pixbuf(DateEdit.bad)
|
||||
elif self.checkval.getIncomplete():
|
||||
elif self.checkval.get_incomplete():
|
||||
self.pixmap_obj.set_from_pixbuf(DateEdit.caution)
|
||||
else:
|
||||
self.pixmap_obj.set_from_pixbuf(DateEdit.good)
|
||||
|
@ -1375,7 +1375,8 @@ class EditPerson:
|
||||
import NameEdit
|
||||
store,iter = self.ntree.get_selected()
|
||||
if iter:
|
||||
NameEdit.NameEditor(self,self.ntree.get_object(iter),self.name_edit_callback,self.window)
|
||||
NameEdit.NameEditor(self,self.ntree.get_object(iter),
|
||||
self.name_edit_callback,self.window)
|
||||
|
||||
def load_photo(self,photo):
|
||||
"""loads, scales, and displays the person's main photo"""
|
||||
@ -1577,12 +1578,12 @@ class EditPerson:
|
||||
self.person.set_source_reference_list(self.srcreflist)
|
||||
|
||||
self.update_lists()
|
||||
self.db.commit_person(self.person)
|
||||
|
||||
if self.callback:
|
||||
change = (self.orig_surname != surname) or (self.orig_id != idval)
|
||||
self.callback(self,change)
|
||||
|
||||
self.db.commit_person(self.person)
|
||||
|
||||
self.close(1)
|
||||
|
||||
def get_place(self,field,makenew=0):
|
||||
|
@ -606,7 +606,7 @@ class FamilyView:
|
||||
self.parent.active_person = ap
|
||||
self.load_family(self.family)
|
||||
|
||||
def new_spouse_after_edit(self,epo):
|
||||
def new_spouse_after_edit(self,epo,change):
|
||||
|
||||
if epo.person.get_id() == "":
|
||||
self.parent.db.add_person(epo.person)
|
||||
|
@ -48,6 +48,8 @@ import GrampsCfg
|
||||
import const
|
||||
import ImageSelect
|
||||
import RelImage
|
||||
import ColumnOrder
|
||||
import DisplayModels
|
||||
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog, WarningDialog
|
||||
|
||||
@ -58,6 +60,13 @@ from QuestionDialog import QuestionDialog, ErrorDialog, WarningDialog
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
column_names = [
|
||||
_('Title'),
|
||||
_('ID'),
|
||||
_('Type'),
|
||||
_('Path'),
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MediaView
|
||||
@ -74,35 +83,12 @@ class MediaView:
|
||||
self.mpath = glade.get_widget("mpath")
|
||||
self.mdetails = glade.get_widget("mdetails")
|
||||
self.preview = glade.get_widget("preview")
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
self.column_headers = [(_('Title'),4,350), (_('ID'),1,50),
|
||||
(_('Type'),2,70), (_('Path'),3,150), ('',4,0) ]
|
||||
|
||||
self.id2col = {}
|
||||
self.model = DisplayModels.MediaModel(self.db)
|
||||
self.selection = self.list.get_selection()
|
||||
|
||||
colno = 0
|
||||
for title in self.column_headers:
|
||||
renderer = gtk.CellRendererText ()
|
||||
column = gtk.TreeViewColumn (title[0], renderer, text=colno)
|
||||
colno = colno + 1
|
||||
column.set_clickable (gtk.TRUE)
|
||||
if title[0] == '':
|
||||
column.set_visible(gtk.FALSE)
|
||||
else:
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_visible(gtk.TRUE)
|
||||
if title[1] >= 0:
|
||||
column.set_sort_column_id(title[1])
|
||||
column.set_min_width(title[2])
|
||||
self.list.append_column(column)
|
||||
|
||||
self.list.set_search_column(0)
|
||||
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.list.set_model(self.model)
|
||||
self.list.get_column(0).clicked()
|
||||
|
||||
t = [ ('STRING', 0, 0),
|
||||
('text/plain',0,0),
|
||||
@ -129,6 +115,40 @@ class MediaView:
|
||||
"If you would like to enable this feature, "
|
||||
"install Python Imaging Library (PIL), available at http://www.pythonware.com/products/pil/ "
|
||||
"or ImageMagick, available at http://www.imagemagick.org/"))
|
||||
self.columns = []
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
|
||||
def build_columns(self):
|
||||
for column in self.columns:
|
||||
self.list.remove_column(column)
|
||||
|
||||
column = gtk.TreeViewColumn(_('Title'), self.renderer,text=0)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(225)
|
||||
#column.set_sort_column_id(0)
|
||||
self.list.append_column(column)
|
||||
self.columns = [column]
|
||||
|
||||
index = 1
|
||||
for pair in self.parent.db.get_media_column_order():
|
||||
if not pair[0]:
|
||||
continue
|
||||
name = column_names[pair[1]]
|
||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(75)
|
||||
column.set_sort_column_id(0)
|
||||
self.columns.append(column)
|
||||
self.list.append_column(column)
|
||||
index += 1
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
|
||||
def goto(self,id):
|
||||
self.selection.unselect_all()
|
||||
@ -138,8 +158,15 @@ class MediaView:
|
||||
col = self.list.get_column (0)
|
||||
self.list.scroll_to_cell (itpath, col, gtk.TRUE, 0.5, 0)
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
def build_tree(self):
|
||||
self.list.set_model(None)
|
||||
self.model = DisplayModels.MediaModel(self.parent.db)
|
||||
|
||||
self.list.set_model(self.model)
|
||||
self.selection = self.list.get_selection()
|
||||
#self.selection.connect('changed',self.row_changed)
|
||||
#self.list.connect('row_activated', self.alpha_event)
|
||||
#self.model.connect('button-press-event',self.on_plist_button_press)
|
||||
|
||||
def on_select_row(self,obj):
|
||||
fexists = 1
|
||||
@ -247,22 +274,7 @@ class MediaView:
|
||||
ImageSelect.GlobalMediaProperties(self.db,self.obj,self.load_media)
|
||||
|
||||
def load_media(self):
|
||||
self.model.clear()
|
||||
self.id2col = {}
|
||||
|
||||
object_keys = self.db.get_object_keys()
|
||||
|
||||
for src_key in object_keys:
|
||||
src = self.db.find_object_from_id(src_key)
|
||||
title = src.get_description()
|
||||
id = src.get_id()
|
||||
type = Utils.get_mime_description(src.get_mime_type())
|
||||
path = src.get_path()
|
||||
stitle = string.upper(title)
|
||||
|
||||
iter = self.model.append()
|
||||
self.id2col[id] = iter
|
||||
self.model.set(iter, 0, title, 1, id, 2, type, 3, path, 4, stitle)
|
||||
pass
|
||||
|
||||
def on_add_clicked(self,obj):
|
||||
"""Add a new media object to the media list"""
|
||||
|
@ -1,3 +1,23 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2003 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
|
||||
#
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gtk.glade
|
||||
@ -6,23 +26,17 @@ import gnome.ui
|
||||
|
||||
from RelLib import *
|
||||
|
||||
def unique(mylist):
|
||||
a = {}
|
||||
for val in mylist:
|
||||
a[val] = 1
|
||||
return a.keys()
|
||||
|
||||
def callback(foo):
|
||||
pass
|
||||
|
||||
class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def __init__(self,db):
|
||||
def __init__(self,db,filter=None):
|
||||
|
||||
gtk.GenericTreeModel.__init__(self)
|
||||
self.db = db
|
||||
self.rebuild_data()
|
||||
self.set_property("leak_references",0)
|
||||
|
||||
self.db = db
|
||||
self.filter = filter
|
||||
|
||||
self.rebuild_data()
|
||||
self.connect('row-inserted',self.on_row_inserted)
|
||||
self.connect('row-deleted',self.on_row_deleted)
|
||||
self.fmap = [
|
||||
@ -45,16 +59,12 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
if not self.db.is_open():
|
||||
return
|
||||
|
||||
val = 0
|
||||
name_list = self.db.get_surnames()
|
||||
for name in name_list:
|
||||
self.top_iter2path[unicode(name)] = (val,)
|
||||
self.top_path2iter[val] = unicode(name)
|
||||
val += 1
|
||||
|
||||
for person_id in self.db.get_person_keys():
|
||||
|
||||
person = self.db.find_person_from_id(person_id)
|
||||
if self.filter and not self.filter(person):
|
||||
continue
|
||||
|
||||
surname = unicode(person.get_primary_name().get_surname())
|
||||
|
||||
if self.sname_sub.has_key(surname):
|
||||
@ -67,7 +77,15 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
tpl = (surname,val)
|
||||
self.iter2path[person_id] = tpl
|
||||
self.path2iter[tpl] = person_id
|
||||
|
||||
|
||||
val = 0
|
||||
name_list = self.db.get_surnames()
|
||||
for name in name_list:
|
||||
if self.sname_sub.has_key(name):
|
||||
self.top_iter2path[unicode(name)] = (val,)
|
||||
self.top_path2iter[val] = unicode(name)
|
||||
val += 1
|
||||
|
||||
def on_row_inserted(self,obj,path,iter):
|
||||
self.rebuild_data()
|
||||
|
||||
@ -86,14 +104,17 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def on_get_flags(self):
|
||||
'''returns the GtkTreeModelFlags for this particular type of model'''
|
||||
return 0
|
||||
#print "on_get_flags"
|
||||
return 1
|
||||
|
||||
def on_get_n_columns(self):
|
||||
#print "on_get_columns"
|
||||
return 5
|
||||
|
||||
def on_get_path(self, node):
|
||||
'''returns the tree path (a tuple of indices at the various
|
||||
levels) for a particular node.'''
|
||||
#print "on_get_path"
|
||||
if self.top_iter2path.has_key(node):
|
||||
return self.top_iter2path[node]
|
||||
else:
|
||||
@ -104,6 +125,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return gobject.TYPE_STRING
|
||||
|
||||
def on_get_iter(self, path):
|
||||
#print "on_get_iter"
|
||||
try:
|
||||
if len(path)==1:
|
||||
return self.top_path2iter[path[0]]
|
||||
@ -114,16 +136,18 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return None
|
||||
|
||||
def on_get_value(self,iter,col):
|
||||
#print "on_get_value", iter, col
|
||||
if self.top_iter2path.has_key(iter):
|
||||
if col == 0:
|
||||
return iter
|
||||
else:
|
||||
return ''
|
||||
return u''
|
||||
else:
|
||||
return self.fmap[col](self.db.person_map[str(iter)])
|
||||
|
||||
def on_iter_next(self, node):
|
||||
'''returns the next node at this level of the tree'''
|
||||
#print "on_iter_next"
|
||||
if self.top_iter2path.has_key(node):
|
||||
path = self.top_iter2path[node]
|
||||
return self.top_path2iter.get(path[0]+1)
|
||||
@ -132,28 +156,31 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return self.path2iter.get((surname,val+1))
|
||||
|
||||
def on_iter_children(self,node):
|
||||
"""Return the first child of the node"""
|
||||
#print "on_iter_children"
|
||||
if node == None:
|
||||
return self.top_path2iter[0]
|
||||
if self.top_iter2path.has_key(node):
|
||||
return self.path2iter.get((node,0))
|
||||
return None
|
||||
return self.path2iter.get((node,0))
|
||||
|
||||
def on_iter_has_child(self, node):
|
||||
'''returns true if this node has children'''
|
||||
#print "on_iter_has_child"
|
||||
if node == None:
|
||||
return 1
|
||||
if self.top_iter2path.has_key(node):
|
||||
return len(top_iter2path) > 0
|
||||
if self.sname_sub.has_key(node) and len(self.sname_sub[node]) > 0:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def on_iter_n_children(self,node):
|
||||
if node == NONE:
|
||||
return len(self.sname_sub)
|
||||
if self.iter2path.has_key(node):
|
||||
#print "on_iter_n_children",node
|
||||
if node == None:
|
||||
return len(self.top_iter2path)
|
||||
if self.top_iter2path.has_key(node):
|
||||
return len(self.sname_sub[node])
|
||||
return 0
|
||||
|
||||
def on_iter_nth_child(self,node,n):
|
||||
#print "on_iter_nth_child"
|
||||
path = self.top_iter2path.get(node)
|
||||
if path:
|
||||
return self.path2iter.get((node,n))
|
||||
@ -162,7 +189,8 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def on_iter_parent(self, node):
|
||||
'''returns the parent of this node'''
|
||||
path = self.iter2path[node]
|
||||
#print "on_iter_parent"
|
||||
path = self.iter2path.get(node)
|
||||
if path:
|
||||
return path[0]
|
||||
return None
|
||||
@ -190,16 +218,20 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_birth_place(self,data):
|
||||
if data[6]:
|
||||
place_id = self.db.find_event_from_id(data[5]).get_place_id()
|
||||
if place_id:
|
||||
return self.db.find_place_from_id(place_id).get_title()
|
||||
event = self.db.find_event_from_id(data[5])
|
||||
if event:
|
||||
place_id = event.get_place_id()
|
||||
if place_id:
|
||||
return self.db.find_place_from_id(place_id).get_title()
|
||||
return u""
|
||||
|
||||
def column_death_place(self,data):
|
||||
if data[5]:
|
||||
place_id = self.db.find_event_from_id(data[5]).get_place_id()
|
||||
if place_id:
|
||||
return self.db.find_place_from_id(place_id).get_title()
|
||||
event = self.db.find_event_from_id(data[5])
|
||||
if event:
|
||||
place_id = event.get_place_id()
|
||||
if place_id:
|
||||
return self.db.find_place_from_id(place_id).get_title()
|
||||
return u""
|
||||
|
||||
_GENDER = [ _('female'), _('male'), _('unknown') ]
|
||||
|
@ -38,7 +38,7 @@ import gtk.glade
|
||||
|
||||
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
|
||||
|
||||
_sel_mode = gtk.SELECTION_MULTIPLE
|
||||
_sel_mode = gtk.SELECTION_SINGLE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -47,7 +47,16 @@ _sel_mode = gtk.SELECTION_MULTIPLE
|
||||
#-------------------------------------------------------------------------
|
||||
import PeopleModel
|
||||
import Filter
|
||||
import ColumnOrder
|
||||
|
||||
column_names = [
|
||||
_('Name'),
|
||||
_('ID') ,
|
||||
_('Gender'),
|
||||
_('Birth Date'),
|
||||
_('Birth Place'),
|
||||
_('Death Date'),
|
||||
_('Death Place'),
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -63,7 +72,6 @@ class PeopleView:
|
||||
self.pscroll = self.parent.gtop.get_widget("pscroll")
|
||||
self.person_tree = self.parent.gtop.get_widget("person_tree")
|
||||
self.person_tree.set_rules_hint(gtk.TRUE)
|
||||
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
self.columns = []
|
||||
@ -78,23 +86,31 @@ class PeopleView:
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(225)
|
||||
column.set_sort_column_id(0)
|
||||
self.person_tree.append_column(column)
|
||||
self.columns = [column]
|
||||
|
||||
index = 1
|
||||
for pair in self.parent.db.get_column_order():
|
||||
if not pair[0]:
|
||||
continue
|
||||
name = ColumnOrder.column_names[pair[1]]
|
||||
name = column_names[pair[1]]
|
||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(75)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(60)
|
||||
column.set_sort_column_id(0)
|
||||
self.columns.append(column)
|
||||
self.person_tree.append_column(column)
|
||||
index += 1
|
||||
|
||||
def build_tree(self):
|
||||
self.person_tree.set_model(None)
|
||||
self.person_model = PeopleModel.PeopleModel(self.parent.db)
|
||||
|
||||
#self.sort_model = gtk.TreeModelSort(self.person_model)
|
||||
#self.person_tree.set_model(self.sort_model)
|
||||
|
||||
self.person_tree.set_model(self.person_model)
|
||||
|
||||
self.person_selection = self.person_tree.get_selection()
|
||||
@ -114,14 +130,15 @@ class PeopleView:
|
||||
"""Called with a row is changed. Check the selected objects from the person_tree
|
||||
to get the IDs of the selected objects. Set the active person to the first person
|
||||
in the list. If no one is selected, set the active person to None"""
|
||||
selected_id_list = self.get_selected_objects()
|
||||
if selected_id_list and selected_id_list[0]:
|
||||
try:
|
||||
person = self.parent.db.get_person(selected_id_list[0])
|
||||
self.parent.change_active_person(person)
|
||||
except:
|
||||
self.parent.change_active_person(None)
|
||||
self.person_tree.unselect()
|
||||
|
||||
selected_ids = self.get_selected_objects()
|
||||
|
||||
try:
|
||||
person = self.parent.db.get_person(selected_ids[0])
|
||||
self.parent.change_active_person(person)
|
||||
except:
|
||||
self.parent.change_active_person(None)
|
||||
self.person_selection.unselect_all()
|
||||
|
||||
def change_db(self,db):
|
||||
self.build_columns()
|
||||
@ -133,7 +150,6 @@ class PeopleView:
|
||||
def remove_from_person_list(self,person,old_id=None):
|
||||
"""Remove the selected person from the list. A person object is expected,
|
||||
not an ID"""
|
||||
print old_id, person.get_id()
|
||||
if old_id == None or person.get_id() == old_id:
|
||||
path = self.person_model.find_path(person.get_id())
|
||||
self.person_model.row_deleted(path)
|
||||
@ -180,13 +196,10 @@ class PeopleView:
|
||||
id = p.get_id()
|
||||
path = self.person_model.find_path(id)
|
||||
top_path = self.person_model.find_path(p.get_primary_name().get_surname())
|
||||
self.person_tree.expand_row(top_path,1)
|
||||
self.person_tree.expand_row(top_path,0)
|
||||
self.person_selection.select_path(path)
|
||||
self.person_tree.scroll_to_cell(path,None,1,0.5,0)
|
||||
|
||||
# itpath = model.model.get_path(iter)
|
||||
# col = model.tree.get_column(0)
|
||||
|
||||
def alpha_event(self,obj,a,b):
|
||||
self.parent.load_person(self.parent.active_person)
|
||||
|
||||
|
@ -41,10 +41,24 @@ import gtk.gdk
|
||||
import RelLib
|
||||
import EditPlace
|
||||
import Utils
|
||||
import DisplayModels
|
||||
import ColumnOrder
|
||||
|
||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||
from gettext import gettext as _
|
||||
|
||||
column_names = [
|
||||
_('Place Name'),
|
||||
_('ID'),
|
||||
_('Church Parish'),
|
||||
_('City'),
|
||||
_('County'),
|
||||
_('State'),
|
||||
_('Country'),
|
||||
_('Longitude'),
|
||||
_('Latitude'),
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# PlaceView class
|
||||
@ -59,84 +73,71 @@ class PlaceView:
|
||||
self.list = glade.get_widget("place_list")
|
||||
self.update = update
|
||||
|
||||
self.column_headers = [
|
||||
(_('Place Name'),7,200), (_('ID'),1,50), (_('Church Parish'),8,75),
|
||||
(_('City'),9,75), (_('County'),10,75), (_('State'),11,75),
|
||||
(_('Country'),12,75), ('',7,0), ('',8,0), ('',9,0), ('',10,0),
|
||||
('',11,0), ('',12,0)]
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
self.active = None
|
||||
|
||||
self.id2col = {}
|
||||
self.selection = self.list.get_selection()
|
||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
colno = 0
|
||||
for title in self.column_headers:
|
||||
renderer = gtk.CellRendererText ()
|
||||
renderer.set_fixed_height_from_font(1)
|
||||
column = gtk.TreeViewColumn (title[0], renderer, text=colno)
|
||||
colno = colno + 1
|
||||
column.set_clickable (gtk.TRUE)
|
||||
if title[0] == '':
|
||||
column.set_visible(gtk.FALSE)
|
||||
else:
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_visible(gtk.TRUE)
|
||||
column.set_sort_column_id(title[1])
|
||||
column.set_min_width(title[2])
|
||||
column.connect('clicked',self.on_click)
|
||||
self.list.append_column(column)
|
||||
|
||||
self.click_col = None
|
||||
|
||||
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.model = DisplayModels.PlaceModel(self.db)
|
||||
self.list.set_model(self.model)
|
||||
self.selection = self.list.get_selection()
|
||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
self.list.connect('button-press-event',self.button_press)
|
||||
self.list.connect('key-press-event',self.key_press)
|
||||
self.topWindow = self.glade.get_widget("gramps")
|
||||
|
||||
self.columns = []
|
||||
self.build_columns()
|
||||
|
||||
def build_columns(self):
|
||||
for column in self.columns:
|
||||
self.list.remove_column(column)
|
||||
|
||||
column = gtk.TreeViewColumn(_('Place Name'), self.renderer,text=0)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(225)
|
||||
#column.set_sort_column_id(0)
|
||||
self.list.append_column(column)
|
||||
self.columns = [column]
|
||||
|
||||
index = 1
|
||||
for pair in self.parent.db.get_place_column_order():
|
||||
if not pair[0]:
|
||||
continue
|
||||
name = column_names[pair[1]]
|
||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(75)
|
||||
column.set_sort_column_id(0)
|
||||
self.columns.append(column)
|
||||
self.list.append_column(column)
|
||||
index += 1
|
||||
|
||||
def on_click(self,column):
|
||||
self.click_col = column
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
|
||||
def build_tree(self):
|
||||
self.list.set_model(None)
|
||||
self.model = DisplayModels.PlaceModel(self.parent.db)
|
||||
|
||||
self.list.set_model(self.model)
|
||||
|
||||
self.selection = self.list.get_selection()
|
||||
#self.selection.connect('changed',self.row_changed)
|
||||
#self.list.connect('row_activated', self.alpha_event)
|
||||
#self.model.connect('button-press-event',self.on_plist_button_press)
|
||||
|
||||
def load_places(self,id=None):
|
||||
"""Rebuilds the entire place view. This can be very time consuming
|
||||
on large databases, and should only be called when absolutely
|
||||
necessary"""
|
||||
|
||||
del self.model
|
||||
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.id2col = {}
|
||||
|
||||
for key in self.db.sort_place_keys():
|
||||
val = self.db.get_place_display(key)
|
||||
|
||||
iter = self.model.append()
|
||||
self.id2col[key] = iter
|
||||
self.model.set(iter,
|
||||
0, val[0], 1, val[1], 2, val[2], 3, val[3],
|
||||
4, val[4], 5, val[5], 6, val[6], 7, val[7],
|
||||
8, val[8], 9, val[9], 10, val[10], 11, val[11],
|
||||
12, val[12]
|
||||
)
|
||||
self.list.set_model(self.model)
|
||||
if self.click_col:
|
||||
self.click_col.clicked()
|
||||
pass
|
||||
#self.build_tree()
|
||||
|
||||
def goto(self,id):
|
||||
self.selection.unselect_all()
|
||||
|
@ -621,14 +621,6 @@ class MediaObject(SourceNote):
|
||||
(self.id, junk, self.path, self.mime, self.desc, self.attrlist,
|
||||
self.source_list, self.note) = data
|
||||
|
||||
def set_thumbnail(self,thumb):
|
||||
"""set the thumbnail"""
|
||||
self.thumb = thumb
|
||||
|
||||
def get_thumbnail(self):
|
||||
"""return the thumbnail"""
|
||||
return self.thumb
|
||||
|
||||
def set_id(self,id):
|
||||
"""Sets the gramps ID for the place object"""
|
||||
self.id = id
|
||||
@ -2578,13 +2570,13 @@ class GrampsDB:
|
||||
|
||||
def get_default_person(self):
|
||||
"""returns the default Person of the database"""
|
||||
if self.metadata.has_key('default'):
|
||||
person = Person()
|
||||
data = self.person_map.get(self.metadata['default'])
|
||||
person.unserialize(data)
|
||||
return person
|
||||
else:
|
||||
return None
|
||||
if self.metadata:
|
||||
if self.metadata.has_key('default'):
|
||||
person = Person()
|
||||
data = self.person_map.get(self.metadata['default'])
|
||||
person.unserialize(data)
|
||||
return person
|
||||
return None
|
||||
|
||||
def get_person(self,id):
|
||||
"""returns a Person from a GRAMPS's ID"""
|
||||
@ -2986,8 +2978,18 @@ class GrampsDB:
|
||||
return place
|
||||
|
||||
def sortbyplace(self,f,s):
|
||||
fp = self.place_map[f][0].upper()
|
||||
sp = self.place_map[s][0].upper()
|
||||
fp = self.place_map[f][1].upper()
|
||||
sp = self.place_map[s][1].upper()
|
||||
return cmp(fp,sp)
|
||||
|
||||
def sortbysource(self,f,s):
|
||||
fp = self.source_map[f][1].upper()
|
||||
sp = self.source_map[s][1].upper()
|
||||
return cmp(fp,sp)
|
||||
|
||||
def sortbymedia(self,f,s):
|
||||
fp = self.media_map[f][3].upper()
|
||||
sp = self.media_map[s][3].upper()
|
||||
return cmp(fp,sp)
|
||||
|
||||
def sort_place_keys(self):
|
||||
@ -2998,6 +3000,22 @@ class GrampsDB:
|
||||
return keys
|
||||
return []
|
||||
|
||||
def sort_media_keys(self):
|
||||
if self.media_map:
|
||||
keys = self.media_map.keys()
|
||||
keys.sort(self.sortbymedia)
|
||||
return keys
|
||||
else:
|
||||
return []
|
||||
|
||||
def sort_source_keys(self):
|
||||
if self.source_map:
|
||||
keys = self.source_map.keys()
|
||||
keys.sort(self.sortbysource)
|
||||
return keys
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_place_id_keys(self):
|
||||
if self.place_map:
|
||||
return self.place_map.keys()
|
||||
@ -3183,9 +3201,54 @@ class GrampsDB:
|
||||
if self.metadata != None:
|
||||
self.metadata['columns'] = list
|
||||
|
||||
def set_place_column_order(self,list):
|
||||
if self.metadata != None:
|
||||
self.metadata['place_columns'] = list
|
||||
|
||||
def set_source_column_order(self,list):
|
||||
if self.metadata != None:
|
||||
self.metadata['source_columns'] = list
|
||||
|
||||
def set_media_column_order(self,list):
|
||||
if self.metadata != None:
|
||||
self.metadata['media_columns'] = list
|
||||
|
||||
def get_column_order(self):
|
||||
if self.metadata == None:
|
||||
return [(1,1),(1,2),(1,3),(0,4),(1,5),(0,6)]
|
||||
else:
|
||||
return self.metadata.get('columns',[(1,1),(1,2),(1,3),(0,4),(1,5),(0,6)])
|
||||
|
||||
def get_place_column_order(self):
|
||||
default = [(1,1),(1,2),(0,3),(1,4),(0,5),(1,6),(0,7),(0,8)]
|
||||
if self.metadata == None:
|
||||
return default
|
||||
else:
|
||||
cols = self.metadata.get('place_columns',default)
|
||||
if len(cols) != len(default):
|
||||
return cols + default[len(cols):]
|
||||
else:
|
||||
return cols
|
||||
|
||||
def get_source_column_order(self):
|
||||
default = [(1,1),(1,2),(1,3),(0,4)]
|
||||
if self.metadata == None:
|
||||
return default
|
||||
else:
|
||||
cols = self.metadata.get('source_columns',default)
|
||||
if len(cols) != len(default):
|
||||
return cols + default[len(cols):]
|
||||
else:
|
||||
return cols
|
||||
|
||||
def get_media_column_order(self):
|
||||
default = [(1,1),(1,2),(1,3)]
|
||||
if self.metadata == None:
|
||||
return default
|
||||
else:
|
||||
cols = self.metadata.get('meda_columns',default)
|
||||
if len(cols) != len(default):
|
||||
return cols + default[len(cols):]
|
||||
else:
|
||||
return cols
|
||||
|
||||
|
@ -20,12 +20,6 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
@ -43,9 +37,18 @@ import gtk.gdk
|
||||
import RelLib
|
||||
import EditSource
|
||||
import Utils
|
||||
import DisplayModels
|
||||
|
||||
from QuestionDialog import QuestionDialog
|
||||
|
||||
column_names = [
|
||||
_('Title'),
|
||||
_('ID'),
|
||||
_('Author'),
|
||||
_('Abbreviation'),
|
||||
_('Publication Information'),
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# internationalization
|
||||
@ -68,38 +71,50 @@ class SourceView:
|
||||
self.selection = self.list.get_selection()
|
||||
colno = 0
|
||||
|
||||
self.column_headers = [(_('Title'),3,350),(_('ID'),1,50),
|
||||
(_('Author'),4,70),('',3,0),('',4,0) ]
|
||||
self.renderer = gtk.CellRendererText()
|
||||
|
||||
for title in self.column_headers:
|
||||
renderer = gtk.CellRendererText ()
|
||||
renderer.set_fixed_height_from_font(1)
|
||||
column = gtk.TreeViewColumn (title[0], renderer, text=colno)
|
||||
colno = colno + 1
|
||||
column.set_clickable (gtk.TRUE)
|
||||
if title[0] == '':
|
||||
column.set_visible(gtk.FALSE)
|
||||
else:
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_visible(gtk.TRUE)
|
||||
column.set_sort_column_id(title[1])
|
||||
column.set_min_width(title[2])
|
||||
column.connect('clicked',self.on_click)
|
||||
self.list.append_column(column)
|
||||
|
||||
self.click_col = None
|
||||
|
||||
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.model = DisplayModels.SourceModel(self.db)
|
||||
self.list.set_model(self.model)
|
||||
self.topWindow = self.glade.get_widget("gramps")
|
||||
|
||||
self.columns = []
|
||||
self.build_columns()
|
||||
|
||||
def load_sources(self,id=None):
|
||||
pass
|
||||
|
||||
def on_click(self,column):
|
||||
self.click_col = column
|
||||
|
||||
def build_columns(self):
|
||||
for column in self.columns:
|
||||
self.list.remove_column(column)
|
||||
|
||||
column = gtk.TreeViewColumn(_('Title'), self.renderer,text=0)
|
||||
column.set_resizable(gtk.TRUE)
|
||||
#column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(225)
|
||||
#column.set_sort_column_id(0)
|
||||
self.list.append_column(column)
|
||||
self.columns = [column]
|
||||
|
||||
index = 1
|
||||
for pair in self.parent.db.get_source_column_order():
|
||||
if not pair[0]:
|
||||
continue
|
||||
name = column_names[pair[1]]
|
||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||
column.set_resizable(gtk.TRUE)
|
||||
column.set_clickable(gtk.TRUE)
|
||||
column.set_min_width(75)
|
||||
column.set_sort_column_id(0)
|
||||
self.columns.append(column)
|
||||
self.list.append_column(column)
|
||||
index += 1
|
||||
|
||||
def change_db(self,db):
|
||||
self.db = db
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
|
||||
def goto(self,id):
|
||||
iter = self.map[id]
|
||||
@ -108,23 +123,17 @@ class SourceView:
|
||||
col = self.list.get_column (0)
|
||||
self.list.scroll_to_cell (itpath, col, gtk.TRUE, 0.5, 0)
|
||||
|
||||
def load_sources(self):
|
||||
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.map = {}
|
||||
|
||||
for key in self.db.get_source_keys():
|
||||
val = self.db.get_source_display(key)
|
||||
|
||||
iter = self.model.append()
|
||||
self.map[val[1]] = iter
|
||||
self.model.set(iter, 0, val[0], 1, val[1], 2, val[2],
|
||||
3, val[3], 4, val[4])
|
||||
self.list.connect('button-press-event',self.button_press)
|
||||
self.list.connect('key-press-event',self.key_press)
|
||||
def build_tree(self):
|
||||
self.list.set_model(None)
|
||||
self.model = DisplayModels.SourceModel(self.parent.db)
|
||||
|
||||
self.list.set_model(self.model)
|
||||
|
||||
|
||||
self.selection = self.list.get_selection()
|
||||
#self.selection.connect('changed',self.row_changed)
|
||||
#self.list.connect('row_activated', self.alpha_event)
|
||||
#self.model.connect('button-press-event',self.on_plist_button_press)
|
||||
|
||||
def button_press(self,obj,event):
|
||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||
store,iter = self.selection.get_selected()
|
||||
|
@ -352,9 +352,39 @@ class Gramps:
|
||||
self.db.set_column_order(list)
|
||||
self.people_view.build_columns()
|
||||
|
||||
def set_place_column_order(self,list):
|
||||
self.db.set_place_column_order(list)
|
||||
self.place_view.build_columns()
|
||||
|
||||
def set_source_column_order(self,list):
|
||||
self.db.set_source_column_order(list)
|
||||
self.source_view.build_columns()
|
||||
|
||||
def set_media_column_order(self,list):
|
||||
self.db.set_media_column_order(list)
|
||||
self.media_view.build_columns()
|
||||
|
||||
def column_order(self,obj):
|
||||
import ColumnOrder
|
||||
ColumnOrder.ColumnOrder(self.db.get_column_order(),self.set_column_order)
|
||||
|
||||
cpage = self.views.get_current_page()
|
||||
if cpage == PERSON_VIEW:
|
||||
ColumnOrder.ColumnOrder(self.db.get_column_order(),
|
||||
PeopleView.column_names,
|
||||
self.set_column_order)
|
||||
elif cpage == SOURCE_VIEW:
|
||||
print self.db.get_source_column_order()
|
||||
ColumnOrder.ColumnOrder(self.db.get_source_column_order(),
|
||||
SourceView.column_names,
|
||||
self.set_source_column_order)
|
||||
elif cpage == PLACE_VIEW:
|
||||
ColumnOrder.ColumnOrder(self.db.get_place_column_order(),
|
||||
PlaceView.column_names,
|
||||
self.set_place_column_order)
|
||||
elif cpage == MEDIA_VIEW:
|
||||
ColumnOrder.ColumnOrder(self.db.get_media_column_order(),
|
||||
MediaView.column_names,
|
||||
self.set_media_column_order)
|
||||
|
||||
def clear_history(self):
|
||||
self.history = []
|
||||
@ -1336,10 +1366,13 @@ class Gramps:
|
||||
return 0
|
||||
|
||||
def display_relationship(self):
|
||||
default_person = self.db.get_default_person()
|
||||
if not default_person:
|
||||
return u''
|
||||
try:
|
||||
pname = GrampsCfg.nameof(self.db.get_default_person())
|
||||
pname = GrampsCfg.nameof(default_person)
|
||||
(name,plist) = self.relationship.get_relationship(
|
||||
self.db.get_default_person(),
|
||||
default_person,
|
||||
self.active_person)
|
||||
if name:
|
||||
if plist == None:
|
||||
@ -1606,6 +1639,9 @@ class Gramps:
|
||||
self.statusbar.set_progress_percentage(1.0)
|
||||
|
||||
self.people_view.change_db(self.db)
|
||||
self.place_view.change_db(self.db)
|
||||
self.source_view.change_db(self.db)
|
||||
self.media_view.change_db(self.db)
|
||||
#self.full_update()
|
||||
|
||||
self.change_active_person(self.find_initial_person())
|
||||
|
@ -55,14 +55,13 @@ import SelectPerson
|
||||
from gettext import gettext as _
|
||||
|
||||
_name2list = {
|
||||
_('Personal event:') : (const.personalEvents,const.personal_events),
|
||||
_('Family event:') : (const.marriageEvents,const.family_events),
|
||||
_('Personal attribute:') : (const.personalAttributes,const.personal_attributes),
|
||||
_('Family attribute:') : (const.familyAttributes,const.family_attributes),
|
||||
_('Relationship type:') : (const.familyRelations,const.family_relations),
|
||||
_('Personal event:') : const.personal_events,
|
||||
_('Family event:') : const.family_events,
|
||||
_('Personal attribute:') : const.personal_attributes,
|
||||
_('Family attribute:') : const.family_attributes,
|
||||
_('Relationship type:') : const.family_relations,
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MyBoolean - check button with standard interface
|
||||
@ -196,8 +195,9 @@ class MyID(gtk.HBox):
|
||||
#-------------------------------------------------------------------------
|
||||
class MySelect(gtk.Combo):
|
||||
|
||||
def __init__(self,list,transtable):
|
||||
def __init__(self,transtable):
|
||||
gtk.Combo.__init__(self)
|
||||
list = transtable.get_values()
|
||||
list.sort()
|
||||
self.set_popdown_strings(list)
|
||||
self.set_value_in_list(1,0)
|
||||
@ -465,7 +465,8 @@ class FilterEditor:
|
||||
t = MyFilters(self.filterdb.get_filters())
|
||||
elif _name2list.has_key(v1):
|
||||
data =_name2list[v1]
|
||||
t = MySelect(data[0],data[1])
|
||||
print data, data.get_values()
|
||||
t = MySelect(data.get_values(),data)
|
||||
elif v == _('Inclusive:'):
|
||||
t = MyBoolean(_('Include original person'))
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user