From 2bae169f3818e698f5d481a876b8da7b37313035 Mon Sep 17 00:00:00 2001 From: einarr Date: Wed, 21 Feb 2007 16:39:04 +0000 Subject: [PATCH] Annotation display now works (sort of). --- fluents/selections.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/fluents/selections.py b/fluents/selections.py index 043b10f..0e673eb 100644 --- a/fluents/selections.py +++ b/fluents/selections.py @@ -38,6 +38,9 @@ class IdListController: self._idstore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,) + # Annotation tree column + self._annotation_column = None + ## Set up identifier list idlist.set_model(self._idstore) @@ -64,6 +67,8 @@ class IdListController: if dimname == self._dimension: return + self.set_annotation(self._annotation.get(dimname, None)) + if not self._annotation.has_key(dimname): self._annotation[dimname] = None self._dimension = dimname @@ -73,14 +78,28 @@ class IdListController: the annotation column is hidden. Otherwise the annotation column is shown and filled with values from the given annotation field.""" - if annotation == self._annotation: - return - - if self.annotation == None: - self._idlist.remove_column(self._annotation_colum) + if annotation == None: + if self._annotation_column != None: + self._idlist.remove_column(self._annotation_column) + self._annotation_column = None else: - for x in self._idstore: - print "set annotation:", x + + idlist = [x[0] for x in self._idstore] + annlist = annotations.get_dim_annotations(self._dimension, + annotation, + idlist) + + for i, x in enumerate(self._idstore): + x[1] = annlist[i] + + if self._annotation_column == None: + renderer = gtk.CellRendererText() + col = gtk.TreeViewColumn(annotation, renderer, text=1) + self._idlist.append_column(col) + self._annotation_column = col + self._annotation_column.set_title(annotation) + + self._annotation[self._dimension] = annotation def set_selection(self, selection): """Set the selection to be displayed. @@ -109,7 +128,6 @@ class IdListController: dim_h = annotations.get_dim_handler(self._dimension) if not dim_h: - print "No annotations etc" self._menu_ann.set_sensitive(False) else: annotations_menu = gtk.Menu() @@ -215,7 +233,6 @@ class SelectionListController: def selection_changed(self, dimname, selection): """Callback function from Project.""" - print "selection changed" for dim in selection.dims(): self._ensure_selection_store(dim) store = self._sel_stores[dim]