This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
laydi/system/dialogs.py
2006-04-25 09:53:35 +00:00

76 lines
2.4 KiB
Python

import pygtk
pygtk.require('2.0')
import gtk
import sys
import os
import gobject
from system import logger, project, workflow
import workflows
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)
def __getitem__(self, key):
return self.widget_tree.get_widget(key)
def make_workflow_list(self):
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
for wf in workflow.workflow_list():
store.insert_after(None, (wf.name, wf))
return store
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)