From a65d79697fbedea93796918acea4d7194e222ac2 Mon Sep 17 00:00:00 2001 From: einarr Date: Sun, 21 Jan 2007 16:16:37 +0000 Subject: [PATCH] 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. --- workflows/go_workflow.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/workflows/go_workflow.py b/workflows/go_workflow.py index d5a8b99..2fec6a7 100644 --- a/workflows/go_workflow.py +++ b/workflows/go_workflow.py @@ -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)' %