Added Expand/Collapse menu choices to the GO browser context menu. This is

particularly useful when searching for GO terms, because the gtk TreeView
widget does not do interactive search in collapsed parts of the tree.
This commit is contained in:
Einar Ryeng 2007-01-21 16:16:37 +00:00
parent e03cc4ed4c
commit a65d79697f

View File

@ -123,7 +123,7 @@ class GeneOntologyTree (gtk.HPaned):
else:
obj = None
self._context_menu.set_current_term(obj)
self._context_menu.set_current_term(obj, iter)
if event.button == 3:
self._context_menu.popup(None, None, None, event.button, event.time)
@ -136,17 +136,36 @@ class GoTermContextMenu (gtk.Menu):
self._treemodel = treemodel
self._treeview = treeview
self._current_term = None
self._current_iter = None
gtk.Menu.__init__(self)
# Popuplate tree
self._expand_item = i = gtk.MenuItem('Expand')
i.connect('activate', self._on_expand_subtree, treemodel, treeview)
self.append(i)
i.show()
self._collapse_item = i = gtk.MenuItem('Collapse')
i.connect('activate', self._on_collapse_subtree, treemodel, treeview)
self.append(i)
i.show()
self._select_subtree_item = i = gtk.MenuItem('Select subtree')
i.connect('activate', self._on_select_subtree, treemodel, treeview)
self.append(i)
i.show()
def set_current_term(self, term):
def set_current_term(self, term, it):
self._current_term = term
self._current_iter = it
def _on_expand_subtree(self, item, treemodel, treeview):
path = treemodel.get_path(self._current_iter)
treeview.expand_row(path, True)
def _on_collapse_subtree(self, item, treemodel, treeview):
treeview.collapse_row(treemodel.get_path(self._current_iter))
def _on_select_subtree(self, item, treemodel, treeview):
logger.log('notice', 'Selecting subtree from GO id: %s (%s)' %