2006-04-23 00:29:02 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
import logger
|
|
|
|
import project
|
|
|
|
import workflows
|
|
|
|
import workflow
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
GLADEFILENAME = 'system/fluent.glade'
|
|
|
|
|
|
|
|
class CreateProjectDruid(gtk.Window):
|
|
|
|
"""A druid for creating a new project.
|
|
|
|
|
|
|
|
The CreateProjectDruid gets a list of all classes derived from
|
|
|
|
Workflow, and asks the user to select one of these. A new project of
|
|
|
|
the selected class is added to the application."""
|
|
|
|
|
|
|
|
def __init__(self, app):
|
|
|
|
gtk.Window.__init__(self)
|
|
|
|
self.app = app
|
|
|
|
self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'new_project_druid')
|
|
|
|
self.workflows = self.make_workflow_list()
|
|
|
|
self.selected = None
|
|
|
|
|
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
wf_name = gtk.TreeViewColumn('Workflow Name', renderer, text=0)
|
|
|
|
self['workflow_list'].insert_column(wf_name, 0)
|
|
|
|
|
|
|
|
self.wf_info = gtk.TextBuffer()
|
|
|
|
self['workflow_info'].set_buffer(self.wf_info)
|
|
|
|
|
2006-04-24 23:52:18 +02:00
|
|
|
def __getitem__(self, key):
|
|
|
|
return self.widget_tree.get_widget(key)
|
2006-04-23 00:29:02 +02:00
|
|
|
|
|
|
|
def make_workflow_list(self):
|
|
|
|
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
|
2006-04-24 23:52:18 +02:00
|
|
|
for wf in workflow.workflow_list():
|
|
|
|
store.insert_after(None, (wf.name, wf))
|
2006-04-23 00:29:02 +02:00
|
|
|
return store
|
2006-04-24 23:52:18 +02:00
|
|
|
|
2006-04-23 00:29:02 +02:00
|
|
|
def run(self):
|
|
|
|
self['workflow_list'].set_model(self.workflows)
|
|
|
|
|
|
|
|
self['druidpagestart1'].show()
|
|
|
|
self['druidpagefinish1'].show()
|
|
|
|
self['new_project_druid'].show()
|
|
|
|
|
|
|
|
self['druidpagefinish1'].connect('finish', self.finish)
|
|
|
|
self['workflow_list'].connect('cursor_changed', self.selection_updated)
|
|
|
|
self.connect('destroy', self.delete)
|
|
|
|
|
|
|
|
def delete(self, widget):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def hide(self):
|
|
|
|
self['druidpagestart1'].hide()
|
|
|
|
self['druidpagefinish1'].hide()
|
|
|
|
self['new_project_druid'].hide()
|
|
|
|
gtk.Window.hide(self)
|
|
|
|
|
|
|
|
def finish(self, *rest):
|
|
|
|
tree, it = self['workflow_list'].get_selection().get_selected()
|
|
|
|
wf = self.workflows.get_value(it, 1)
|
|
|
|
proj = project.Project()
|
|
|
|
self.app.set_workflow(wf(self.app))
|
|
|
|
self.app.set_project(proj)
|
|
|
|
self.hide()
|
|
|
|
self.destroy()
|
|
|
|
|
|
|
|
def selection_updated(self, *rest):
|
|
|
|
tree, it = self['workflow_list'].get_selection().get_selected()
|
|
|
|
wf = self.workflows.get_value(it, 1)
|
|
|
|
self.wf_info.set_text(wf.description)
|
|
|
|
|