Filter editor fixes

svn: r1396
This commit is contained in:
Don Allingham 2003-03-25 05:26:05 +00:00
parent cd666c90f7
commit 62e29dcaf0
3 changed files with 258 additions and 168 deletions

View File

@ -580,6 +580,11 @@ class HasNameOf(Rule):
return 0 return 0
#-------------------------------------------------------------------------
#
# MatchesFilter
#
#-------------------------------------------------------------------------
class MatchesFilter(Rule): class MatchesFilter(Rule):
"""Rule that checks against another filter""" """Rule that checks against another filter"""
@ -594,7 +599,7 @@ class MatchesFilter(Rule):
return filter.check(p) return filter.check(p)
for filter in CustomFilters.get_filters(): for filter in CustomFilters.get_filters():
if filter.get_name() == self.list[0]: if filter.get_name() == self.list[0]:
return filter.check(p) return filter.check(db,p)
return 0 return 0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -35,11 +35,11 @@ import Utils
from intl import gettext as _ from intl import gettext as _
_name2list = { _name2list = {
_('Personal Event') : const.personalEvents, _('Personal event:') : const.personalEvents,
_('Family Event') : const.marriageEvents, _('Family event:') : const.marriageEvents,
_('Personal Attribute') : const.personalAttributes, _('Personal attribute:') : const.personalAttributes,
_('Family Attribute') : const.familyAttributes, _('Family attribute:') : const.familyAttributes,
_('Relationship Type') : const.familyRelations, _('Relationship type:') : const.familyRelations,
} }
class FilterEditor: class FilterEditor:
@ -47,7 +47,7 @@ class FilterEditor:
self.db = db self.db = db
self.filterdb = GenericFilter.GenericFilterList(filterdb) self.filterdb = GenericFilter.GenericFilterList(filterdb)
self.filterdb.load() self.filterdb.load()
self.editor = gtk.glade.XML(const.filterFile,'filter_list') self.editor = gtk.glade.XML(const.filterFile,'filter_list')
self.editor_top = self.editor.get_widget('filter_list') self.editor_top = self.editor.get_widget('filter_list')
self.filter_list = self.editor.get_widget('filters') self.filter_list = self.editor.get_widget('filters')
@ -265,9 +265,18 @@ class FilterEditor:
l = gtk.Label(v1) l = gtk.Label(v1)
l.set_alignment(1,0.5) l.set_alignment(1,0.5)
l.show() l.show()
if v == 'Place': if v == 'Place:':
t = gtk.Combo() t = gtk.Combo()
AutoComp.AutoCombo(t,self.pmap.keys()) AutoComp.AutoCombo(t,self.pmap.keys())
tlist.append(t.entry)
elif v == 'Filter name:':
t = gtk.Combo()
flist = []
for f in self.filterdb.get_filters():
flist.append(f.get_name())
flist.sort()
AutoComp.AutoCombo(t,flist)
tlist.append(t.entry)
elif _name2list.has_key(v1): elif _name2list.has_key(v1):
t = gtk.Combo() t = gtk.Combo()
_name2list[v1].sort() _name2list[v1].sort()

View File

@ -93,12 +93,171 @@
<widget class="GtkTable" id="table1"> <widget class="GtkTable" id="table1">
<property name="border_width">12</property> <property name="border_width">12</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">6</property> <property name="n_rows">12</property>
<property name="n_columns">2</property> <property name="n_columns">3</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<property name="column_spacing">12</property> <property name="column_spacing">12</property>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Definition&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Rule List&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="rule_list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="add">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Add...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_add_clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="edit">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Edit...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_edit_clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="delete">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_delete_clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">11</property>
<property name="bottom_attach">12</property>
<property name="x_options">fill</property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="label2"> <widget class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
@ -115,12 +274,10 @@
<property name="mnemonic_widget">filter_name</property> <property name="mnemonic_widget">filter_name</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">1</property>
<property name="right_attach">1</property> <property name="right_attach">2</property>
<property name="top_attach">0</property> <property name="top_attach">1</property>
<property name="bottom_attach">1</property> <property name="bottom_attach">2</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -142,12 +299,10 @@
<property name="mnemonic_widget">comment</property> <property name="mnemonic_widget">comment</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">1</property>
<property name="right_attach">1</property> <property name="right_attach">2</property>
<property name="top_attach">1</property> <property name="top_attach">2</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">3</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -167,12 +322,10 @@
<signal name="changed" handler="on_filter_name_changed"/> <signal name="changed" handler="on_filter_name_changed"/>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">2</property>
<property name="right_attach">2</property> <property name="right_attach">3</property>
<property name="top_attach">0</property> <property name="top_attach">1</property>
<property name="bottom_attach">1</property> <property name="bottom_attach">2</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -190,32 +343,30 @@
<property name="activates_default">False</property> <property name="activates_default">False</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">2</property>
<property name="right_attach">2</property> <property name="right_attach">3</property>
<property name="top_attach">1</property> <property name="top_attach">2</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">3</property>
<property name="x_padding">5</property>
<property name="y_padding">5</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkRadioButton" id="logical_one"> <widget class="GtkRadioButton" id="logical_and">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">E_xactly one rule must apply</property> <property name="label" translatable="yes">All _rules must apply</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property> <property name="active">True</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">2</property>
<property name="right_attach">2</property> <property name="right_attach">3</property>
<property name="top_attach">5</property> <property name="top_attach">3</property>
<property name="bottom_attach">6</property> <property name="bottom_attach">4</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
@ -231,11 +382,11 @@
<property name="active">False</property> <property name="active">False</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">logical_one</property> <property name="group">logical_and</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">2</property>
<property name="right_attach">2</property> <property name="right_attach">3</property>
<property name="top_attach">4</property> <property name="top_attach">4</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">5</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
@ -244,16 +395,40 @@
</child> </child>
<child> <child>
<widget class="GtkRadioButton" id="logical_and"> <widget class="GtkRadioButton" id="logical_one">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">All _rules must apply</property> <property name="label" translatable="yes">E_xactly one rule must apply</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">True</property> <property name="active">False</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">logical_one</property> <property name="group">logical_and</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">Rule operations:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -269,7 +444,7 @@
<widget class="GtkCheckButton" id="logical_not"> <widget class="GtkCheckButton" id="logical_not">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">_Invert</property> <property name="label" translatable="yes">_Return values that do not match the filter rules (invert)</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property> <property name="active">False</property>
@ -278,136 +453,37 @@
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">3</property>
<property name="top_attach">2</property> <property name="top_attach">8</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">9</property>
<property name="x_options">fill</property> <property name="x_options">fill</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox6">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow1"> <widget class="GtkLabel" id="label17">
<property name="visible">True</property> <property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="label" translatable="yes">&lt;b&gt;Rule Modifiers&lt;/b&gt;</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="use_underline">False</property>
<property name="shadow_type">GTK_SHADOW_IN</property> <property name="use_markup">True</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<child> <property name="selectable">False</property>
<widget class="GtkTreeView" id="rule_list"> <property name="xalign">0</property>
<property name="visible">True</property> <property name="yalign">0.5</property>
<property name="can_focus">True</property> <property name="xpad">0</property>
<property name="headers_visible">True</property> <property name="ypad">0</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="left_attach">0</property>
<property name="expand">True</property> <property name="right_attach">3</property>
<property name="fill">True</property> <property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkVBox" id="vbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="add">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Add...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_add_clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="edit">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Edit...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_edit_clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="delete">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_delete_clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">30</property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>