diff --git a/system/navigator.py b/system/navigator.py index 0a823d2..a07d99f 100644 --- a/system/navigator.py +++ b/system/navigator.py @@ -2,6 +2,7 @@ import gtk import gobject import plots +import time from system import dataset, logger, plots, project, workflow class NavigatorView (gtk.TreeView): @@ -22,6 +23,7 @@ class NavigatorView (gtk.TreeView): self.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.get_selection().set_select_function(self.is_selectable) self.get_selection().connect('changed',self.selection_changed_handler) + self._previous_selection = [] # Setting up TextRenderers etc # self.connect('cursor_changed', self.cursor_changed_handler) @@ -71,10 +73,20 @@ class NavigatorView (gtk.TreeView): # selection changed, setting current_data ojbects def selection_changed_handler(self, selection): + # update prev selection right away in case of multiple events model, paths = selection.get_selected_rows() - - objs = [self.data_tree.get_value(self.data_tree.get_iter(path),2) for path in paths] - + tmp = self._previous_selection + self._previous_selection = paths + + # set timestamp on newly selected objects + [self.data_tree.set_value(self.data_tree.get_iter(path),5,time.time()) for path in paths if path not in tmp] + + objs = [self.data_tree.get_iter(path) for path in paths] + objs = [(self.data_tree.get_value(iter,5), self.data_tree.get_value(iter,2)) for iter in objs] + objs.sort() + objs = [obj for timestamp, obj in objs] + # order dataset + if objs and isinstance(objs[0], dataset.Dataset): logger.log('debug', 'Selecting dataset') self.project.set_current_data(objs) diff --git a/system/project.py b/system/project.py index 0738054..c2dfcd4 100644 --- a/system/project.py +++ b/system/project.py @@ -8,7 +8,7 @@ class Project: def __init__(self,name="Testing"): self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, - gobject.TYPE_PYOBJECT,gobject.TYPE_STRING,gobject.TYPE_STRING) + gobject.TYPE_PYOBJECT,gobject.TYPE_STRING,gobject.TYPE_STRING, gobject.TYPE_DOUBLE) self.name = name self.dim_names = [] @@ -61,7 +61,7 @@ class Project: d.set_selection_listener(self.set_selection) self._selection_observers.append(d) - def data_tree_insert(self, parent, text, data, bgcolour,fontcolour): + def data_tree_insert(self, parent, text, data, bgcolour,fontcolour,selected = 0): tree = self.data_tree it = tree.append(parent) tree.set_value(it, 0, text) @@ -69,6 +69,7 @@ class Project: tree.set_value(it, 2, data) tree.set_value(it, 3, bgcolour) tree.set_value(it, 4, fontcolour) + tree.set_value(it, 5, selected) return it def add_dataset(self,dataset):