From 28e6c52f78a8492994bc399808671f26bcd1861d Mon Sep 17 00:00:00 2001 From: einarr Date: Thu, 1 Mar 2007 15:06:33 +0000 Subject: [PATCH] Fixed bug with hidden dimensions. --- fluents/selections.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fluents/selections.py b/fluents/selections.py index 43d1b0f..425ba0f 100644 --- a/fluents/selections.py +++ b/fluents/selections.py @@ -443,6 +443,8 @@ class DimListController: self._current_dim = None self._seltree_controller = seltree_controller + self.show_hidden = False + ## dimstore is a list of all dimensions in the application self.dimstore = gtk.ListStore(gobject.TYPE_STRING) @@ -485,11 +487,11 @@ class DimListController: """Returns the iterator to the dimension with the given name, or None if not found.""" - i = self.dimstore.get_iter_first() + i = self.dimstore_filter.get_iter_first() while i: - if self.dimstore.get_value(i, 0) == dim: + if self.dimstore_filter.get_value(i, 0) == dim: return i - i = self.dimstore.iter_next(i) + i = self.dimstore_filter.iter_next(i) return None def set_dimension(self, dimname): @@ -497,10 +499,10 @@ class DimListController: self._current_dim = dimname dim = self.get_dimension(self._current_dim) - path = self.dimstore.get_path(dim) + path = self.dimstore_filter.get_path(dim) if self.dimlist.get_cursor()[0] != path: - self.dimlist.set_cursor(self.dimstore.get_path(dim)) + self.dimlist.set_cursor(self.dimstore_filter.get_path(dim)) self._seltree_controller.set_dimension(dimname) def dataset_changed(self): @@ -512,12 +514,16 @@ class DimListController: for dim in self.dim_names: if not self.get_dimension(dim): self.dimstore.insert_after(None, (dim,)) + self.dimstore_filter.refilter() # # Private interface # def _dimension_filter(self, store, row): """Filters out dimensions with underscore prefix.""" + if self.show_hidden: + return True + visible = False name = store.get_value(row, 0) if name != None: @@ -530,18 +536,19 @@ class DimListController: def _on_dim_hide(self, menuitem): """Menu item callback function which hides underscore prefixed dimensions.""" + self.show_hidden = False self.dimstore_filter.refilter() - self.dimlist.set_model(self.dimstore_filter) def _on_dim_show(self, menuitem): """Menu item callback function that shows underscore prefixed dimension names.""" - self.dimlist.set_model(self.dimstore) + self.show_hidden = True + self.dimstore_filter.refilter() def _dim_cursor_changed(self, widget): cursor = self.dimlist.get_cursor()[0] - i = self.dimlist.get_model().get_iter(cursor) - row = self.dimlist.get_model().get_value(i, 0) + i = self.dimstore_filter.get_iter(cursor) + row = self.dimstore_filter.get_value(i, 0) self.set_dimension(row) self._seltree_controller.activate()