added show/hide on dimensions
This commit is contained in:
parent
2bae169f38
commit
0d8702bb71
|
@ -402,18 +402,30 @@ class DimListController:
|
|||
## dimstore is a list of all dimensions in the application
|
||||
self.dimstore = gtk.ListStore(gobject.TYPE_STRING)
|
||||
|
||||
# filter for hiding dims prefixed with underscore
|
||||
self.dimstore_filter = self.dimstore.filter_new()
|
||||
self.dimstore_filter.set_visible_func(self._dimension_filter)
|
||||
|
||||
## The widgets we are controlling
|
||||
self.dimlist = dimlist
|
||||
|
||||
## Set up dimensions list
|
||||
dimlist.set_model(self.dimstore)
|
||||
dimlist.set_model(self.dimstore_filter)
|
||||
|
||||
renderer = gtk.CellRendererText()
|
||||
dim_column = gtk.TreeViewColumn('Dimension', renderer, text=0)
|
||||
dimlist.insert_column(dim_column, 0)
|
||||
|
||||
# Signals
|
||||
dimlist.connect('row-activated', self._dim_row_activated)
|
||||
dimlist.connect('cursor-changed', self._dim_cursor_changed)
|
||||
dimlist.connect('button-press-event', self._dimlist_button_pressed)
|
||||
|
||||
# Set up dimension context menu
|
||||
self._dimlist_menu = SimpleMenu()
|
||||
self._dimlist_menu.add_simple_item('Hide', self._on_dim_hide)
|
||||
self._dimlist_menu.add_simple_item('Show all', self._on_dim_show)
|
||||
|
||||
|
||||
##
|
||||
## Public interface
|
||||
|
@ -460,10 +472,26 @@ class DimListController:
|
|||
if not self.get_dimension(dim):
|
||||
self.dimstore.insert_after(None, (dim,))
|
||||
|
||||
#def _dimension_filter(self, store, row):
|
||||
# """Filters out everything but the selected dimension."""
|
||||
# row_dim = store.get_value(row, 2)
|
||||
# return row_dim == self._current_dim
|
||||
|
||||
def _dimension_filter(self, store, row):
|
||||
"""Filters out everything but the selected dimension."""
|
||||
row_dim = store.get_value(row, 2)
|
||||
return row_dim == self._current_dim
|
||||
"""Filters out dimension with underscore prefix"""
|
||||
visible = False
|
||||
name = store.get_value(row, 0)
|
||||
if name != None:
|
||||
visible = name[0]!="_"
|
||||
#print (name, visible)
|
||||
return visible
|
||||
|
||||
def _on_dim_hide(self, menuitem):
|
||||
self.dimstore_filter.refilter()
|
||||
self.dimlist.set_model(self.dimstore_filter)
|
||||
|
||||
def _on_dim_show(self, menuitem):
|
||||
self.dimlist.set_model(self.dimstore)
|
||||
|
||||
##
|
||||
## GTK Callbacks.
|
||||
|
@ -477,3 +505,6 @@ class DimListController:
|
|||
def _dim_row_activated(self, widget, path, column):
|
||||
self._seltree_controller.set_dimension(dim)
|
||||
|
||||
def _dimlist_button_pressed(self, widget, event):
|
||||
if event.button == 3:
|
||||
self._dimlist_menu.popup(None, None, None, event.button, event.time)
|
||||
|
|
Reference in New Issue