Logic operations for filters.

svn: r899
This commit is contained in:
Don Allingham 2002-04-08 03:19:43 +00:00
parent 13549c6109
commit c4856abc56
10 changed files with 383 additions and 107 deletions

View File

@ -1957,14 +1957,19 @@
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_name_list_select_row</handler>
<last_modification_time>Mon, 18 Dec 2000 22:29:26 GMT</last_modification_time>
<handler>on_name_select_row</handler>
<last_modification_time>Sun, 07 Apr 2002 04:37:52 GMT</last_modification_time>
</signal>
<signal>
<name>button_press_event</name>
<handler>on_name_button_press</handler>
<last_modification_time>Sun, 04 Nov 2001 15:40:59 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_name_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 04:37:40 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>350,100,50</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -2046,6 +2051,7 @@
<widget>
<class>GtkButton</class>
<name>aka_update</name>
<sensitive>False</sensitive>
<tooltip>Modify the selected name</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -2062,6 +2068,7 @@
<widget>
<class>GtkButton</class>
<name>aka_delete</name>
<sensitive>False</sensitive>
<tooltip>Delete selected name</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -2628,6 +2635,11 @@
<handler>on_event_button_press</handler>
<last_modification_time>Sun, 04 Nov 2001 15:29:48 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_event_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 04:54:47 GMT</last_modification_time>
</signal>
<columns>5</columns>
<column_widths>115,110,150,100,50</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -2734,7 +2746,8 @@
<widget>
<class>GtkButton</class>
<name>button59</name>
<name>event_edit_btn</name>
<sensitive>False</sensitive>
<tooltip>Update the selected event with the above data</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -2750,7 +2763,8 @@
<widget>
<class>GtkButton</class>
<name>button60</name>
<name>event_delete_btn</name>
<sensitive>False</sensitive>
<tooltip>Delete the selected event</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -3074,14 +3088,19 @@
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_attr_list_select_row</handler>
<last_modification_time>Tue, 01 May 2001 17:24:40 GMT</last_modification_time>
<handler>on_attr_select_row</handler>
<last_modification_time>Sun, 07 Apr 2002 05:07:05 GMT</last_modification_time>
</signal>
<signal>
<name>button_press_event</name>
<handler>on_attr_button_press</handler>
<last_modification_time>Sun, 04 Nov 2001 15:42:49 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_attr_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 05:07:26 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>200,250,50</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -3162,7 +3181,8 @@
<widget>
<class>GtkButton</class>
<name>button89</name>
<name>attr_edit_btn</name>
<sensitive>False</sensitive>
<tooltip>Update the selected attribute with the above data</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -3178,7 +3198,8 @@
<widget>
<class>GtkButton</class>
<name>button90</name>
<name>attr_delete_btn</name>
<sensitive>False</sensitive>
<tooltip>Delete the selected attribute</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -3892,14 +3913,19 @@
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_address_list_select_row</handler>
<last_modification_time>Wed, 23 May 2001 18:42:16 GMT</last_modification_time>
<handler>on_addr_select_row</handler>
<last_modification_time>Sun, 07 Apr 2002 05:27:50 GMT</last_modification_time>
</signal>
<signal>
<name>button_press_event</name>
<handler>on_addr_button_press</handler>
<last_modification_time>Sun, 04 Nov 2001 15:53:05 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_addr_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 05:27:58 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>150,350,50</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -3980,7 +4006,8 @@
<widget>
<class>GtkButton</class>
<name>button93</name>
<name>addr_edit_btn</name>
<sensitive>False</sensitive>
<tooltip>Update the selected address with the above data</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -3996,7 +4023,8 @@
<widget>
<class>GtkButton</class>
<name>button94</name>
<name>addr_delete_btn</name>
<sensitive>False</sensitive>
<tooltip>Delete the selected address</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -4500,14 +4528,19 @@
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_web_list_select_row</handler>
<last_modification_time>Tue, 24 Apr 2001 14:12:50 GMT</last_modification_time>
<handler>on_web_select_row</handler>
<last_modification_time>Sun, 07 Apr 2002 18:44:25 GMT</last_modification_time>
</signal>
<signal>
<name>button_press_event</name>
<handler>on_web_button_press</handler>
<last_modification_time>Sun, 04 Nov 2001 15:44:20 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_web_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 18:44:42 GMT</last_modification_time>
</signal>
<columns>2</columns>
<column_widths>273,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -4576,6 +4609,7 @@
<widget>
<class>GtkButton</class>
<name>update_url</name>
<sensitive>False</sensitive>
<tooltip>Modify selected reference</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
@ -4592,6 +4626,7 @@
<widget>
<class>GtkButton</class>
<name>delete_url</name>
<sensitive>False</sensitive>
<tooltip>Delete selected reference</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>

