2008-01-18 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/FilterEditor/_EditRule.py * src/FilterEditor/_ShowResults.py * src/plugins/ExtractCity.py * src/plugins/NarrativeWeb.py * src/plugins/ChangeNames.py * src/plugins/GraphViz.py * src/plugins/MediaManager.py * src/plugins/FamilyLines.py * src/Selectors/_BaseSelector.py * src/ObjectSelector/_ObjectSelectorWindow.py * src/ObjectSelector/_FamilyFilterFrame.py * src/ObjectSelector/_PersonFilterFrame.py * src/PageView.py * src/Filters/_FilterMenu.py * src/Filters/_SearchBar.py * src/Filters/_FilterComboBox.py * src/Filters/_FilterList.py * src/Filters/_FilterParser.py * src/Filters/_FilterStore.py * src/Filters/_GenericFilter.py * src/Filters/_ParamFilter.py pylint fixes + init gtk.ListStore() with gobject.TYPE_BOOLEAN types etc svn: r9886
This commit is contained in:
parent
493c790703
commit
0fc89437fa
25
ChangeLog
25
ChangeLog
@ -1,3 +1,28 @@
|
||||
2008-01-18 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* src/FilterEditor/_EditRule.py
|
||||
* src/FilterEditor/_ShowResults.py
|
||||
* src/plugins/ExtractCity.py
|
||||
* src/plugins/NarrativeWeb.py
|
||||
* src/plugins/ChangeNames.py
|
||||
* src/plugins/GraphViz.py
|
||||
* src/plugins/MediaManager.py
|
||||
* src/plugins/FamilyLines.py
|
||||
* src/Selectors/_BaseSelector.py
|
||||
* src/ObjectSelector/_ObjectSelectorWindow.py
|
||||
* src/ObjectSelector/_FamilyFilterFrame.py
|
||||
* src/ObjectSelector/_PersonFilterFrame.py
|
||||
* src/PageView.py
|
||||
* src/Filters/_FilterMenu.py
|
||||
* src/Filters/_SearchBar.py
|
||||
* src/Filters/_FilterComboBox.py
|
||||
* src/Filters/_FilterList.py
|
||||
* src/Filters/_FilterParser.py
|
||||
* src/Filters/_FilterStore.py
|
||||
* src/Filters/_GenericFilter.py
|
||||
* src/Filters/_ParamFilter.py
|
||||
pylint fixes + init gtk.ListStore() with gobject.TYPE_BOOLEAN types etc
|
||||
|
||||
|
||||
2008-01-18 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* src/gen/db/dbdir.py
|
||||
* src/plugins/ChangeNames.py
|
||||
|
@ -148,7 +148,7 @@ class MyFilters(gtk.ComboBox):
|
||||
If filter_name is given, it will be excluded from the dropdown box
|
||||
"""
|
||||
gtk.ComboBox.__init__(self)
|
||||
store = gtk.ListStore(str)
|
||||
store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.set_model(store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
@ -182,7 +182,7 @@ class MyLesserEqualGreater(gtk.ComboBox):
|
||||
|
||||
def __init__(self):
|
||||
gtk.ComboBox.__init__(self)
|
||||
store = gtk.ListStore(str)
|
||||
store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.set_model(store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
@ -215,7 +215,7 @@ class MySource(gtk.ComboBox):
|
||||
def __init__(self, db):
|
||||
gtk.ComboBox.__init__(self)
|
||||
self.db = db
|
||||
store = gtk.ListStore(str)
|
||||
store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.set_model(store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
|
@ -81,7 +81,7 @@ class ShowResults(ManagedWindow.ManagedWindow):
|
||||
render = gtk.CellRendererText()
|
||||
|
||||
tree = self.get_widget('list')
|
||||
model = gtk.ListStore(str, str)
|
||||
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
tree.set_model(model)
|
||||
|
||||
column_n = gtk.TreeViewColumn(_('Name'), render, text=0)
|
||||
|
@ -30,6 +30,7 @@ Package providing filtering framework for GRAMPS.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -46,7 +47,7 @@ from Filters import SystemFilters, CustomFilters
|
||||
class FilterComboBox(gtk.ComboBox):
|
||||
|
||||
def set(self,local_filters,default=""):
|
||||
self.store = gtk.ListStore(str)
|
||||
self.store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.set_model(self.store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
|
@ -25,7 +25,7 @@
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from xml.sax import make_parser,SAXParseException
|
||||
from xml.sax import make_parser, SAXParseException
|
||||
import os
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -33,7 +33,7 @@ import os
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from _FilterParser import FilterParser
|
||||
from Filters._FilterParser import FilterParser
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -46,17 +46,17 @@ class FilterList:
|
||||
It stores, saves, and loads the filters.
|
||||
"""
|
||||
|
||||
def __init__(self,file):
|
||||
def __init__(self, file):
|
||||
self.filter_namespaces = {}
|
||||
self.file = os.path.expanduser(file)
|
||||
|
||||
def get_filters(self,namespace='generic'):
|
||||
def get_filters(self, namespace='generic'):
|
||||
try:
|
||||
return self.filter_namespaces[namespace]
|
||||
except KeyError:
|
||||
return []
|
||||
|
||||
def add(self,namespace,filt):
|
||||
def add(self, namespace, filt):
|
||||
assert(type(namespace)==str or type(namespace)==unicode)
|
||||
|
||||
if namespace not in self.filter_namespaces.keys():
|
||||
@ -76,15 +76,15 @@ class FilterList:
|
||||
except SAXParseException:
|
||||
print "Parser error"
|
||||
|
||||
def fix(self,line):
|
||||
def fix(self, line):
|
||||
l = line.strip()
|
||||
l = l.replace('&','&')
|
||||
l = l.replace('>','>')
|
||||
l = l.replace('<','<')
|
||||
return l.replace('"','"')
|
||||
l = l.replace('&', '&')
|
||||
l = l.replace('>', '>')
|
||||
l = l.replace('<', '<')
|
||||
return l.replace('"', '"')
|
||||
|
||||
def save(self):
|
||||
f = open(self.file.encode('utf-8'),'w')
|
||||
f = open(self.file.encode('utf-8'), 'w')
|
||||
|
||||
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
f.write('<filters>\n')
|
||||
@ -103,8 +103,8 @@ class FilterList:
|
||||
for rule in the_filter.get_rules():
|
||||
f.write(' <rule class="%s">\n'
|
||||
% rule.__class__.__name__)
|
||||
for v in rule.values():
|
||||
f.write(' <arg value="%s"/>\n' % self.fix(v))
|
||||
for value in rule.values():
|
||||
f.write(' <arg value="%s"/>\n' % self.fix(value))
|
||||
f.write(' </rule>\n')
|
||||
f.write(' </filter>\n')
|
||||
f.write('</object>\n')
|
||||
|
@ -68,7 +68,7 @@ def build_filter_model(space, local = [], default=""):
|
||||
model = gtk.ListStore(str, object)
|
||||
|
||||
flist = local + SystemFilters.get_filters(space) + \
|
||||
CustomFilters.get_filters(space)
|
||||
CustomFilters.get_filters(space)
|
||||
|
||||
for filt in flist:
|
||||
model.append(row=[filt.get_name(), filt])
|
||||
|
@ -32,8 +32,8 @@ from xml.sax import handler
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from _GenericFilter import GenericFilterFactory
|
||||
import Rules
|
||||
from Filters._GenericFilter import GenericFilterFactory
|
||||
from Filters import Rules
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -43,7 +43,7 @@ import Rules
|
||||
class FilterParser(handler.ContentHandler):
|
||||
"""Parses the XML file and builds the list of filters"""
|
||||
|
||||
def __init__(self,gfilter_list):
|
||||
def __init__(self, gfilter_list):
|
||||
handler.ContentHandler.__init__(self)
|
||||
self.gfilter_list = gfilter_list
|
||||
self.f = None
|
||||
@ -52,10 +52,10 @@ class FilterParser(handler.ContentHandler):
|
||||
self.cname = None
|
||||
self.namespace = "Person"
|
||||
|
||||
def setDocumentLocator(self,locator):
|
||||
def setDocumentLocator(self, locator):
|
||||
self.locator = locator
|
||||
|
||||
def startElement(self,tag,attrs):
|
||||
def startElement(self, tag, attrs):
|
||||
if tag == "object":
|
||||
if attrs.has_key('type'):
|
||||
self.namespace = attrs['type']
|
||||
@ -79,7 +79,7 @@ class FilterParser(handler.ContentHandler):
|
||||
self.f.set_invert(attrs['invert'])
|
||||
if attrs.has_key('comment'):
|
||||
self.f.set_comment(attrs['comment'])
|
||||
self.gfilter_list.add(self.namespace,self.f)
|
||||
self.gfilter_list.add(self.namespace, self.f)
|
||||
elif tag == "rule":
|
||||
save_name = attrs['class']
|
||||
if save_name in old_names_2_class.keys():
|
||||
@ -98,14 +98,14 @@ class FilterParser(handler.ContentHandler):
|
||||
except (ImportError, NameError, AttributeError ):
|
||||
print "ERROR: Filter rule '%s' in "\
|
||||
"filter '%s' not found!"\
|
||||
% (save_name,self.f.get_name())
|
||||
% (save_name, self.f.get_name())
|
||||
self.r = None
|
||||
return
|
||||
self.a = []
|
||||
elif tag == "arg":
|
||||
self.a.append(attrs['value'])
|
||||
|
||||
def endElement(self,tag):
|
||||
def endElement(self, tag):
|
||||
if tag == "rule" and self.r != None:
|
||||
if len(self.r.labels) < len(self.a):
|
||||
print "WARNING: Invalid number of arguments in filter '%s'!" %\
|
||||
@ -114,7 +114,7 @@ class FilterParser(handler.ContentHandler):
|
||||
rule = self.r(self.a[0:nargs])
|
||||
self.f.add_rule(rule)
|
||||
elif len(self.r.labels) > len(self.a):
|
||||
print "ERROR: Invalid number of arguments in filter '%s'!" %\
|
||||
print "ERROR: Invalid number of arguments in filter '%s'!" % \
|
||||
self.f.get_name()
|
||||
else:
|
||||
rule = self.r(self.a)
|
||||
|
@ -37,7 +37,6 @@ from gettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from _GenericFilter import GenericFilter
|
||||
from Filters import SystemFilters, CustomFilters
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -47,8 +46,8 @@ from Filters import SystemFilters, CustomFilters
|
||||
#-------------------------------------------------------------------------
|
||||
class FilterStore(gtk.ListStore):
|
||||
|
||||
def __init__(self,local_filters=[], namespace="generic",default=""):
|
||||
gtk.ListStore.__init__(self,str)
|
||||
def __init__(self, local_filters=[], namespace="generic", default=""):
|
||||
gtk.ListStore.__init__(self, str)
|
||||
self.list_map = []
|
||||
self.def_index = 0
|
||||
|
||||
@ -61,7 +60,8 @@ class FilterStore(gtk.ListStore):
|
||||
self.def_index = cnt
|
||||
cnt += 1
|
||||
|
||||
for filt in SystemFilters.get_filters(namespace) + CustomFilters.get_filters(namespace):
|
||||
for filt in SystemFilters.get_filters(namespace) + \
|
||||
CustomFilters.get_filters(namespace):
|
||||
name = _(filt.get_name())
|
||||
self.append(row=[name])
|
||||
self.list_map.append(filt)
|
||||
@ -72,5 +72,5 @@ class FilterStore(gtk.ListStore):
|
||||
def default_index(self):
|
||||
return self.def_index
|
||||
|
||||
def get_filter(self,index):
|
||||
def get_filter(self, index):
|
||||
return self.list_map[index]
|
||||
|
@ -35,7 +35,7 @@ class GenericFilter:
|
||||
|
||||
logical_functions = ['or', 'and', 'xor', 'one']
|
||||
|
||||
def __init__(self,source=None):
|
||||
def __init__(self, source=None):
|
||||
if source:
|
||||
self.need_param = source.need_param
|
||||
self.flist = source.flist[:]
|
||||
@ -51,18 +51,20 @@ class GenericFilter:
|
||||
self.logical_op = 'and'
|
||||
self.invert = False
|
||||
|
||||
def match(self,handle,db):
|
||||
"""Return True or False depending on whether the handle matches the
|
||||
filter """
|
||||
if self.apply(db,[handle]):
|
||||
def match(self, handle, db):
|
||||
"""
|
||||
Return True or False depending on whether the handle matches the filter.
|
||||
"""
|
||||
if self.apply(db, [handle]):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_empty(self):
|
||||
return len(self.flist) == 0 or (len(self.flist) == 1 and self.flist[0].is_empty())
|
||||
return len(self.flist) == 0 or \
|
||||
(len(self.flist) == 1 and self.flist[0].is_empty())
|
||||
|
||||
def set_logical_op(self,val):
|
||||
def set_logical_op(self, val):
|
||||
if val in GenericFilter.logical_functions:
|
||||
self.logical_op = val
|
||||
else:
|
||||
@ -71,7 +73,7 @@ class GenericFilter:
|
||||
def get_logical_op(self):
|
||||
return self.logical_op
|
||||
|
||||
def set_invert(self,val):
|
||||
def set_invert(self, val):
|
||||
self.invert = bool(val)
|
||||
|
||||
def get_invert(self):
|
||||
@ -80,22 +82,22 @@ class GenericFilter:
|
||||
def get_name(self):
|
||||
return self.name
|
||||
|
||||
def set_name(self,name):
|
||||
def set_name(self, name):
|
||||
self.name = name
|
||||
|
||||
def set_comment(self,comment):
|
||||
def set_comment(self, comment):
|
||||
self.comment = comment
|
||||
|
||||
def get_comment(self):
|
||||
return self.comment
|
||||
|
||||
def add_rule(self,rule):
|
||||
def add_rule(self, rule):
|
||||
self.flist.append(rule)
|
||||
|
||||
def delete_rule(self,rule):
|
||||
def delete_rule(self, rule):
|
||||
self.flist.remove(rule)
|
||||
|
||||
def set_rules(self,rules):
|
||||
def set_rules(self, rules):
|
||||
self.flist = rules
|
||||
|
||||
def get_rules(self):
|
||||
@ -110,7 +112,7 @@ class GenericFilter:
|
||||
def find_from_handle(self, db, handle):
|
||||
return db.get_person_from_handle(handle)
|
||||
|
||||
def check_func(self,db,id_list,task):
|
||||
def check_func(self, db, id_list, task):
|
||||
final_list = []
|
||||
|
||||
if id_list == None:
|
||||
@ -119,18 +121,18 @@ class GenericFilter:
|
||||
while data:
|
||||
person = self.make_obj()
|
||||
person.unserialize(data[1])
|
||||
if task(db,person) != self.invert:
|
||||
if task(db, person) != self.invert:
|
||||
final_list.append(data[0])
|
||||
data = cursor.next()
|
||||
cursor.close()
|
||||
else:
|
||||
for handle in id_list:
|
||||
person = self.find_from_handle(db, handle)
|
||||
if task(db,person) != self.invert:
|
||||
if task(db, person) != self.invert:
|
||||
final_list.append(handle)
|
||||
return final_list
|
||||
|
||||
def check_and(self,db,id_list):
|
||||
def check_and(self, db, id_list):
|
||||
final_list = []
|
||||
flist = self.flist
|
||||
if id_list == None:
|
||||
@ -141,7 +143,7 @@ class GenericFilter:
|
||||
person.unserialize(data[1])
|
||||
val = True
|
||||
for rule in flist:
|
||||
if not rule.apply(db,person):
|
||||
if not rule.apply(db, person):
|
||||
val = False
|
||||
break
|
||||
if val != self.invert:
|
||||
@ -153,40 +155,40 @@ class GenericFilter:
|
||||
person = self.find_from_handle(db, handle)
|
||||
val = True
|
||||
for rule in flist:
|
||||
if not rule.apply(db,person):
|
||||
if not rule.apply(db, person):
|
||||
val = False
|
||||
break
|
||||
if val != self.invert:
|
||||
final_list.append(handle)
|
||||
return final_list
|
||||
|
||||
def check_or(self,db,id_list):
|
||||
return self.check_func(db,id_list,self.or_test)
|
||||
def check_or(self, db, id_list):
|
||||
return self.check_func(db, id_list, self.or_test)
|
||||
|
||||
def check_one(self,db,id_list):
|
||||
return self.check_func(db,id_list,self.one_test)
|
||||
def check_one(self, db, id_list):
|
||||
return self.check_func(db, id_list, self.one_test)
|
||||
|
||||
def check_xor(self,db,id_list):
|
||||
return self.check_func(db,id_list,self.xor_test)
|
||||
def check_xor(self, db, id_list):
|
||||
return self.check_func(db, id_list, self.xor_test)
|
||||
|
||||
def xor_test(self,db,person):
|
||||
def xor_test(self, db, person):
|
||||
test = False
|
||||
for rule in self.flist:
|
||||
test = test ^ rule.apply(db,person)
|
||||
test = test ^ rule.apply(db, person)
|
||||
return test
|
||||
|
||||
def one_test(self,db,person):
|
||||
def one_test(self, db, person):
|
||||
count = 0
|
||||
for rule in self.flist:
|
||||
if rule.apply(db,person):
|
||||
if rule.apply(db, person):
|
||||
if count:
|
||||
return False
|
||||
count += 1
|
||||
return count == 1
|
||||
|
||||
def or_test(self,db,person):
|
||||
def or_test(self, db, person):
|
||||
for rule in self.flist:
|
||||
if rule.apply(db,person):
|
||||
if rule.apply(db, person):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -197,14 +199,14 @@ class GenericFilter:
|
||||
m = self.check_and
|
||||
return m
|
||||
|
||||
def check(self,db,handle):
|
||||
return self.get_check_func()(db,[handle])
|
||||
def check(self, db, handle):
|
||||
return self.get_check_func()(db, [handle])
|
||||
|
||||
def apply(self,db,id_list=None):
|
||||
def apply(self, db, id_list=None):
|
||||
m = self.get_check_func()
|
||||
for rule in self.flist:
|
||||
rule.prepare(db)
|
||||
res = m(db,id_list)
|
||||
res = m(db, id_list)
|
||||
for rule in self.flist:
|
||||
rule.reset()
|
||||
return res
|
||||
|
@ -29,7 +29,7 @@ Package providing filtering framework for GRAMPS.
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from _GenericFilter import GenericFilter
|
||||
from Filters._GenericFilter import GenericFilter
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -38,15 +38,15 @@ from _GenericFilter import GenericFilter
|
||||
#-------------------------------------------------------------------------
|
||||
class ParamFilter(GenericFilter):
|
||||
|
||||
def __init__(self,source=None):
|
||||
GenericFilter.__init__(self,source)
|
||||
def __init__(self, source=None):
|
||||
GenericFilter.__init__(self, source)
|
||||
self.need_param = 1
|
||||
self.param_list = []
|
||||
|
||||
def set_parameter(self,param):
|
||||
def set_parameter(self, param):
|
||||
self.param_list = [param]
|
||||
|
||||
def apply(self,db,id_list=None):
|
||||
def apply(self, db, id_list=None):
|
||||
for rule in self.flist:
|
||||
#rule.set_list(self.param_list)
|
||||
#
|
||||
@ -59,7 +59,7 @@ class ParamFilter(GenericFilter):
|
||||
rule.set_list(new_list)
|
||||
for rule in self.flist:
|
||||
rule.prepare(db)
|
||||
result = GenericFilter.apply(self,db,id_list)
|
||||
result = GenericFilter.apply(self, db, id_list)
|
||||
for rule in self.flist:
|
||||
rule.reset()
|
||||
return result
|
||||
|
@ -17,6 +17,7 @@
|
||||
# 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
|
||||
|
||||
# $Id$
|
||||
|
||||
@ -47,29 +48,33 @@ class SearchBar:
|
||||
self.dbstate = dbstate
|
||||
self.uistate = uistate
|
||||
self.apply_text = ''
|
||||
|
||||
self.filterbar = gtk.HBox()
|
||||
self.filter_text = gtk.Entry()
|
||||
self.filter_button = gtk.Button(stock=gtk.STOCK_FIND)
|
||||
self.clear_button = gtk.Button(stock=gtk.STOCK_CLEAR)
|
||||
self.filter_list = gtk.ComboBox()
|
||||
self.filter_model = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
|
||||
def build( self):
|
||||
self.filterbar = gtk.HBox()
|
||||
self.filterbar.set_spacing(4)
|
||||
self.filter_list = gtk.ComboBox()
|
||||
self.filter_list.connect('changed', self.filter_changed)
|
||||
|
||||
self.filter_text = gtk.Entry()
|
||||
self.filter_text.connect('key-press-event',self.key_press)
|
||||
self.filter_text.connect('changed',self.text_changed)
|
||||
self.filter_text.connect('key-press-event', self.key_press)
|
||||
self.filter_text.connect('changed', self.text_changed)
|
||||
|
||||
self.filter_button = gtk.Button(stock=gtk.STOCK_FIND)
|
||||
self.filter_button.connect( 'clicked',self.apply_filter_clicked)
|
||||
self.filter_button.connect( 'clicked', self.apply_filter_clicked)
|
||||
self.filter_button.set_sensitive(False)
|
||||
|
||||
self.clear_button = gtk.Button(stock=gtk.STOCK_CLEAR)
|
||||
self.clear_button.connect( 'clicked',self.apply_clear)
|
||||
self.clear_button.connect( 'clicked', self.apply_clear)
|
||||
self.clear_button.set_sensitive(False)
|
||||
|
||||
self.filterbar.pack_start(self.filter_list,False)
|
||||
self.filterbar.pack_start(self.filter_text,True)
|
||||
self.filterbar.pack_end(self.clear_button,False)
|
||||
self.filterbar.pack_end(self.filter_button,False)
|
||||
self.filterbar.pack_start(self.filter_list, False)
|
||||
self.filterbar.pack_start(self.filter_text, True)
|
||||
self.filterbar.pack_end(self.clear_button, False)
|
||||
self.filterbar.pack_end(self.filter_button, False)
|
||||
|
||||
return self.filterbar
|
||||
|
||||
@ -78,18 +83,17 @@ class SearchBar:
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
self.filter_list.clear()
|
||||
self.filter_list.pack_start(cell,True)
|
||||
self.filter_list.add_attribute(cell,'text',0)
|
||||
self.filter_list.pack_start(cell, True)
|
||||
self.filter_list.add_attribute(cell, 'text', 0)
|
||||
|
||||
self.filter_model = gtk.ListStore(str, int, bool)
|
||||
|
||||
maxval = 0
|
||||
for col,index in column_data:
|
||||
for col, index in column_data:
|
||||
rule = _("%s contains") % col
|
||||
self.filter_model.append(row=[rule,index,False])
|
||||
self.filter_model.append(row=[rule, index, False])
|
||||
maxval += 1
|
||||
rule = _("%s does not contain") % col
|
||||
self.filter_model.append(row=[rule,index,True])
|
||||
self.filter_model.append(row=[rule, index, True])
|
||||
maxval += 1
|
||||
|
||||
self.filter_list.set_model(self.filter_model)
|
||||
@ -132,8 +136,8 @@ class SearchBar:
|
||||
def get_value(self):
|
||||
text = unicode(self.filter_text.get_text()).strip()
|
||||
node = self.filter_list.get_active_iter()
|
||||
index = self.filter_model.get_value(node,1)
|
||||
inv = self.filter_model.get_value(node,2)
|
||||
index = self.filter_model.get_value(node, 1)
|
||||
inv = self.filter_model.get_value(node, 2)
|
||||
return (index, text, inv)
|
||||
|
||||
def apply_filter(self, current_model=None):
|
||||
|
@ -58,7 +58,7 @@ class FamilyFilterFrame(FilterFrameBase):
|
||||
filters = [ filter for filter in default_filters if \
|
||||
not hasattr(filter,'labels') or len(filter.labels) == 0 ]
|
||||
|
||||
self._filter_list = gtk.ListStore(str,object)
|
||||
self._filter_list = gtk.ListStore(str, object)
|
||||
|
||||
for filter in filters:
|
||||
self._filter_list.append([filter.name,filter])
|
||||
|
@ -160,7 +160,9 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
|
||||
person_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(const.IMAGE_DIR,"person.svg"))
|
||||
flist_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(const.IMAGE_DIR,"flist.svg"))
|
||||
|
||||
self._tool_list = gtk.ListStore(gtk.gdk.Pixbuf, str,int)
|
||||
self._tool_list = gtk.ListStore(gtk.gdk.Pixbuf,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT)
|
||||
|
||||
d={ObjectTypes.PERSON: [person_pixbuf,'People',ObjectTypes.PERSON],
|
||||
ObjectTypes.FAMILY: [flist_pixbuf,'Families',ObjectTypes.FAMILY],
|
||||
@ -169,7 +171,8 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
|
||||
self._object_type_column = 2
|
||||
|
||||
except gobject.GError:
|
||||
self._tool_list = gtk.ListStore(str,int)
|
||||
self._tool_list = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT)
|
||||
|
||||
d={ObjectTypes.PERSON: ['People',ObjectTypes.PERSON],
|
||||
ObjectTypes.FAMILY: ['Families',ObjectTypes.FAMILY],
|
||||
|
@ -61,7 +61,8 @@ class PersonFilterFrame(FilterFrameBase):
|
||||
[_("Female"),gen.lib.Person.FEMALE],
|
||||
[_("Unknown"),gen.lib.Person.UNKNOWN]]
|
||||
|
||||
self._gender_list = gtk.ListStore(str,int)
|
||||
self._gender_list = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT)
|
||||
|
||||
for entry in genders:
|
||||
self._gender_list.append(entry)
|
||||
@ -110,7 +111,7 @@ class PersonFilterFrame(FilterFrameBase):
|
||||
filters = [ filter for filter in default_filters if \
|
||||
not hasattr(filter,'labels') or len(filter.labels) == 0 ]
|
||||
|
||||
self._filter_list = gtk.ListStore(str,object)
|
||||
self._filter_list = gtk.ListStore(str, gobject)
|
||||
|
||||
for filter in filters:
|
||||
self._filter_list.append([filter.name,filter])
|
||||
|
@ -739,9 +739,7 @@ class ListView(BookMarkView):
|
||||
return True
|
||||
|
||||
def setup_filter(self):
|
||||
"""
|
||||
Builds the default filters and add them to the filter menu.
|
||||
"""
|
||||
"""Build the default filters and add them to the filter menu."""
|
||||
cols = []
|
||||
for pair in [pair for pair in self.column_order() if pair[0]]:
|
||||
cols.append((self.colinfo[pair[1]], pair[1]))
|
||||
|
@ -78,8 +78,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
|
||||
self.colinfo = self.column_view_names()
|
||||
#add the search bar
|
||||
self.search_bar = SearchBar(dbstate, uistate,
|
||||
self.build_tree)
|
||||
self.search_bar = SearchBar(dbstate, uistate, self.build_tree)
|
||||
filter_box = self.search_bar.build()
|
||||
self.setup_filter()
|
||||
vbox.pack_start(filter_box, False, False)
|
||||
|
@ -104,7 +104,8 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
self.list = self.top.get_widget("list")
|
||||
self.set_window(window,self.top.get_widget('title'),self.label)
|
||||
|
||||
self.model = gtk.ListStore(bool, str, str)
|
||||
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
|
||||
r = gtk.CellRendererToggle()
|
||||
r.connect('toggled',self.toggled)
|
||||
|
@ -39,6 +39,7 @@ from gettext import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gtk.glade
|
||||
import gobject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -474,7 +475,10 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
'be extracted from the place title. Select the places you '
|
||||
'wish GRAMPS to convert.'))
|
||||
|
||||
self.model = gtk.ListStore(bool, str, str, str, str, str, str)
|
||||
self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
|
||||
r = gtk.CellRendererToggle()
|
||||
r.connect('toggled', self.toggled)
|
||||
|
@ -938,10 +938,12 @@ class FamilyLinesOptions(ReportOptions):
|
||||
# ******** FAMILY COLOURS **********
|
||||
title = _("Family Colours")
|
||||
|
||||
self.familyLinesModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
self.familyLinesModel = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
self.familyLinesTreeView = gtk.TreeView(self.familyLinesModel)
|
||||
self.familyLinesTreeView.set_size_request(150, 150)
|
||||
self.familyLinesTreeView.connect('row-activated', self.dialog.familyLinesClicked)
|
||||
self.familyLinesTreeView.connect('row-activated',
|
||||
self.dialog.familyLinesClicked)
|
||||
col1 = gtk.TreeViewColumn(_('Surname'), gtk.CellRendererText(), text=0)
|
||||
col2 = gtk.TreeViewColumn(_('Colour'), gtk.CellRendererText(), text=1)
|
||||
col1.set_resizable(True)
|
||||
@ -953,13 +955,17 @@ class FamilyLinesOptions(ReportOptions):
|
||||
self.familyLinesTreeView.append_column(col2)
|
||||
self.familyLinesScrolledWindow = gtk.ScrolledWindow()
|
||||
self.familyLinesScrolledWindow.add(self.familyLinesTreeView)
|
||||
self.familyLinesScrolledWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.familyLinesScrolledWindow.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
self.familyLinesScrolledWindow.set_shadow_type(gtk.SHADOW_OUT)
|
||||
self.familyLinesHbox = gtk.HBox()
|
||||
self.familyLinesHbox.pack_start(self.familyLinesScrolledWindow, expand=True, fill=True)
|
||||
self.familyLinesHbox.pack_start(self.familyLinesScrolledWindow,
|
||||
expand=True, fill=True)
|
||||
|
||||
self.addSurname = GrampsWidgets.SimpleButton(gtk.STOCK_ADD, self.dialog.addSurnameClicked)
|
||||
self.delSurname = GrampsWidgets.SimpleButton(gtk.STOCK_REMOVE, self.dialog.delSurnameClicked)
|
||||
self.addSurname = GrampsWidgets.SimpleButton(gtk.STOCK_ADD,
|
||||
self.dialog.addSurnameClicked)
|
||||
self.delSurname = GrampsWidgets.SimpleButton(gtk.STOCK_REMOVE,
|
||||
self.dialog.delSurnameClicked)
|
||||
self.familyLinesVbbox = gtk.VButtonBox()
|
||||
self.familyLinesVbbox.add(self.addSurname)
|
||||
self.familyLinesVbbox.add(self.delSurname)
|
||||
|
@ -50,6 +50,7 @@ log = logging.getLogger(".GraphViz")
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -761,7 +762,7 @@ class GraphVizOptions(ReportOptions):
|
||||
def add_list(self, options, default):
|
||||
"returns compobox of given options and default value"
|
||||
box = gtk.ComboBox()
|
||||
store = gtk.ListStore(str)
|
||||
store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
box.set_model(store)
|
||||
cell = gtk.CellRendererText()
|
||||
box.pack_start(cell,True)
|
||||
@ -1100,7 +1101,7 @@ class FormatComboBox(gtk.ComboBox):
|
||||
"""
|
||||
|
||||
def set(self,tables=0,callback=None,obj=None,active=None):
|
||||
self.store = gtk.ListStore(str)
|
||||
self.store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.set_model(self.store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
@ -1148,7 +1149,7 @@ class GraphicsFormatComboBox(gtk.ComboBox):
|
||||
"""
|
||||
|
||||
def set(self,active=None):
|
||||
self.store = gtk.ListStore(str)
|
||||
self.store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.set_model(self.store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
|
@ -38,6 +38,7 @@ from gettext import gettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -238,7 +239,7 @@ class MediaMan(Tool.Tool):
|
||||
scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
scrolled_window.set_shadow_type(gtk.SHADOW_IN)
|
||||
tree = gtk.TreeView()
|
||||
model = gtk.ListStore(str)
|
||||
model = gtk.ListStore(gobject.TYPE_STRING)
|
||||
tree.set_model(model)
|
||||
tree_view_column = gtk.TreeViewColumn(_('Affected path'),
|
||||
gtk.CellRendererText(),text=0)
|
||||
|
@ -58,6 +58,7 @@ log = logging.getLogger(".WebPage")
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -2821,7 +2822,7 @@ class WebReportOptions(ReportOptions):
|
||||
cset_node = None
|
||||
cset = self.options_dict['NWEBencoding']
|
||||
|
||||
store = gtk.ListStore(str,str)
|
||||
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
for data in _character_sets:
|
||||
if data[1] == cset:
|
||||
cset_node = store.append(row=data)
|
||||
@ -2831,7 +2832,7 @@ class WebReportOptions(ReportOptions):
|
||||
|
||||
cset_node = None
|
||||
cset = self.options_dict['NWEBcss']
|
||||
store = gtk.ListStore(str,str)
|
||||
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
for data in _css_files:
|
||||
if data[1] == cset:
|
||||
cset_node = store.append(row=data)
|
||||
|
Loading…
Reference in New Issue
Block a user