* src/plugins/FilterEditor.py: Multiple fixes.
* src/GenericFilter.py: Multiple fixes. svn: r4112
This commit is contained in:
parent
c4686821c7
commit
737e0acf71
@ -15,6 +15,9 @@
|
|||||||
import XML and GEDCOM.
|
import XML and GEDCOM.
|
||||||
* src/plugins/FilterEditor.py (MySelect.get_text): Typo.
|
* 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>
|
2005-02-27 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/DbPrompter.py (format_maker): Add mnemonic activation target
|
* src/DbPrompter.py (format_maker): Add mnemonic activation target
|
||||||
to the format selector label; Use new import format; don't treat
|
to the format selector label; Use new import format; don't treat
|
||||||
|
@ -655,24 +655,24 @@ class IsAncestorOf(Rule):
|
|||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root_id = self.list[0]
|
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)
|
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:
|
if not first:
|
||||||
self.map[p_id] = 1
|
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_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:
|
if fam:
|
||||||
f_id = fam.get_father_handle()
|
f_id = fam.get_father_handle()
|
||||||
m_id = fam.get_mother_handle()
|
m_id = fam.get_mother_handle()
|
||||||
|
|
||||||
if f_id:
|
if f_id:
|
||||||
self.init_ancestor_list(f_id,0)
|
self.init_ancestor_list(db,f_id,0)
|
||||||
if m_id:
|
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)
|
filt = MatchesFilter(self.list)
|
||||||
for person_handle in db.get_person_handles(sort_handles=False):
|
for person_handle in db.get_person_handles(sort_handles=False):
|
||||||
if filt.apply (db, person_handle):
|
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)
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -863,7 +863,7 @@ class IsParentOfFilterMatch(Rule):
|
|||||||
|
|
||||||
def init_list(self,p_id):
|
def init_list(self,p_id):
|
||||||
p = self.db.get_person_from_handle(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)
|
fam = self.db.get_family_from_handle(fam_id)
|
||||||
for parent_id in [fam.get_father_handle (), fam.get_mother_handle ()]:
|
for parent_id in [fam.get_father_handle (), fam.get_mother_handle ()]:
|
||||||
if parent_id:
|
if parent_id:
|
||||||
@ -1105,7 +1105,7 @@ class HasRelationship(Rule):
|
|||||||
for f_id in p.get_family_handle_list():
|
for f_id in p.get_family_handle_list():
|
||||||
f = db.get_family_from_handle(f_id)
|
f = db.get_family_from_handle(f_id)
|
||||||
cnt = cnt + len(f.get_child_handle_list())
|
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
|
rel_type = 1
|
||||||
|
|
||||||
# if number of relations specified
|
# if number of relations specified
|
||||||
@ -1353,7 +1353,7 @@ class MatchesFilter(Rule):
|
|||||||
return 'Matches the filter named'
|
return 'Matches the filter named'
|
||||||
|
|
||||||
def apply(self,db,p_id):
|
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]:
|
if filt.get_name() == self.list[0]:
|
||||||
return filt.check(p_id)
|
return filt.check(p_id)
|
||||||
for filt in CustomFilters.get_filters():
|
for filt in CustomFilters.get_filters():
|
||||||
|
@ -30,7 +30,7 @@ __author__ = "Don Allingham"
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import os
|
import os
|
||||||
import string
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -52,7 +52,6 @@ import AutoComp
|
|||||||
import ListModel
|
import ListModel
|
||||||
import Utils
|
import Utils
|
||||||
import SelectPerson
|
import SelectPerson
|
||||||
from gettext import gettext as _
|
|
||||||
|
|
||||||
_name2list = {
|
_name2list = {
|
||||||
_('Personal event:') : const.personal_events,
|
_('Personal event:') : const.personal_events,
|
||||||
@ -110,27 +109,28 @@ class MyFilters(gtk.ComboBox):
|
|||||||
|
|
||||||
def __init__(self,filters):
|
def __init__(self,filters):
|
||||||
gtk.ComboBox.__init__(self)
|
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 fname in self.flist:
|
||||||
for f in filters:
|
store.append(row=[fname])
|
||||||
flist.append(f.get_name())
|
self.set_active(0)
|
||||||
flist.sort()
|
|
||||||
if len(flist) == 0:
|
|
||||||
self.ok = 0
|
|
||||||
self.set_sensitive(0)
|
|
||||||
else:
|
|
||||||
self.ok = 1
|
|
||||||
AutoComp.fill_option_text(self,flist)
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
if self.ok:
|
active = self.get_active()
|
||||||
return unicode(AutoComp.get_option(self))
|
if active < 0:
|
||||||
else:
|
|
||||||
return ""
|
return ""
|
||||||
|
return self.flist[active]
|
||||||
|
|
||||||
def set_text(self,val):
|
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()
|
self.show()
|
||||||
|
|
||||||
def get_text(self):
|
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):
|
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):
|
def __init__(self,data_list):
|
||||||
gtk.ComboBoxEntry.__init__(self)
|
gtk.ComboBox.__init__(self)
|
||||||
new_list = []
|
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:
|
for item in data_list:
|
||||||
new_list.append(item[0])
|
store.append(row=[item[0]])
|
||||||
new_list.sort()
|
self.set_active(0)
|
||||||
AutoComp.fill_combo(self,new_list)
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def get_text(self):
|
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):
|
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_num = 0
|
||||||
self.page = []
|
self.page = []
|
||||||
self.name2page = {}
|
self.name2page = {}
|
||||||
map = {}
|
the_map = {}
|
||||||
list = []
|
the_list = []
|
||||||
keylist = GenericFilter.tasks.keys()
|
keylist = GenericFilter.tasks.keys()
|
||||||
keylist.sort()
|
keylist.sort()
|
||||||
for name in keylist:
|
for name in keylist:
|
||||||
@ -585,21 +595,24 @@ class EditRule:
|
|||||||
vallist = []
|
vallist = []
|
||||||
tlist = []
|
tlist = []
|
||||||
self.page.append((name,cname,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
|
pos = 0
|
||||||
l2 = gtk.Label(name)
|
l2 = gtk.Label(name)
|
||||||
l2.set_alignment(0,0.5)
|
l2.set_alignment(0,0.5)
|
||||||
l2.show()
|
l2.show()
|
||||||
c = gtk.ListItem()
|
c = gtk.TreeView()
|
||||||
c.add(l2)
|
|
||||||
c.set_data('d',pos)
|
c.set_data('d',pos)
|
||||||
c.show()
|
c.show()
|
||||||
list.append(c)
|
the_list.append(c)
|
||||||
map[name] = 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:
|
for v in arglist:
|
||||||
v1 = _(v)
|
v1 = _(v)
|
||||||
l = gtk.Label(v1)
|
l = gtk.Label(v1)
|
||||||
@ -652,9 +665,9 @@ class EditRule:
|
|||||||
else:
|
else:
|
||||||
self.sel_name = ""
|
self.sel_name = ""
|
||||||
|
|
||||||
for v in map.keys():
|
for v in the_map.keys():
|
||||||
filter = GenericFilter.tasks[v]([None])
|
the_filter = GenericFilter.tasks[v]([None])
|
||||||
category = filter.category()
|
category = the_filter.category()
|
||||||
if top_level.has_key(category):
|
if top_level.has_key(category):
|
||||||
top_level[category].append(v)
|
top_level[category].append(v)
|
||||||
else:
|
else:
|
||||||
@ -735,8 +748,8 @@ class EditRule:
|
|||||||
self.notebook.set_current_page(page)
|
self.notebook.set_current_page(page)
|
||||||
self.valuebox.set_sensitive(1)
|
self.valuebox.set_sensitive(1)
|
||||||
self.rule_name.set_text(key)
|
self.rule_name.set_text(key)
|
||||||
filter = GenericFilter.tasks[key]([None])
|
the_filter = GenericFilter.tasks[key]([None])
|
||||||
self.rule.get_widget('description').set_text(filter.description())
|
self.rule.get_widget('description').set_text(the_filter.description())
|
||||||
|
|
||||||
def rule_ok(self,obj):
|
def rule_ok(self,obj):
|
||||||
name = unicode(self.rule_name.get_text())
|
name = unicode(self.rule_name.get_text())
|
||||||
@ -793,7 +806,7 @@ class ShowResults:
|
|||||||
(p.get_primary_name().get_name(),p.get_gramps_id()))
|
(p.get_primary_name().get_name(),p.get_gramps_id()))
|
||||||
|
|
||||||
n.sort ()
|
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.window.set_transient_for(self.parent.window)
|
||||||
self.add_itself_to_menu()
|
self.add_itself_to_menu()
|
||||||
|
Loading…
Reference in New Issue
Block a user