View File

@ -92,6 +92,22 @@ class EditPerson:
self.top = libglade.GladeXML(const.editPersonFile, "editPerson")
gwidget = self.top.get_widget("photolist")
self.gallery = ImageSelect.Gallery(person, self.path, gwidget, self.db)
self.name_update_btn = self.top.get_widget('aka_update')
self.name_delete_btn = self.top.get_widget('aka_delete')
self.web_update_btn = self.top.get_widget('update_url')
self.web_delete_btn = self.top.get_widget('delete_url')
self.event_edit_btn = self.top.get_widget('event_edit_btn')
self.event_delete_btn = self.top.get_widget('event_delete_btn')
self.attr_edit_btn = self.top.get_widget('attr_edit_btn')
self.attr_delete_btn = self.top.get_widget('attr_delete_btn')
self.addr_edit_btn = self.top.get_widget('addr_edit_btn')
self.addr_delete_btn = self.top.get_widget('addr_delete_btn')
self.top.signal_autoconnect({
"destroy_passed_object" : self.on_cancel_edit,
"on_up_clicked" : self.on_up_clicked,
@ -103,12 +119,14 @@ class EditPerson:
"on_addr_button_press" : self.addr_double_click,
"on_web_button_press" : self.url_double_click,
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
"on_address_list_select_row": self.on_addr_list_select_row,
"on_addr_select_row" : self.on_addr_select_row,
"on_addr_unselect_row" : self.on_addr_unselect_row,
"on_aka_delete_clicked" : self.on_aka_delete_clicked,
"on_aka_update_clicked" : self.on_aka_update_clicked,
"on_apply_person_clicked" : self.on_apply_person_clicked,
"on_attr_button_press" : self.attr_double_click,
"on_attr_list_select_row" : self.on_attr_list_select_row,
"on_attr_select_row" : self.on_attr_select_row,
"on_attr_unselect_row" : self.on_attr_unselect_row,
"on_edit_birth_clicked" : self.on_edit_birth_clicked,
"on_edit_death_clicked" : self.on_edit_death_clicked,
"on_delete_address_clicked" : self.on_delete_addr_clicked,
@ -122,9 +140,11 @@ class EditPerson:
"on_event_button_press" : self.event_double_click,
"on_event_delete_clicked" : self.on_event_delete_clicked,
"on_event_select_row" : self.on_event_select_row,
"on_event_unselect_row" : self.on_event_unselect_row,
"on_event_update_clicked" : self.on_event_update_clicked,
"on_name_button_press" : self.aka_double_click,
"on_name_list_select_row" : self.on_name_list_select_row,
"on_name_select_row" : self.on_name_select_row,
"on_name_unselect_row" : self.on_name_unselect_row,
"on_name_note_clicked" : self.on_name_note_clicked,
"on_ldsbap_note_clicked" : self.on_ldsbap_note_clicked,
"on_ldsendow_note_clicked" : self.on_ldsendow_note_clicked,
@ -139,7 +159,8 @@ class EditPerson:
"on_update_attr_clicked" : self.on_update_attr_clicked,
"on_update_url_clicked" : self.on_update_url_clicked,
"on_web_go_clicked" : self.on_web_go_clicked,
"on_web_list_select_row" : self.on_web_list_select_row,
"on_web_select_row" : self.on_web_select_row,
"on_web_unselect_row" : self.on_web_unselect_row,
})
self.window = self.get_widget("editPerson")
@ -225,7 +246,8 @@ class EditPerson:
self.window.editable_enters(self.dplace);
self.autoplace = AutoComp.AutoCombo(self.bpcombo,self.pmap.keys())
self.autodeath = AutoComp.AutoCombo(self.dpcombo,self.pmap.keys(),self.autoplace)
self.autodeath = AutoComp.AutoCombo(self.dpcombo,self.pmap.keys(),
self.autoplace)
self.comp = AutoComp.AutoCombo(self.sncombo,const.surnames)
self.gid.set_text(person.getId())
@ -283,25 +305,33 @@ class EditPerson:
self.notes_field.insert_defaults(person.getNote())
self.notes_field.set_word_wrap(1)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
pycode_tgts,ACTION_COPY)
self.event_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.event_list.connect('drag_data_get', self.ev_drag_data_get)
self.event_list.connect('drag_data_received', self.ev_drag_data_received)
self.event_list.connect('drag_data_received',
self.ev_drag_data_received)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.web_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
pycode_tgts,ACTION_COPY)
self.web_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.web_list.connect('drag_data_get', self.url_drag_data_get)
self.web_list.connect('drag_data_received', self.url_drag_data_received)
self.web_list.connect('drag_data_received',
self.url_drag_data_received)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,
ACTION_COPY)
self.attr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.attr_list.connect('drag_data_get', self.at_drag_data_get)
self.attr_list.connect('drag_data_received', self.at_drag_data_received)
self.attr_list.connect('drag_data_received',
self.at_drag_data_received)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,pycode_tgts,ACTION_COPY)
self.addr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
pycode_tgts,ACTION_COPY)
self.addr_list.drag_source_set(BUTTON1_MASK, pycode_tgts, ACTION_COPY)
self.addr_list.connect('drag_data_get', self.ad_drag_data_get)
self.addr_list.connect('drag_data_received', self.ad_drag_data_received)
self.addr_list.connect('drag_data_received',
self.ad_drag_data_received)
self.redraw_event_list()
self.redraw_attr_list()
@ -951,6 +981,8 @@ class EditPerson:
self.callback)
def on_event_select_row(self,obj,row,b,c):
self.event_edit_btn.set_sensitive(1)
self.event_delete_btn.set_sensitive(1)
event = obj.get_row_data(row)
self.event_date_field.set_text(event.getDate())
self.event_place_field.set_text(event.getPlaceName())
@ -959,9 +991,20 @@ class EditPerson:
self.event_descr_field.set_text(event.getDescription())
self.event_details_field.set_text(Utils.get_detail_text(event))
def on_addr_list_select_row(self,obj,row,b,c):
def on_event_unselect_row(self,obj,a,b,c):
enable = len(obj.selection) > 0
self.event_edit_btn.set_sensitive(enable)
self.event_delete_btn.set_sensitive(enable)
def on_addr_unselect_row(self,obj,row,b,c):
enable = len(obj.selection) > 0
self.addr_edit_btn.set_sensitive(enable)
self.addr_delete_btn.set_sensitive(enable)
def on_addr_select_row(self,obj,row,b,c):
a = obj.get_row_data(row)
self.addr_edit_btn.set_sensitive(1)
self.addr_delete_btn.set_sensitive(1)
label = "%s %s %s" % (a.getCity(),a.getState(),a.getCountry())
self.addr_label.set_label(label)
@ -973,8 +1016,9 @@ class EditPerson:
self.addr_postal.set_text(a.getPostal())
self.addr_details_field.set_text(Utils.get_detail_text(a))
def on_name_list_select_row(self,obj,row,b,c):
def on_name_select_row(self,obj,row,b,c):
self.name_update_btn.set_sensitive(1)
self.name_delete_btn.set_sensitive(1)
name = obj.get_row_data(row)
self.name_frame.set_label(name.getName())
self.alt_given_field.set_text(name.getFirstName())
@ -984,8 +1028,14 @@ class EditPerson:
self.name_type_field.set_text(name.getType())
self.name_details_field.set_text(Utils.get_detail_text(name))
def on_web_list_select_row(self,obj,row,b,c):
def on_name_unselect_row(self,obj,a,b,c):
enable = len(obj.selection) > 0
self.name_update_btn.set_sensitive(enable)
self.name_delete_btn.set_sensitive(enable)
def on_web_select_row(self,obj,row,b,c):
self.web_update_btn.set_sensitive(1)
self.web_delete_btn.set_sensitive(1)
url = obj.get_row_data(row)
if url == None:
self.web_url.set_text("")
@ -997,13 +1047,24 @@ class EditPerson:
self.web_go.set_sensitive(1)
self.web_description.set_text(url.get_description())
def on_attr_list_select_row(self,obj,row,b,c):
def on_web_unselect_row(self,obj,row,b,c):
enable = len(obj.selection) > 0
self.web_update_btn.set_sensitive(enable)
self.web_delete_btn.set_sensitive(enable)
def on_attr_select_row(self,obj,row,b,c):
self.attr_edit_btn.set_sensitive(1)
self.attr_delete_btn.set_sensitive(1)
attr = obj.get_row_data(row)
self.attr_type.set_label(const.display_pattr(attr.getType()))
self.attr_value.set_text(attr.getValue())
self.attr_details_field.set_text(Utils.get_detail_text(attr))
def on_attr_unselect_row(self,obj,row,b,c):
enable = len(obj.selection) > 0
self.attr_edit_btn.set_sensitive(enable)
self.attr_delete_btn.set_sensitive(enable)
def aka_double_click(self,obj,event):
if event.button == 1 and event.type == _2BUTTON_PRESS:
self.on_aka_update_clicked(obj)

