From 842d1490bed7da6665c06673c1a27278db22888c Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 24 Jun 2015 18:46:03 +0100 Subject: [PATCH] Tidy up and remove redundant code --- gramps/gui/editors/filtereditor.py | 33 +++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/gramps/gui/editors/filtereditor.py b/gramps/gui/editors/filtereditor.py index bb61a4e33..73237a298 100644 --- a/gramps/gui/editors/filtereditor.py +++ b/gramps/gui/editors/filtereditor.py @@ -453,6 +453,7 @@ class EditRule(ManagedWindow): self.valuebox = self.get_widget('valuebox') self.rname = self.get_widget('ruletree') self.rule_name = self.get_widget('rulename') + self.description = self.get_widget('description') self.notebook = Gtk.Notebook() self.notebook.set_show_tabs(0) @@ -462,7 +463,6 @@ class EditRule(ManagedWindow): self.page_num = 0 self.page = [] self.class2page = {} - the_map = {} if self.namespace == 'Person': class_list = rules.person.editor_rule_list @@ -490,10 +490,6 @@ class EditRule(ManagedWindow): pos = 0 l2 = Gtk.Label(label=class_obj.name, halign=Gtk.Align.START) l2.show() - c = Gtk.TreeView() - #c.set_data('d', pos) - c.show() - the_map[class_obj] = c grid = Gtk.Grid() grid.set_border_width(12) grid.set_column_spacing(6) @@ -639,7 +635,7 @@ class EditRule(ManagedWindow): else: self.sel_class = None - keys = sorted(the_map, key=lambda x: x.name, reverse=True) + keys = sorted(class_list, key=lambda x: x.name, reverse=True) catlist = sorted(set(class_obj.category for class_obj in keys)) for category in catlist: @@ -728,23 +724,22 @@ class EditRule(ManagedWindow): Update the informational display on the right hand side of the dialog box with the description of the selected report. """ - store, node = self.selection.get_selected() if node: - try: - class_obj = store.get_value(node, 1) - self.display_values(class_obj) - except: - self.valuebox.set_sensitive(0) - self.rule_name.set_text(_('No rule selected')) - self.get_widget('description').set_text('') + class_obj = store.get_value(node, 1) + self.display_values(class_obj) def display_values(self, class_obj): - page = self.class2page[class_obj] - self.notebook.set_current_page(page) - self.valuebox.set_sensitive(1) - self.rule_name.set_text(class_obj.name) - self.get_widget('description').set_text(class_obj.description) + if class_obj in self.class2page: + page = self.class2page[class_obj] + self.notebook.set_current_page(page) + self.valuebox.set_sensitive(1) + self.rule_name.set_text(class_obj.name) + self.description.set_text(class_obj.description) + else: + self.valuebox.set_sensitive(0) + self.rule_name.set_text(_('No rule selected')) + self.description.set_text('') def rule_ok(self, obj): if self.rule_name.get_text() == _('No rule selected'):