Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Fixed function output bug. Datasets now appear as children of their first parent, also in gtk 2.10

This commit is contained in:
Einar Ryeng 2007-01-03 13:05:37 +00:00
parent c34f23190b
commit 75447d8840
2 changed files with 19 additions and 23 deletions

View File

@ -19,6 +19,8 @@ class NavigatorView (gtk.TreeView):
# various properties # various properties
self.set_headers_visible(False) self.set_headers_visible(False)
self.get_hadjustment().set_value(0) self.get_hadjustment().set_value(0)
self.set_enable_tree_lines(True)
# Selection Mode # Selection Mode
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)

View File

@ -8,9 +8,12 @@ import dataset, plots
class Project: class Project:
def __init__(self,name="Testing"): def __init__(self,name="Testing"):
self.data_tree = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, self.data_tree = gtk.TreeStore(gobject.TYPE_STRING,
gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_OBJECT, gobject.TYPE_PYOBJECT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_OBJECT,
gobject.TYPE_DOUBLE) gobject.TYPE_DOUBLE)
self.name = name self.name = name
@ -22,6 +25,7 @@ class Project:
self.sel_obj = dataset.Selection('Current Selection') self.sel_obj = dataset.Selection('Current Selection')
self.selections = [] self.selections = []
self._last_selection = None self._last_selection = None
self._dataset_iter_map = {}
def add_selection_observer(self, observer): def add_selection_observer(self, observer):
self._selection_observers.append(observer) self._selection_observers.append(observer)
@ -52,28 +56,17 @@ class Project:
"""Returns the current selection object""" """Returns the current selection object"""
return self.sel_obj return self.sel_obj
def get_data_iter(self, obj):
"""Retuns an iterator to data."""
retval = [None]
if obj:
# add data below first function data input
obj=obj[0]
def is_obj(m, p, i, d):
if obj == m.get_value(i, 2):
d.append(i)
return True
self.data_tree.foreach(is_obj, retval)
return retval[-1]
def add_data(self, parents, data, fun='Function'): def add_data(self, parents, data, fun='Function'):
"""Adds a set of data and plots to the navigator. """Adds a set of data and plots to the navigator.
This method is usually called after a Function in a workflow This method is usually called after a Function in a workflow
has finished and returns its output.""" has finished and returns its output."""
parent_iter = self.get_data_iter(parents) if len(parents) > 0:
parent_iter = self._dataset_iter_map[parents[0]]
else:
parent_iter = None
icon_fname = os.path.join(fluents.ICONDIR, "folder_grey.png") icon_fname = os.path.join(fluents.ICONDIR, "folder_grey.png")
icon = gtk.gdk.pixbuf_new_from_file(icon_fname) icon = gtk.gdk.pixbuf_new_from_file(icon_fname)
it = self.data_tree_insert(parent_iter, fun, None, None, "black", icon) it = self.data_tree_insert(parent_iter, fun, None, None, "black", icon)
@ -113,6 +106,7 @@ class Project:
tree.set_value(it, 4, fontcolour) tree.set_value(it, 4, fontcolour)
tree.set_value(it, 5, icon) tree.set_value(it, 5, icon)
tree.set_value(it, 6, selected) tree.set_value(it, 6, selected)
self._dataset_iter_map[data] = it
return it return it
def add_dataset(self, dataset): def add_dataset(self, dataset):