View File

@ -505,11 +505,19 @@ class GenericFilter:
self.flist = source.flist[:]
self.name = source.name
self.comment = source.comment
self.logical_or = source.logical_or
else:
self.flist = []
self.name = 'NoName'
self.name = ''
self.comment = ''
self.logical_or = 0
def set_logical_or(self,val):
self.logical_or = val
def get_logical_or(self):
return self.logical_or
def get_name(self):
return self.name
@ -533,12 +541,19 @@ class GenericFilter:
def apply(self,list):
result = []
for p in list:
for rule in self.flist:
if rule.apply(p) == 0:
break
else:
result.append(p)
if self.logical_or:
for p in list:
for rule in self.flist:
if rule.apply(p):
result.append(p)
break
else:
for p in list:
for rule in self.flist:
if rule.apply(p) == 0:
break
else:
result.append(p)
return result
#-------------------------------------------------------------------------
@ -607,6 +622,8 @@ class GenericFilterList:
f.write('<filters>\n')
for i in self.filter_list:
f.write(' <filter name="%s"' % self.fix(i.get_name()))
if i.get_logical_or():
f.write(' function="1"')
comment = i.get_comment()
if comment:
f.write(' comment="%s"' % self.fix(comment))
@ -643,6 +660,8 @@ class FilterParser(handler.ContentHandler):
if tag == "filter":
self.f = GenericFilter()
self.f.set_name(attrs['name'])
if attrs.has_key('function'):
self.f.set_logical_or(int(attrs['function']))
if attrs.has_key('comment'):
self.f.set_comment(attrs['comment'])
self.gfilter_list.add(self.f)

