Fixed dim_cursor_changed to to use the correct treemodel, and added show/hide on selection details
This commit is contained in:
parent
0d8702bb71
commit
41e8ed511b
|
@ -15,9 +15,9 @@ class SimpleMenu(gtk.Menu):
|
|||
def __init__(self):
|
||||
gtk.Menu.__init__(self)
|
||||
|
||||
def add_simple_item(self, title, function):
|
||||
def add_simple_item(self, title, function, *args):
|
||||
item = gtk.MenuItem(title)
|
||||
item.connect('activate', function)
|
||||
item.connect('activate', function, *args)
|
||||
self.append(item)
|
||||
item.show()
|
||||
|
||||
|
@ -104,10 +104,8 @@ class IdListController:
|
|||
def set_selection(self, selection):
|
||||
"""Set the selection to be displayed.
|
||||
The selection is not stored, the values are copied into the TreeStore"""
|
||||
|
||||
self._idstore.clear()
|
||||
id_list = list(selection[self._dimension])
|
||||
|
||||
idlist = list(selection[self._dimension])
|
||||
if self._annotation[self._dimension] != None:
|
||||
annlist = annotations.get_dim_annotations(self._dimension,
|
||||
|
@ -182,22 +180,20 @@ class SelectionListController:
|
|||
def __init__(self, seltree, idlist_controller):
|
||||
self._seltree = seltree
|
||||
self._sel_stores = {}
|
||||
self._detail_cols = []
|
||||
self._dimension = None
|
||||
self._idlist_controller = idlist_controller
|
||||
self._details_on = False
|
||||
|
||||
# Selection renderers
|
||||
# Selection column
|
||||
renderer = gtk.CellRendererText()
|
||||
sel_column = gtk.TreeViewColumn('Selection', renderer, text=0)
|
||||
seltree.insert_column(sel_column, 0)
|
||||
|
||||
intersect_cs_col = gtk.TreeViewColumn('In curr.sel.', renderer, text=3)
|
||||
seltree.insert_column(intersect_cs_col, 1)
|
||||
|
||||
n_all_col = gtk.TreeViewColumn('# All', renderer, text=4)
|
||||
seltree.insert_column(n_all_col, 2)
|
||||
|
||||
rank_col = gtk.TreeViewColumn('Rank', renderer, text=5)
|
||||
seltree.insert_column(rank_col, 3)
|
||||
# Detail columns
|
||||
cols = [('In CS', 3), ('All', 4), ('Rank', 5)]
|
||||
for name, store_col in cols:
|
||||
self._detail_cols.append(gtk.TreeViewColumn(name, renderer, text=store_col))
|
||||
|
||||
# Signals
|
||||
seltree.connect('row-activated', self._on_row_activated)
|
||||
|
@ -212,6 +208,8 @@ class SelectionListController:
|
|||
# Selections context menu
|
||||
self._seltree_menu = SimpleMenu()
|
||||
self._seltree_menu.add_simple_item('Sort by selection', self._on_seltree_sort)
|
||||
self._seltree_menu.add_simple_item('Show details', self._enable_details, True)
|
||||
self._seltree_menu.add_simple_item('Hide details', self._enable_details, False)
|
||||
# self._seltree_menu.add_simple_item('Copy selection', self._on_seltree_copy_selection)
|
||||
#
|
||||
# Public interface
|
||||
|
@ -239,7 +237,7 @@ class SelectionListController:
|
|||
|
||||
if not self._get_current_selection_iter(selection, dim):
|
||||
n = len(selection[dim])
|
||||
values = (selection.title, selection, dim, n, n, 2)
|
||||
values = (selection.title, selection, dim, n, n, 0)
|
||||
store.insert_after(None, None, values)
|
||||
|
||||
def add_dataset(self, dataset):
|
||||
|
@ -260,10 +258,9 @@ class SelectionListController:
|
|||
values = (selection.title, selection, dim_name, 0, n_sel, 0)
|
||||
store.insert_after(i, None, values)
|
||||
|
||||
|
||||
##
|
||||
## Private interface
|
||||
##
|
||||
#
|
||||
# Private interface
|
||||
#
|
||||
def _add_selection_store(self, dim):
|
||||
"""Add a new gtk.TreeStore for the selections on a dimension."""
|
||||
# Create new store
|
||||
|
@ -340,6 +337,15 @@ class SelectionListController:
|
|||
#
|
||||
# GTK callbacks
|
||||
#
|
||||
def _enable_details(self, widget, bool):
|
||||
if self._details_on == bool : return
|
||||
self._details_on = bool
|
||||
if bool==True:
|
||||
for col in self._detail_cols:
|
||||
self._seltree.insert_column(col, -1)
|
||||
else:
|
||||
for col in self._detail_cols:
|
||||
self._seltree.remove_column(col)
|
||||
|
||||
def _drag_data_received(self, widget, drag_context, x, y,
|
||||
selection, info, timestamp):
|
||||
|
@ -354,7 +360,6 @@ class SelectionListController:
|
|||
|
||||
def _on_cursor_changed(self, widget):
|
||||
"Show the list of identifier strings."
|
||||
|
||||
store = self._sel_stores[self._dimension]
|
||||
|
||||
p = self._seltree.get_cursor()[0]
|
||||
|
@ -366,7 +371,6 @@ class SelectionListController:
|
|||
|
||||
def _on_row_activated(self, widget, path, column):
|
||||
store = self._sel_stores[self._dimension]
|
||||
|
||||
i = store.get_iter(path)
|
||||
obj = store.get_value(i, 1)
|
||||
if isinstance(obj, dataset.Dataset):
|
||||
|
@ -456,27 +460,21 @@ class DimListController:
|
|||
|
||||
if self.dimlist.get_cursor()[0] != path:
|
||||
self.dimlist.set_cursor(self.dimstore.get_path(dim))
|
||||
|
||||
self._seltree_controller.set_dimension(dimname)
|
||||
|
||||
def dataset_changed(self):
|
||||
"""Callback function from Project."""
|
||||
self.update_dims()
|
||||
|
||||
##
|
||||
## Private interface
|
||||
##
|
||||
def update_dims(self):
|
||||
"""Update the list of dimensions shown"""
|
||||
for dim in self.dim_names:
|
||||
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
|
||||
|
||||
#
|
||||
# Private interface
|
||||
#
|
||||
def _dimension_filter(self, store, row):
|
||||
"""Filters out dimension with underscore prefix"""
|
||||
visible = False
|
||||
|
@ -493,13 +491,13 @@ class DimListController:
|
|||
def _on_dim_show(self, menuitem):
|
||||
self.dimlist.set_model(self.dimstore)
|
||||
|
||||
##
|
||||
## GTK Callbacks.
|
||||
##
|
||||
#
|
||||
# GTK Callbacks.
|
||||
#
|
||||
def _dim_cursor_changed(self, widget):
|
||||
cursor = self.dimlist.get_cursor()[0]
|
||||
i = self.dimstore.get_iter(cursor)
|
||||
row = self.dimstore.get_value(i, 0)
|
||||
i = self.dimlist.get_model().get_iter(cursor)
|
||||
row = self.dimlist.get_model().get_value(i, 0)
|
||||
self.set_dimension(row)
|
||||
|
||||
def _dim_row_activated(self, widget, path, column):
|
||||
|
|
Reference in New Issue