* src/plugins/FilterEditor.py: Multiple fixes.

* src/GenericFilter.py: Multiple fixes.


svn: r4112
This commit is contained in:
Alex Roitman 2005-03-03 05:13:47 +00:00
parent c4686821c7
commit 737e0acf71
3 changed files with 70 additions and 54 deletions

View File

@ -15,6 +15,9 @@
import XML and GEDCOM.
* src/plugins/FilterEditor.py (MySelect.get_text): Typo.
* src/plugins/FilterEditor.py: Multiple fixes.
* src/GenericFilter.py: Multiple fixes.
2005-02-27 Alex Roitman <shura@alex.neuro.umn.edu>
* src/DbPrompter.py (format_maker): Add mnemonic activation target
to the format selector label; Use new import format; don't treat

View File

@ -655,24 +655,24 @@ class IsAncestorOf(Rule):
if not self.init:
self.init = 1
root_id = self.list[0]
self.init_ancestor_list(root_id,first)
self.init_ancestor_list(db,root_id,first)
return self.map.has_key(p_id)
def init_ancestor_list(self,p_id,first):
def init_ancestor_list(self,db,p_id,first):
if not first:
self.map[p_id] = 1
p = self.db.get_person_from_handle(p_id)
p = db.get_person_from_handle(p_id)
fam_id = p.get_main_parents_family_handle()
fam = self.db.get_family_from_handle(fam_id)
fam = db.get_family_from_handle(fam_id)
if fam:
f_id = fam.get_father_handle()
m_id = fam.get_mother_handle()
if f_id:
self.init_ancestor_list(f_id,0)
self.init_ancestor_list(db,f_id,0)
if m_id:
self.init_ancestor_list(m_id,0)
self.init_ancestor_list(db,m_id,0)
#-------------------------------------------------------------------------
#
@ -713,7 +713,7 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
filt = MatchesFilter(self.list)
for person_handle in db.get_person_handles(sort_handles=False):
if filt.apply (db, person_handle):
self.init_ancestor_list (person_handle,first)
self.init_ancestor_list (db,person_handle,first)
return self.map.has_key(p_id)
#-------------------------------------------------------------------------
@ -863,7 +863,7 @@ class IsParentOfFilterMatch(Rule):
def init_list(self,p_id):
p = self.db.get_person_from_handle(p_id)
for fam_id in p.get_main_parents_family_handle():
for fam_id,frel,mrel in p.get_parent_family_handle_list():
fam = self.db.get_family_from_handle(fam_id)
for parent_id in [fam.get_father_handle (), fam.get_mother_handle ()]:
if parent_id:
@ -1105,7 +1105,7 @@ class HasRelationship(Rule):
for f_id in p.get_family_handle_list():
f = db.get_family_from_handle(f_id)
cnt = cnt + len(f.get_child_handle_list())
if self.list[1] and f.get_relationship() == self.list[1]:
if self.list[1] and int(self.list[1]) == f.get_relationship():
rel_type = 1
# if number of relations specified
@ -1353,7 +1353,7 @@ class MatchesFilter(Rule):
return 'Matches the filter named'
def apply(self,db,p_id):
for filt in SystemFilters.get_filter():
for filt in SystemFilters.get_filters():
if filt.get_name() == self.list[0]:
return filt.check(p_id)
for filt in CustomFilters.get_filters():

View File

