Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

fixed ordering of multiple selected datasets

This commit is contained in:
Reidar Strand Hagen 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 gtk
import gobject import gobject
import plots import plots
import time
from system import dataset, logger, plots, project, workflow from system import dataset, logger, plots, project, workflow
class NavigatorView (gtk.TreeView): class NavigatorView (gtk.TreeView):
@ -22,6 +23,7 @@ class NavigatorView (gtk.TreeView):
self.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.get_selection().set_select_function(self.is_selectable) self.get_selection().set_select_function(self.is_selectable)
self.get_selection().connect('changed',self.selection_changed_handler) self.get_selection().connect('changed',self.selection_changed_handler)
self._previous_selection = []
# Setting up TextRenderers etc # Setting up TextRenderers etc
# self.connect('cursor_changed', self.cursor_changed_handler) # self.connect('cursor_changed', self.cursor_changed_handler)
@ -71,9 +73,19 @@ class NavigatorView (gtk.TreeView):
# selection changed, setting current_data ojbects # selection changed, setting current_data ojbects
def selection_changed_handler(self, selection): def selection_changed_handler(self, selection):
# update prev selection right away in case of multiple events
model, paths = selection.get_selected_rows() model, paths = selection.get_selected_rows()
tmp = self._previous_selection
self._previous_selection = paths
objs = [self.data_tree.get_value(self.data_tree.get_iter(path),2) for path in 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): if objs and isinstance(objs[0], dataset.Dataset):
logger.log('debug', 'Selecting dataset') logger.log('debug', 'Selecting dataset')

View File

@ -8,7 +8,7 @@ class Project:
def __init__(self,name="Testing"): def __init__(self,name="Testing"):
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, self.data_tree = gtk.TreeStore(gobject.TYPE_STRING,
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.name = name
self.dim_names = [] self.dim_names = []
@ -61,7 +61,7 @@ class Project:
d.set_selection_listener(self.set_selection) d.set_selection_listener(self.set_selection)
self._selection_observers.append(d) 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 tree = self.data_tree
it = tree.append(parent) it = tree.append(parent)
tree.set_value(it, 0, text) tree.set_value(it, 0, text)
@ -69,6 +69,7 @@ class Project:
tree.set_value(it, 2, data) tree.set_value(it, 2, data)
tree.set_value(it, 3, bgcolour) tree.set_value(it, 3, bgcolour)
tree.set_value(it, 4, fontcolour) tree.set_value(it, 4, fontcolour)
tree.set_value(it, 5, selected)
return it return it
def add_dataset(self,dataset): def add_dataset(self,dataset):