View File

@ -821,21 +821,13 @@ class GrampsPreferences:
next_panel=13
for c in self.c.keys():
item = gtk.GtkTreeItem(c)
item.show()
item.expand()
item.connect('select',self.select,0)
self.tree.append(item)
subtree = gtk.GtkTree()
subtree.show()
item.set_subtree(subtree)
node = self.tree.insert_node(None,None,[c],is_leaf=0,expanded=1)
self.tree.node_set_row_data(node,0)
next = None
for panel in self.c[c].keys():
newitem = gtk.GtkTreeItem(panel)
newitem.show()
newitem.expand()
newitem.connect('select',self.select,next_panel)
next = self.tree.insert_node(node,next,[panel],is_leaf=1,expanded=1)
self.tree.node_set_row_data(next,next_panel)
next_panel = next_panel + 1
subtree.append(newitem)
box = gtk.GtkVBox()
box.show()
col = 0
@ -853,10 +845,13 @@ class GrampsPreferences:
for wobj in pairs:
w = wobj.get_widgets()
if len(w) == 2:
table.attach(w[0],0,1,col,col+1,GTK.FILL,GTK.SHRINK,5,5)
table.attach(w[1],1,2,col,col+1,GTK.FILL|GTK.EXPAND,GTK.SHRINK,5,5)
table.attach(w[0],0,1,col,col+1,
GTK.FILL,GTK.SHRINK,5,5)
table.attach(w[1],1,2,col,col+1,
GTK.FILL|GTK.EXPAND,GTK.SHRINK,5,5)
else:
table.attach(w[0],0,2,col,col+1,GTK.FILL|GTK.EXPAND,GTK.SHRINK,5,5)
table.attach(w[0],0,2,col,col+1,
GTK.FILL|GTK.EXPAND,GTK.SHRINK,5,5)
col = col + 1
def select(self,obj,node,other):