@ -30,7 +30,7 @@ __author__ = "Don Allingham"
#
#-------------------------------------------------------------------------
import os
import string
from gettext import gettext as _
#-------------------------------------------------------------------------
#
@ -52,7 +52,6 @@ import AutoComp
import ListModel
import Utils
import SelectPerson
from gettext import gettext as _
_name2list = {
_('Personal event:') : const.personal_events,
@ -110,27 +109,28 @@ class MyFilters(gtk.ComboBox):
def __init__(self,filters):
gtk.ComboBox.__init__(self)
store = gtk.ListStore(str)
self.set_model(store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
self.flist = [ f.get_name() for f in filters ]
self.flist.sort()
flist = []
for f in filters:
flist.append(f.get_name())
flist.sort()
if len(flist) == 0:
self.ok = 0
self.set_sensitive(0)
else:
self.ok = 1
AutoComp.fill_option_text(self,flist)
for fname in self.flist:
store.append(row=[fname])
self.set_active(0)
self.show()
def get_text(self):
if self.ok:
return unicode(AutoComp.get_option(self))
else:
active = self.get_active()
if active < 0:
return ""
return self.flist[active]
def set_text(self,val):
self.entry.set_text(val)
if val in self.flist:
self.set_active(self.flist.index(val))
#-------------------------------------------------------------------------
#
@ -205,32 +205,42 @@ class MySelect(gtk.ComboBoxEntry):
self.show()
def get_text(self):
return self.transtable.find_key(unicode(self.entry.get_text()))
return self.transtable.find_key(unicode(self.child.get_text()))
def set_text(self,val):
self.entry.set_text(_(val))
self.child.set_text(_(val))
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class MyListSelect(gtk.ComboBoxEntry):
class MyListSelect(gtk.ComboBox):
def __init__(self,data_list):
gtk.ComboBoxEntry.__init__(self)
new_list = []
gtk.ComboBox.__init__(self)
store = gtk.ListStore(str)
self.set_model(store)
cell = gtk.CellRendererText()
self.pack_start(cell,True)
self.add_attribute(cell,'text',0)
self.data_list = data_list
for item in data_list:
new_list.append(item[0])
new_list.sort()
AutoComp.fill_combo(self,new_list)
store.append(row=[item[0]])
self.set_active(0)
self.show()
def get_text(self):
return self.transtable.find_key(unicode(self.entry.get_text()))
active = self.get_active()
if active < 0:
return str(-1)
return str(active)
def set_text(self,val):
self.entry.set_text(_(val))
active = int(val)
if active >=0:
self.set_active(active)
#-------------------------------------------------------------------------
#
@ -575,8 +585,8 @@ class EditRule:
self.page_num = 0
self.page = []
self.name2page = {}
map = {}
list = []
the_map = {}
the_list = []
keylist = GenericFilter.tasks.keys()
keylist.sort()
for name in keylist:
@ -585,21 +595,24 @@ class EditRule:
vallist = []
tlist = []
self.page.append((name,cname,vallist,tlist))
table = gtk.Table(3,len(arglist))
table.set_border_width(6)
table.set_col_spacings(6)
table.set_row_spacings(6)
table.show()
pos = 0
l2 = gtk.Label(name)
l2.set_alignment(0,0.5)
l2.show()
c = gtk.ListItem()
c.add(l2)
c = gtk.TreeView()
c.set_data('d',pos)
c.show()
list.append(c)
map[name] = c
the_list.append(c)
the_map[name] = c
# Only add a table with parameters if there are any parameters
if arglist:
table = gtk.Table(3,len(arglist))
else:
table = gtk.Table(1,1)
table.set_border_width(6)
table.set_col_spacings(6)
table.set_row_spacings(6)
table.show()
for v in arglist:
v1 = _(v)
l = gtk.Label(v1)
@ -652,9 +665,9 @@ class EditRule:
else:
self.sel_name = ""
for v in map.keys():
filter = GenericFilter.tasks[v]([None])
category = filter.category()
for v in the_map.keys():
the_filter = GenericFilter.tasks[v]([None])
category = the_filter.category()
if top_level.has_key(category):
top_level[category].append(v)
else:
@ -735,8 +748,8 @@ class EditRule:
self.notebook.set_current_page(page)
self.valuebox.set_sensitive(1)
self.rule_name.set_text(key)
filter = GenericFilter.tasks[key]([None])
self.rule.get_widget('description').set_text(filter.description())
the_filter = GenericFilter.tasks[key]([None])
self.rule.get_widget('description').set_text(the_filter.description())
def rule_ok(self,obj):
name = unicode(self.rule_name.get_text())
@ -793,7 +806,7 @@ class ShowResults:
(p.get_primary_name().get_name(),p.get_gramps_id()))
n.sort ()
text.get_buffer().set_text(string.join (n, ''))
text.get_buffer().set_text(''.join(n))
self.window.set_transient_for(self.parent.window)
self.add_itself_to_menu()