diff --git a/src/Filter.py b/src/Filter.py index 9adb07bca..da8ab6a41 100644 --- a/src/Filter.py +++ b/src/Filter.py @@ -127,12 +127,14 @@ def load_filters(dir): # # #------------------------------------------------------------------------- -def build_filter_menu(callback): +def build_filter_menu(callback,fw): myMenu = gtk.GtkMenu() for filter in _filter_list: menuitem = gtk.GtkMenuItem(filter[1]) myMenu.append(menuitem) - menuitem.set_data("filter",filter[0]) + menuitem.set_data("filter",fw) + menuitem.set_data("name",filter[1]) + menuitem.set_data("function",filter[0]) menuitem.set_data("qual",filter[2]) menuitem.connect("activate",callback) menuitem.show() diff --git a/src/gramps_main.py b/src/gramps_main.py index c18670dde..a939d0932 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -2028,7 +2028,7 @@ def on_apply_filter_clicked(obj): invert_filter = gtop.get_widget("invert").get_active() qualifer = gtop.get_widget("filter").get_text() menu = gtop.get_widget(FILTERNAME).get_menu() - class_init = menu.get_active().get_data("filter") + class_init = menu.get_active().get_data("function") DataFilter = class_init(qualifer) DataFilter.set_invert(invert_filter) apply_filter() @@ -2039,7 +2039,8 @@ def on_apply_filter_clicked(obj): # #------------------------------------------------------------------------- def on_filter_name_changed(obj): - gtop.get_widget("filter").set_sensitive(obj.get_data("qual")) + filter = obj.get_data("filter") + filter.set_sensitive(obj.get_data("qual")) #------------------------------------------------------------------------- # @@ -2969,9 +2970,10 @@ def main(arg): person_list.set_sort_column(sort_column) person_list.set_sort_type(sort_direct) - filter_list.set_menu(Filter.build_filter_menu(on_filter_name_changed)) + fw = gtop.get_widget('filter') + filter_list.set_menu(Filter.build_filter_menu(on_filter_name_changed,fw)) - gtop.get_widget("filter").set_sensitive(0) + fw.set_sensitive(0) # set the window icon topWindow.set_icon(GtkPixmap(topWindow,const.logo)) diff --git a/src/plugins/EventCmp.py b/src/plugins/EventCmp.py index 110e5c30b..9fdc77bcf 100644 --- a/src/plugins/EventCmp.py +++ b/src/plugins/EventCmp.py @@ -63,10 +63,10 @@ from OpenSpreadSheet import * OBJECT = "o" INDEX = "i" -FUNCTION = "f" -QUALIFIER= "q" -FILTER = "x" -NAME = "n" +FILTER = "filter" +FUNCTION = "function" +QUALIFIER= "qual" +NAME = "name" #------------------------------------------------------------------------ # @@ -197,17 +197,8 @@ class EventComparison: self.filter_list_obj.set_data(OBJECT,self) self.filter_list = [] - - myMenu = GtkMenu() - for filter in Filter.filterMap.keys(): - menuitem = GtkMenuItem(filter) - myMenu.append(menuitem) - menuitem.set_data(FILTER,Filter.filterMap[filter]) - menuitem.set_data(FUNCTION,Filter.filterEnb[filter]) - menuitem.set_data(NAME,filter) - menuitem.set_data(QUALIFIER,qualifier) - menuitem.connect("activate",on_filter_name_changed) - menuitem.show() + + myMenu = Filter.build_filter_menu(on_filter_name_changed,qualifier) self.filter_menu.set_menu(myMenu) top.set_data(OBJECT,self) @@ -538,7 +529,7 @@ def on_add_clicked(obj): qualifier = myobj.filterDialog.get_widget("qualifier").get_text() menu = myobj.filter_menu.get_menu() - function = menu.get_active().get_data(FILTER) + function = menu.get_active().get_data(FUNCTION) name = menu.get_active().get_data(NAME) myfilter = function(qualifier) @@ -554,7 +545,6 @@ def on_add_clicked(obj): else: invert_text = "no" - print name, qualifier, invert_text myobj.filter_list_obj.append([name,qualifier,invert_text]) #------------------------------------------------------------------------- @@ -563,9 +553,7 @@ def on_add_clicked(obj): # #------------------------------------------------------------------------- def on_filter_name_changed(obj): - function = obj.get_data(FUNCTION) - qualifier = obj.get_data(QUALIFIER) - qualifier.set_sensitive(function()) + obj.get_data(FILTER).set_sensitive(obj.get_data(QUALIFIER)) #------------------------------------------------------------------------- #