View File

@ -107,10 +107,11 @@ class PluginDialog:
self.dialog.signal_autoconnect({
"on_report_apply_clicked" : self.on_apply_clicked,
"on_report_ok_clicked" : self.on_apply_clicked,
"on_tree_select_row" : self.on_node_selected,
"destroy_passed_object" : Utils.destroy_passed_object
})
tree = self.dialog.get_widget("tree")
self.tree = self.dialog.get_widget("tree")
self.top = self.dialog.get_widget("report")
self.img = self.dialog.get_widget("image")
self.description = self.dialog.get_widget("description")
@ -119,7 +120,7 @@ class PluginDialog:
self.title = self.dialog.get_widget("title")
self.run_tool = None
self.build_tree(tree,list)
self.build_tree(list)
self.title.set_text(msg)
self.top.set_title("%s - GRAMPS" % msg)
@ -133,11 +134,16 @@ class PluginDialog:
else:
self.run_tool(self.db,self.active)
def on_node_selected(self,obj):
def on_node_selected(self,obj,node,other):
"""Updates the informational display on the right hand side of
the dialog box with the description of the selected report"""
(task,cat,title,doc,xpm,status) = obj.get_data(TASK)
data = self.tree.node_get_row_data(node)
task = data[1]
title = data[0]
doc = data[2]
xpm = data[3]
status = data[4]
image = GdkImlib.create_image_from_xpm(xpm)
self.description.set_text(doc)
@ -149,12 +155,12 @@ class PluginDialog:
self.dialog.get_widget("title").set_text(title)
self.run_tool = task
def build_tree(self,tree,list):
def build_tree(self,list):
"""Populates a GtkTree with each menu item assocated with a entry
in the lists. The list must consist of a tuples with the following
format:
(task_to_call, category of report, report name, description, image, status)
(task_to_call, category, report name, description, image, status)
Items in the same category are grouped under the same submen. The
task_to_call is bound to the 'select' callback of the menu entry."""
@ -162,30 +168,27 @@ class PluginDialog:
# build the tree items and group together based on the category name
item_hash = {}
for report in list:
item = gtk.GtkTreeItem(report[2])
item.connect("select",self.on_node_selected)
item.set_data(TASK,report)
t = (report[2],report[0],report[3],report[4],report[5])
if item_hash.has_key(report[1]):
item_hash[report[1]].append(item)
item_hash[report[1]].append(t)
else:
item_hash[report[1]] = [item]
item_hash[report[1]] = [t]
# add a submenu for each category, and populate it with the GtkTreeItems
# that are associated with it.
# add a submenu for each category, and populate it with the
# GtkTreeItems that are associated with it.
key_list = item_hash.keys()
key_list.sort()
prev = None
for key in key_list:
top_item = gtk.GtkTreeItem(key)
top_item.show()
tree.append(top_item)
subtree = gtk.GtkTree()
subtree.show()
top_item.set_subtree(subtree)
subtree.show()
for item in item_hash[key]:
item.show()
subtree.append(item)
data = item_hash[key]
node = self.tree.insert_node(None,prev,[key],is_leaf=0,expanded=1)
self.tree.node_set_row_data(node,0)
next = None
data.sort()
data.reverse()
for item in data:
next = self.tree.insert_node(node,next,[item[0]],is_leaf=1,expanded=1)
self.tree.node_set_row_data(next,item)
#-------------------------------------------------------------------------
#

View File

@ -1,15 +1,8 @@
#! /usr/bin/python -O
import traceback
import intl
import os
import GdkImlib
import gtk
import gnome.ui
import gnome.config
import intl
import locale
import gramps_main
import sys
if os.environ.has_key("GRAMPSI18N"):
loc = os.environ["GRAMPSI18N"]
@ -21,6 +14,14 @@ intl.bindtextdomain("gramps",loc)
locale.setlocale(locale.LC_NUMERIC,"C")
import traceback
import GdkImlib
import gtk
import gnome.ui
import gnome.config
import gramps_main
import sys
if len(sys.argv) > 1:
arg = sys.argv[1]
else:

View File

@ -36,6 +36,8 @@ try:
elif ver == "2.2":
from intl22 import *
else:
print 'Internationalization library could be loaded'
def gettext(s):
return s

View File

@ -110,23 +110,54 @@
</child>
<widget>
<class>GtkTree</class>
<name>tree</name>
<border_width>5</border_width>
<width>250</width>
<height>300</height>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<view_mode>GTK_TREE_VIEW_ITEM</view_mode>
<view_line>True</view_line>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
<width>200</width>
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
<shrink>False</shrink>
<resize>True</resize>
<resize>False</resize>
</child>
<widget>
<class>GtkCTree</class>
<name>tree</name>
<width>250</width>
<height>300</height>
<can_focus>True</can_focus>
<signal>
<name>tree_select_row</name>
<handler>on_tree_select_row</handler>
<last_modification_time>Mon, 08 Apr 2002 00:44:55 GMT</last_modification_time>
</signal>
<columns>1</columns>
<column_widths>80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>False</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
<widget>
<class>GtkLabel</class>
<child_name>CTree:title</child_name>
<name>label63</name>
<label>label63</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox36</name>
<width>300</width>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>

View File

@ -52,30 +52,49 @@ class FilterEditor:
self.editor = libglade.GladeXML(const.filterFile,'filter_list')
self.editor_top = self.editor.get_widget('filter_list')
self.filter_list = self.editor.get_widget('filters')
self.draw_filters()
self.edit = self.editor.get_widget('edit')
self.delete = self.editor.get_widget('delete')
self.test = self.editor.get_widget('test')
self.editor.signal_autoconnect({
'on_add_clicked' : self.add_new_filter,
'on_edit_clicked' : self.edit_filter,
'on_filters_select_row' : self.filter_select_row,
'on_filters_unselect_row' : self.filter_unselect_row,
'on_test_clicked' : self.test_clicked,
'on_close_clicked' : self.close_filter_editor,
'on_delete_clicked' : self.delete_filter,
})
self.draw_filters()
def filter_select_row(self,obj,a,b,c):
self.edit.set_sensitive(1)
self.delete.set_sensitive(1)
self.test.set_sensitive(1)
def filter_unselect_row(self,obj,a,b,c):
enable = (len(obj.selection) > 0)
self.edit.set_sensitive(enable)
self.delete.set_sensitive(enable)
self.test.set_sensitive(enable)
def close_filter_editor(self,obj):
self.filterdb.save()
self.editor_top.destroy()
def draw_filters(self):
row = 0
self.filter_list.freeze()
self.filter_list.clear()
for f in self.filterdb.get_filters():
self.filter_list.append([f.get_name(),f.get_comment()])
self.filter_list.set_row_data(row,f)
row = row + 1
self.filter_list.sort()
self.filter_list.thaw()
def add_new_filter(self,obj):
filter = GenericFilter.GenericFilter()
filter.set_name('NoName')
self.filter_editor(filter)
def edit_filter(self,obj):
@ -107,19 +126,41 @@ class FilterEditor:
self.top = self.glade.get_widget('define_filter')
self.rule_list = self.glade.get_widget('rule_list')
self.fname = self.glade.get_widget('filter_name')
self.logor = self.glade.get_widget('logical_or')
self.comment = self.glade.get_widget('comment')
self.ok = self.glade.get_widget('ok')
self.edit_btn = self.glade.get_widget('edit')
self.del_btn = self.glade.get_widget('delete')
self.glade.signal_autoconnect({
'on_ok_clicked' : self.on_ok_clicked,
'on_cancel_clicked' : self.on_cancel_clicked,
'on_rule_select_row' : self.select_row,
'on_rule_unselect_row' : self.unselect_row,
'on_filter_name_changed' : self.filter_name_changed,
'on_delete_clicked' : self.on_delete_clicked,
'on_add_clicked' : self.on_add_clicked,
'on_edit_clicked' : self.on_edit_clicked,
'on_cancel_clicked' : self.on_cancel_clicked,
})
self.fname.set_text(self.filter.get_name())
self.logor.set_active(self.filter.get_logical_or())
if self.filter.get_name():
self.fname.set_text(self.filter.get_name())
self.comment.set_text(self.filter.get_comment())
self.draw_rules()
def filter_name_changed(self,obj):
name = self.fname.get_text()
self.ok.set_sensitive(len(name) != 0)
def select_row(self,obj,a,b,c):
self.edit_btn.set_sensitive(1)
self.del_btn.set_sensitive(1)
def unselect_row(self,obj,a,b,c):
enable = (len(obj.selection) == 1)
self.edit_btn.set_sensitive(enable)
self.del_btn.set_sensitive(enable)
def draw_rules(self):
self.rule_list.clear()
row = 0
@ -141,6 +182,7 @@ class FilterEditor:
if n == f.get_name():
self.filterdb.get_filters().remove(f)
break
self.filter.set_logical_or(self.logor.get_active())
self.filterdb.add(self.filter)
self.draw_filters()
self.top.destroy()
@ -172,7 +214,9 @@ class FilterEditor:
self.name2page = {}
map = {}
list = []
for name in GenericFilter.tasks.keys():
keylist = GenericFilter.tasks.keys()
keylist.sort()
for name in keylist:
cname = GenericFilter.tasks[name]
arglist = cname.labels
vallist = []
@ -191,12 +235,14 @@ class FilterEditor:
list.append(c)
map[name] = c
for v in arglist:
l = gtk.GtkLabel(_(v))
v1 = _(v)
l = gtk.GtkLabel(v1)
l.set_alignment(1,0.5)
l.show()
if _name2list.has_key(_(v)):
if _name2list.has_key(v1):
t = gtk.GtkCombo()
t.set_popdown_strings(_name2list[_(v)])
_name2list[v1].sort()
t.set_popdown_strings(_name2list[v1])
t.set_value_in_list(1,0)
t.entry.set_editable(0)
tlist.append(t.entry)

