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 = {}
|
_filter2class = {}
|
||||||
_filter2descr = {}
|
_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)
|
name = str(class_name)
|
||||||
|
if label == None:
|
||||||
|
label = _("Qualifier")
|
||||||
if description == None:
|
if description == None:
|
||||||
description = _("No description")
|
description = _("No description")
|
||||||
_filter2class[name] = class_name
|
_filter2class[name] = class_name
|
||||||
_filter2descr[name] = description
|
_filter2descr[name] = description
|
||||||
_filter_list.append((class_name,description,qualifier))
|
_filter_list.append((class_name,description,qualifier,label))
|
||||||
|
|
||||||
def get_filter_description(name):
|
def get_filter_description(name):
|
||||||
if _filter2descr.has_key(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("name",filter[1])
|
||||||
menuitem.set_data("function",filter[0])
|
menuitem.set_data("function",filter[0])
|
||||||
menuitem.set_data("qual",filter[2])
|
menuitem.set_data("qual",filter[2])
|
||||||
|
menuitem.set_data("label",filter[3])
|
||||||
menuitem.connect("activate",callback)
|
menuitem.connect("activate",callback)
|
||||||
menuitem.show()
|
menuitem.show()
|
||||||
return myMenu
|
return myMenu
|
||||||
|
@ -54,5 +54,6 @@ class EventAfter(Filter.Filter):
|
|||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
Filter.register_filter(EventAfter,
|
Filter.register_filter(EventAfter,
|
||||||
description=_("People with an event after ..."),
|
description=_("People with an event after ..."),
|
||||||
|
label=_("Date"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
|
||||||
|
@ -54,5 +54,6 @@ class EventBefore(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(EventBefore,
|
Filter.register_filter(EventBefore,
|
||||||
description=_("People with an event before ..."),
|
description=_("People with an event before ..."),
|
||||||
|
label=_("Date"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
|
||||||
|
@ -69,4 +69,5 @@ class EventPlace(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(EventPlace,
|
Filter.register_filter(EventPlace,
|
||||||
description=_("People with an event location of ..."),
|
description=_("People with an event location of ..."),
|
||||||
|
label=_("Place"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
@ -39,4 +39,5 @@ class EventType(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(EventType,
|
Filter.register_filter(EventType,
|
||||||
description=_("People who have an event type of ..."),
|
description=_("People who have an event type of ..."),
|
||||||
|
label=_("Event"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
@ -43,4 +43,5 @@ class MatchSndEx(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(MatchSndEx,
|
Filter.register_filter(MatchSndEx,
|
||||||
description=_("Names with same SoundEx code as ..."),
|
description=_("Names with same SoundEx code as ..."),
|
||||||
|
label=_("Surname"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
@ -39,4 +39,5 @@ class MatchSndEx2(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(MatchSndEx2,
|
Filter.register_filter(MatchSndEx2,
|
||||||
description=_("Names with the specified SoundEx code"),
|
description=_("Names with the specified SoundEx code"),
|
||||||
|
label=_("SoundEx Code"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
@ -50,6 +50,7 @@ class RegExMatch(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(RegExMatch,
|
Filter.register_filter(RegExMatch,
|
||||||
description=_("Names that match a regular expression"),
|
description=_("Names that match a regular expression"),
|
||||||
|
label=_("Text"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,5 +39,6 @@ class SubString(Filter.Filter):
|
|||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
Filter.register_filter(SubString,
|
Filter.register_filter(SubString,
|
||||||
description=_("Names that contain a substring"),
|
description=_("Names that contain a substring"),
|
||||||
|
label=_("Text"),
|
||||||
qualifier=1)
|
qualifier=1)
|
||||||
|
|
||||||
|
@ -792,13 +792,14 @@
|
|||||||
<spacing>0</spacing>
|
<spacing>0</spacing>
|
||||||
<child>
|
<child>
|
||||||
<padding>5</padding>
|
<padding>5</padding>
|
||||||
<expand>False</expand>
|
<expand>True</expand>
|
||||||
<fill>False</fill>
|
<fill>True</fill>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>label185</name>
|
<name>qual</name>
|
||||||
|
<visible>False</visible>
|
||||||
<label>Qualifier</label>
|
<label>Qualifier</label>
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
@ -816,24 +817,36 @@
|
|||||||
<widget>
|
<widget>
|
||||||
<class>GtkEntry</class>
|
<class>GtkEntry</class>
|
||||||
<name>filter</name>
|
<name>filter</name>
|
||||||
|
<visible>False</visible>
|
||||||
<can_focus>True</can_focus>
|
<can_focus>True</can_focus>
|
||||||
<signal>
|
<signal>
|
||||||
<name>activate</name>
|
<name>activate</name>
|
||||||
<handler>on_apply_filter_clicked</handler>
|
<handler>on_apply_filter_clicked</handler>
|
||||||
<last_modification_time>Thu, 06 Sep 2001 23:02:43 GMT</last_modification_time>
|
<last_modification_time>Thu, 06 Sep 2001 23:02:43 GMT</last_modification_time>
|
||||||
</signal>
|
</signal>
|
||||||
<editable>True</editable>
|
<editable>False</editable>
|
||||||
<text_visible>True</text_visible>
|
<text_visible>True</text_visible>
|
||||||
<text_max_length>0</text_max_length>
|
<text_max_length>0</text_max_length>
|
||||||
<text></text>
|
<text></text>
|
||||||
<child>
|
<child>
|
||||||
<padding>0</padding>
|
<padding>0</padding>
|
||||||
<expand>False</expand>
|
<expand>True</expand>
|
||||||
<fill>False</fill>
|
<fill>True</fill>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</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>
|
<widget>
|
||||||
<class>GtkCheckButton</class>
|
<class>GtkCheckButton</class>
|
||||||
<name>invert</name>
|
<name>invert</name>
|
||||||
@ -843,7 +856,7 @@
|
|||||||
<active>False</active>
|
<active>False</active>
|
||||||
<draw_indicator>True</draw_indicator>
|
<draw_indicator>True</draw_indicator>
|
||||||
<child>
|
<child>
|
||||||
<padding>5</padding>
|
<padding>0</padding>
|
||||||
<expand>False</expand>
|
<expand>False</expand>
|
||||||
<fill>False</fill>
|
<fill>False</fill>
|
||||||
</child>
|
</child>
|
||||||
@ -862,12 +875,13 @@
|
|||||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||||
<relief>GTK_RELIEF_NORMAL</relief>
|
<relief>GTK_RELIEF_NORMAL</relief>
|
||||||
<child>
|
<child>
|
||||||
<padding>4</padding>
|
<padding>0</padding>
|
||||||
<expand>False</expand>
|
<expand>False</expand>
|
||||||
<fill>False</fill>
|
<fill>False</fill>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkScrolledWindow</class>
|
<class>GtkScrolledWindow</class>
|
||||||
|
@ -1323,7 +1323,17 @@ def on_apply_filter_clicked(obj):
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def on_filter_name_changed(obj):
|
def on_filter_name_changed(obj):
|
||||||
|
qlabel = gtop.get_widget("qual")
|
||||||
filter = obj.get_data("filter")
|
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"))
|
filter.set_sensitive(obj.get_data("qual"))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user