fixed ordering of multiple selected datasets

This commit is contained in:
2006-05-09 12:22:50 +00:00
parent 0db25f1dd7
commit 184a49ef9a
2 changed files with 18 additions and 5 deletions

View File

@@ -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)