View File

@ -57,6 +57,7 @@
<widget>
<class>GtkButton</class>
<name>ok</name>
<sensitive>False</sensitive>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -122,7 +123,7 @@
<widget>
<class>GtkTable</class>
<name>table1</name>
<rows>2</rows>
<rows>4</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
@ -189,6 +190,11 @@
<class>GtkEntry</class>
<name>filter_name</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_filter_name_changed</handler>
<last_modification_time>Sun, 07 Apr 2002 19:28:31 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@ -232,6 +238,54 @@
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>logical_and</name>
<can_focus>True</can_focus>
<label>All rules must apply</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<group>logic</group>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>logical_or</name>
<can_focus>True</can_focus>
<label>At least one rule must apply</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>logic</group>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
<widget>
@ -253,6 +307,16 @@
<width>450</width>
<height>200</height>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_rule_select_row</handler>
<last_modification_time>Sun, 07 Apr 2002 19:29:31 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_rule_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 19:30:23 GMT</last_modification_time>
</signal>
<columns>2</columns>
<column_widths>147,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -319,6 +383,7 @@
<widget>
<class>GtkButton</class>
<name>edit</name>
<sensitive>False</sensitive>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -333,6 +398,7 @@
<widget>
<class>GtkButton</class>
<name>delete</name>
<sensitive>False</sensitive>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -636,6 +702,16 @@
<width>450</width>
<height>150</height>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
<handler>on_filters_select_row</handler>
<last_modification_time>Sun, 07 Apr 2002 22:15:34 GMT</last_modification_time>
</signal>
<signal>
<name>unselect_row</name>
<handler>on_filters_unselect_row</handler>
<last_modification_time>Sun, 07 Apr 2002 22:15:44 GMT</last_modification_time>
</signal>
<columns>2</columns>
<column_widths>117,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
@ -688,6 +764,7 @@
<widget>
<class>GtkButton</class>
<name>button3</name>
<tooltip>Add a new filter</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -701,7 +778,9 @@
<widget>
<class>GtkButton</class>
<name>button4</name>
<name>edit</name>
<sensitive>False</sensitive>
<tooltip>Edit the selected filter</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -715,7 +794,9 @@
<widget>
<class>GtkButton</class>
<name>button5</name>
<name>delete</name>
<sensitive>False</sensitive>
<tooltip>Delete the selected filter</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
@ -729,7 +810,9 @@
<widget>
<class>GtkButton</class>
<name>button7</name>
<name>test</name>
<sensitive>False</sensitive>
<tooltip>Display people matching the filter</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>