* src/GenericFilter.py: Use class names for internal work; Rework
ID-based filters to use gramps-id instead of a handle. * src/plugins/FilterEditor.py: Use class names for internal work. svn: r4618
This commit is contained in:
parent
1f25c6fd38
commit
686458138a
@ -1,3 +1,8 @@
|
|||||||
|
2005-05-18 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/GenericFilter.py: Use class names for internal work; Rework
|
||||||
|
ID-based filters to use gramps-id instead of a handle.
|
||||||
|
* src/plugins/FilterEditor.py: Use class names for internal work.
|
||||||
|
|
||||||
2005-05-18 Don Allingham <don@gramps-project.org>
|
2005-05-18 Don Allingham <don@gramps-project.org>
|
||||||
* src/ReadGedcom.py: grab description for birth and death events
|
* src/ReadGedcom.py: grab description for birth and death events
|
||||||
* src/WriteGedcom.py: export description for birth and death events
|
* src/WriteGedcom.py: export description for birth and death events
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -65,6 +65,14 @@ _menulist = {
|
|||||||
_('Relationship type:') : const.family_relations,
|
_('Relationship type:') : const.family_relations,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Sorting function for the filter rules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def by_rule_name(f,s):
|
||||||
|
return cmp(f.name,s.name)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# MyBoolean - check button with standard interface
|
# MyBoolean - check button with standard interface
|
||||||
@ -213,7 +221,7 @@ class MyID(gtk.HBox):
|
|||||||
if val == None:
|
if val == None:
|
||||||
self.set_text('')
|
self.set_text('')
|
||||||
else:
|
else:
|
||||||
self.set_text(val.get_handle())
|
self.set_text(val.get_gramps_id())
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
return unicode(self.entry.get_text())
|
return unicode(self.entry.get_text())
|
||||||
@ -550,7 +558,7 @@ class EditFilter:
|
|||||||
def draw_rules(self):
|
def draw_rules(self):
|
||||||
self.rlist.clear()
|
self.rlist.clear()
|
||||||
for r in self.filter.get_rules():
|
for r in self.filter.get_rules():
|
||||||
self.rlist.add([r.trans_name(),r.display_values()],r)
|
self.rlist.add([r.name,r.display_values()],r)
|
||||||
|
|
||||||
def on_ok_clicked(self,obj):
|
def on_ok_clicked(self,obj):
|
||||||
n = unicode(self.fname.get_text()).strip()
|
n = unicode(self.fname.get_text()).strip()
|
||||||
@ -636,26 +644,21 @@ class EditRule:
|
|||||||
self.valuebox.add(self.notebook)
|
self.valuebox.add(self.notebook)
|
||||||
self.page_num = 0
|
self.page_num = 0
|
||||||
self.page = []
|
self.page = []
|
||||||
self.name2page = {}
|
self.class2page = {}
|
||||||
the_map = {}
|
the_map = {}
|
||||||
the_list = []
|
for class_obj in GenericFilter.editor_rule_list:
|
||||||
keylist = GenericFilter.tasks.keys()
|
arglist = class_obj.labels
|
||||||
keylist.sort()
|
|
||||||
for name in keylist:
|
|
||||||
cname = GenericFilter.tasks[name]
|
|
||||||
arglist = cname.labels
|
|
||||||
vallist = []
|
vallist = []
|
||||||
tlist = []
|
tlist = []
|
||||||
self.page.append((name,cname,vallist,tlist))
|
self.page.append((class_obj,vallist,tlist))
|
||||||
pos = 0
|
pos = 0
|
||||||
l2 = gtk.Label(name)
|
l2 = gtk.Label(class_obj.name)
|
||||||
l2.set_alignment(0,0.5)
|
l2.set_alignment(0,0.5)
|
||||||
l2.show()
|
l2.show()
|
||||||
c = gtk.TreeView()
|
c = gtk.TreeView()
|
||||||
c.set_data('d',pos)
|
c.set_data('d',pos)
|
||||||
c.show()
|
c.show()
|
||||||
the_list.append(c)
|
the_map[class_obj] = c
|
||||||
the_map[name] = c
|
|
||||||
# Only add a table with parameters if there are any parameters
|
# Only add a table with parameters if there are any parameters
|
||||||
if arglist:
|
if arglist:
|
||||||
table = gtk.Table(3,len(arglist))
|
table = gtk.Table(3,len(arglist))
|
||||||
@ -698,11 +701,11 @@ class EditRule:
|
|||||||
table.attach(l,1,2,pos,pos+1,gtk.FILL,0,5,5)
|
table.attach(l,1,2,pos,pos+1,gtk.FILL,0,5,5)
|
||||||
table.attach(t,2,3,pos,pos+1,gtk.EXPAND|gtk.FILL,0,5,5)
|
table.attach(t,2,3,pos,pos+1,gtk.EXPAND|gtk.FILL,0,5,5)
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
self.notebook.append_page(table,gtk.Label(name))
|
self.notebook.append_page(table,gtk.Label(class_obj.name))
|
||||||
self.name2page[name] = self.page_num
|
self.class2page[class_obj] = self.page_num
|
||||||
self.page_num = self.page_num + 1
|
self.page_num = self.page_num + 1
|
||||||
self.page_num = 0
|
self.page_num = 0
|
||||||
self.store = gtk.TreeStore(gobject.TYPE_STRING)
|
self.store = gtk.TreeStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT)
|
||||||
self.selection = self.rname.get_selection()
|
self.selection = self.rname.get_selection()
|
||||||
col = gtk.TreeViewColumn(_('Rule Name'),gtk.CellRendererText(),text=0)
|
col = gtk.TreeViewColumn(_('Rule Name'),gtk.CellRendererText(),text=0)
|
||||||
self.rname.append_column(col)
|
self.rname.append_column(col)
|
||||||
@ -719,17 +722,16 @@ class EditRule:
|
|||||||
#
|
#
|
||||||
sel_node = None
|
sel_node = None
|
||||||
if self.active_rule:
|
if self.active_rule:
|
||||||
self.sel_name = unicode(_(self.active_rule.name()))
|
self.sel_class = self.active_rule.__class__
|
||||||
else:
|
else:
|
||||||
self.sel_name = ""
|
self.sel_class = None
|
||||||
|
|
||||||
keys = the_map.keys()
|
keys = the_map.keys()
|
||||||
keys.sort()
|
keys.sort(by_rule_name)
|
||||||
keys.reverse()
|
keys.reverse()
|
||||||
catlist = []
|
catlist = []
|
||||||
for v in keys:
|
for class_obj in keys:
|
||||||
the_filter = GenericFilter.tasks[v]([None])
|
category = class_obj.category
|
||||||
category = the_filter.category()
|
|
||||||
if category not in catlist:
|
if category not in catlist:
|
||||||
catlist.append(category)
|
catlist.append(category)
|
||||||
catlist.sort()
|
catlist.sort()
|
||||||
@ -738,29 +740,28 @@ class EditRule:
|
|||||||
top_node[category] = self.store.insert_after(None,last_top)
|
top_node[category] = self.store.insert_after(None,last_top)
|
||||||
top_level[category] = []
|
top_level[category] = []
|
||||||
last_top = top_node[category]
|
last_top = top_node[category]
|
||||||
self.store.set(last_top,0,category)
|
self.store.set(last_top,0,category,1,None)
|
||||||
|
|
||||||
for v in keys:
|
for class_obj in keys:
|
||||||
the_filter = GenericFilter.tasks[v]([None])
|
category = class_obj.category
|
||||||
category = the_filter.category()
|
top_level[category].append(class_obj.name)
|
||||||
top_level[category].append(v)
|
|
||||||
node = self.store.insert_after(top_node[category],prev)
|
node = self.store.insert_after(top_node[category],prev)
|
||||||
self.store.set(node,0,v)
|
self.store.set(node,0,class_obj.name,1,class_obj)
|
||||||
|
|
||||||
#
|
#
|
||||||
# if this is an edit rule, save the node
|
# if this is an edit rule, save the node
|
||||||
if v == self.sel_name:
|
if class_obj == self.sel_class:
|
||||||
sel_node = node
|
sel_node = node
|
||||||
|
|
||||||
if sel_node:
|
if sel_node:
|
||||||
self.selection.select_iter(sel_node)
|
self.selection.select_iter(sel_node)
|
||||||
page = self.name2page[self.sel_name]
|
page = self.class2page[self.active_rule.__class__]
|
||||||
self.notebook.set_current_page(page)
|
self.notebook.set_current_page(page)
|
||||||
self.display_values(self.sel_name)
|
self.display_values(self.active_rule.__class__)
|
||||||
(n,c,v,t) = self.page[page]
|
(class_obj,vallist,tlist) = self.page[page]
|
||||||
r = self.active_rule.values()
|
r = self.active_rule.values()
|
||||||
for i in range(0,len(t)):
|
for i in range(0,len(tlist)):
|
||||||
t[i].set_text(r[i])
|
tlist[i].set_text(r[i])
|
||||||
|
|
||||||
self.selection.connect('changed', self.on_node_selected)
|
self.selection.connect('changed', self.on_node_selected)
|
||||||
self.rule.signal_autoconnect({
|
self.rule.signal_autoconnect({
|
||||||
@ -787,7 +788,10 @@ class EditRule:
|
|||||||
|
|
||||||
def add_itself_to_menu(self):
|
def add_itself_to_menu(self):
|
||||||
self.parent.child_windows[self.win_key] = self
|
self.parent.child_windows[self.win_key] = self
|
||||||
label = self.sel_name
|
if self.sel_class:
|
||||||
|
label = self.sel_class.name
|
||||||
|
else:
|
||||||
|
label = ''
|
||||||
if not label.strip():
|
if not label.strip():
|
||||||
label = _("New Rule")
|
label = _("New Rule")
|
||||||
label = "%s: %s" % (_('Rule'),label)
|
label = "%s: %s" % (_('Rule'),label)
|
||||||
@ -810,32 +814,32 @@ class EditRule:
|
|||||||
store,iter = self.selection.get_selected()
|
store,iter = self.selection.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
try:
|
try:
|
||||||
key = unicode(store.get_value(iter,0))
|
class_obj = store.get_value(iter,1)
|
||||||
self.display_values(key)
|
self.display_values(class_obj)
|
||||||
except:
|
except:
|
||||||
self.valuebox.set_sensitive(0)
|
self.valuebox.set_sensitive(0)
|
||||||
self.rule_name.set_text(_('No rule selected'))
|
self.rule_name.set_text(_('No rule selected'))
|
||||||
|
self.rule.get_widget('description').set_text('')
|
||||||
|
|
||||||
def display_values(self,key):
|
def display_values(self,class_obj):
|
||||||
page = self.name2page[key]
|
page = self.class2page[class_obj]
|
||||||
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(class_obj.name)
|
||||||
the_filter = GenericFilter.tasks[key]([None])
|
self.rule.get_widget('description').set_text(class_obj.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())
|
if self.rule_name.get_text() == _('No rule selected'):
|
||||||
class_def = GenericFilter.tasks[name]
|
return
|
||||||
obj = class_def(None)
|
|
||||||
try:
|
try:
|
||||||
page = self.name2page[name]
|
page = self.notebook.get_current_page()
|
||||||
(n,c,v,t) = self.page[page]
|
(class_obj,vallist,tlist) = self.page[page]
|
||||||
value_list = []
|
value_list = []
|
||||||
for x in t:
|
for x in tlist:
|
||||||
value_list.append(unicode(x.get_text()))
|
value_list.append(unicode(x.get_text()))
|
||||||
store,iter = self.parent.rlist.get_selected()
|
store,iter = self.parent.rlist.get_selected()
|
||||||
new_rule = c(value_list)
|
new_rule = class_obj(value_list)
|
||||||
if self.active_rule:
|
if self.active_rule:
|
||||||
rule = self.parent.rlist.get_object(iter)
|
rule = self.parent.rlist.get_object(iter)
|
||||||
self.parent.filter.delete_rule(rule)
|
self.parent.filter.delete_rule(rule)
|
||||||
@ -849,7 +853,6 @@ class EditRule:
|
|||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
DisplayTrace.DisplayTrace()
|
DisplayTrace.DisplayTrace()
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user