From 874d43f2aaa22c544e359c64778491bc86a3298b Mon Sep 17 00:00:00 2001 From: Raphael Ackermann Date: Sat, 1 Aug 2009 16:09:17 +0000 Subject: [PATCH] 0002070: Event Comparison Tool filter list doesn't update with new filter remove old unused libglade menu in _FilterMenu svn: r12855 --- src/Filters/_FilterMenu.py | 32 +------------------------------- src/Filters/__init__.py | 2 +- src/plugins/tool/EventCmp.py | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/src/Filters/_FilterMenu.py b/src/Filters/_FilterMenu.py index 2a50d498a..6a10353e7 100644 --- a/src/Filters/_FilterMenu.py +++ b/src/Filters/_FilterMenu.py @@ -26,7 +26,6 @@ # #------------------------------------------------------------------------- import gtk -from gettext import gettext as _ import gobject #------------------------------------------------------------------------- @@ -34,36 +33,7 @@ import gobject # This is used by plugins to create a menu of available filters # #------------------------------------------------------------------------- -def build_filter_menu(local_filters = [], default=""): - from Filters import SystemFilters, CustomFilters - menu = gtk.Menu() - - for filt in local_filters: - menuitem = gtk.MenuItem(filt.get_name()) - menuitem.show() - menu.append(menuitem) - menuitem.set_data("filter", filt) - - for filt in SystemFilters.get_filters(): - menuitem = gtk.MenuItem(_(filt.get_name())) - menuitem.show() - menu.append(menuitem) - menuitem.set_data("filter", filt) - - for filt in CustomFilters.get_filters(): - menuitem = gtk.MenuItem(_(filt.get_name())) - menuitem.show() - menu.append(menuitem) - menuitem.set_data("filter", filt) - - return menu - -#------------------------------------------------------------------------- -# -# This is used by plugins to create a menu of available filters -# -#------------------------------------------------------------------------- -def build_filter_model(space, local = [], default=""): +def build_filter_model(space, local = []): from Filters import SystemFilters, CustomFilters model = gtk.ListStore(gobject.TYPE_STRING, object) diff --git a/src/Filters/__init__.py b/src/Filters/__init__.py index 5a4f143b3..109eea271 100644 --- a/src/Filters/__init__.py +++ b/src/Filters/__init__.py @@ -49,7 +49,7 @@ if not CustomFilters: reload_custom_filters() from _FilterComboBox import FilterComboBox -from _FilterMenu import build_filter_menu, build_filter_model +from _FilterMenu import build_filter_model from _FilterStore import FilterStore from _SearchBar import SearchBar from _SearchFilter import SearchFilter, ExactSearchFilter diff --git a/src/plugins/tool/EventCmp.py b/src/plugins/tool/EventCmp.py index 93badaf4c..56110f73d 100644 --- a/src/plugins/tool/EventCmp.py +++ b/src/plugins/tool/EventCmp.py @@ -139,20 +139,20 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): self.set_window(window,self.filterDialog.get_object('title'), self.label) - all = GenericFilter() - all.set_name(_("Entire Database")) - all.add_rule(Rules.Person.Everyone([])) - - the_filters = [all] - from Filters import CustomFilters - the_filters.extend(CustomFilters.get_filters('Person')) - - self.filter_menu = build_filter_model(the_filters) - filter_num = self.options.handler.options_dict['filter'] - self.filters.set_model(self.filter_menu) - self.filters.set_active(0) + self.on_filters_changed('Person') + uistate.connect('filters-changed', self.on_filters_changed) self.show() + + + def on_filters_changed(self, name_space): + if name_space == 'Person': + all_filter = GenericFilter() + all_filter.set_name(_("Entire Database")) + all_filter.add_rule(Rules.Person.Everyone([])) + self.filter_model = build_filter_model('Person', [all_filter]) + self.filters.set_model(self.filter_model) + self.filters.set_active(0) def on_help_clicked(self, obj): """Display the relevant portion of GRAMPS manual""" @@ -170,7 +170,7 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow): pass def on_apply_clicked(self, obj): - cfilter = self.filter_menu[self.filters.get_active()][1] + cfilter = self.filter_model[self.filters.get_active()][1] progress_bar = ProgressMeter(_('Comparing events'),'') progress_bar.set_pass(_('Selecting people'),1)