Dynamic qualifier menu for filters
svn: r779
This commit is contained in:
parent
c21a8151de
commit
0173cf0fd8
@ -70,17 +70,19 @@ class Filter:
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
_filter_list = [(Filter, _("All people"), 0)]
|
||||
_filter_list = [(Filter, _("All people"), 0, _("Qualifier"))]
|
||||
_filter2class = {}
|
||||
_filter2descr = {}
|
||||
|
||||
def register_filter(class_name, description=None, qualifier=0):
|
||||
def register_filter(class_name, description=None, qualifier=0, label=None):
|
||||
name = str(class_name)
|
||||
if label == None:
|
||||
label = _("Qualifier")
|
||||
if description == None:
|
||||
description = _("No description")
|
||||
_filter2class[name] = class_name
|
||||
_filter2descr[name] = description
|
||||
_filter_list.append((class_name,description,qualifier))
|
||||
_filter_list.append((class_name,description,qualifier,label))
|
||||
|
||||
def get_filter_description(name):
|
||||
if _filter2descr.has_key(name):
|
||||
@ -132,6 +134,7 @@ def build_filter_menu(callback,fw):
|
||||
menuitem.set_data("name",filter[1])
|
||||
menuitem.set_data("function",filter[0])
|
||||
menuitem.set_data("qual",filter[2])
|
||||
menuitem.set_data("label",filter[3])
|
||||
menuitem.connect("activate",callback)
|
||||
menuitem.show()
|
||||
return myMenu
|
||||
|
@ -54,5 +54,6 @@ class EventAfter(Filter.Filter):
|
||||
#--------------------------------------------------------------------
|
||||
Filter.register_filter(EventAfter,
|
||||
description=_("People with an event after ..."),
|
||||
label=_("Date"),
|
||||
qualifier=1)
|
||||
|
||||
|
@ -54,5 +54,6 @@ class EventBefore(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(EventBefore,
|
||||
description=_("People with an event before ..."),
|
||||
label=_("Date"),
|
||||
qualifier=1)
|
||||
|
||||
|
@ -69,4 +69,5 @@ class EventPlace(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(EventPlace,
|
||||
description=_("People with an event location of ..."),
|
||||
label=_("Place"),
|
||||
qualifier=1)
|
||||
|
@ -39,4 +39,5 @@ class EventType(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(EventType,
|
||||
description=_("People who have an event type of ..."),
|
||||
label=_("Event"),
|
||||
qualifier=1)
|
||||
|
@ -43,4 +43,5 @@ class MatchSndEx(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(MatchSndEx,
|
||||
description=_("Names with same SoundEx code as ..."),
|
||||
label=_("Surname"),
|
||||
qualifier=1)
|
||||
|
@ -39,4 +39,5 @@ class MatchSndEx2(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(MatchSndEx2,
|
||||
description=_("Names with the specified SoundEx code"),
|
||||
label=_("SoundEx Code"),
|
||||
qualifier=1)
|
||||
|
@ -50,6 +50,7 @@ class RegExMatch(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(RegExMatch,
|
||||
description=_("Names that match a regular expression"),
|
||||
label=_("Text"),
|
||||
qualifier=1)
|
||||
|
||||
|
||||
|
@ -39,5 +39,6 @@ class SubString(Filter.Filter):
|
||||
#------------------------------------------------------------------------
|
||||
Filter.register_filter(SubString,
|
||||
description=_("Names that contain a substring"),
|
||||
label=_("Text"),
|
||||
qualifier=1)
|
||||
|
||||
|
@ -792,13 +792,14 @@
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>5</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label185</name>
|
||||
<name>qual</name>
|
||||
<visible>False</visible>
|
||||
<label>Qualifier</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
@ -816,56 +817,69 @@
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
<name>filter</name>
|
||||
<visible>False</visible>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>activate</name>
|
||||
<handler>on_apply_filter_clicked</handler>
|
||||
<last_modification_time>Thu, 06 Sep 2001 23:02:43 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<editable>False</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox74</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>3</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>invert</name>
|
||||
<tooltip>Show persons that do not match the filtering rule</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Invert</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>invert</name>
|
||||
<tooltip>Show persons that do not match the filtering rule</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Invert</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>5</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>apply_filter</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_apply_filter_clicked</handler>
|
||||
<object>filter</object>
|
||||
<last_modification_time>Sat, 21 Oct 2000 03:36:06 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>apply_filter</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_apply_filter_clicked</handler>
|
||||
<object>filter</object>
|
||||
<last_modification_time>Sat, 21 Oct 2000 03:36:06 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
|
@ -1323,7 +1323,17 @@ def on_apply_filter_clicked(obj):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_filter_name_changed(obj):
|
||||
qlabel = gtop.get_widget("qual")
|
||||
filter = obj.get_data("filter")
|
||||
if obj.get_data("qual"):
|
||||
qlabel.show()
|
||||
qlabel.set_sensitive(1)
|
||||
qlabel.set_text(obj.get_data("label"))
|
||||
filter.show()
|
||||
else:
|
||||
qlabel.hide()
|
||||
filter.hide()
|
||||
|
||||
filter.set_sensitive(obj.get_data("qual"))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user