From 1371bc1b1a041ab05e0fc3f8d8768e491ca7e5e6 Mon Sep 17 00:00:00 2001 From: einarr Date: Fri, 5 Jan 2007 14:42:22 +0000 Subject: [PATCH] Added function menu. Clicking the items still does not work, though. --- fluents/fluents.py | 16 ++++++++++++---- fluents/workflow.py | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/fluents/fluents.py b/fluents/fluents.py index 4a23ec8..cf1b859 100644 --- a/fluents/fluents.py +++ b/fluents/fluents.py @@ -160,9 +160,17 @@ class FluentApp: self['appwindow'].set_size_request(800, 600) # Set up workflow - self.wf_menu = workflow.WorkflowView(self.workflow) - self.wf_menu.show() - self['workflow_vbox'].pack_end(self.wf_menu) + self.wf_view = workflow.WorkflowView(self.workflow) + self.wf_view.show() + self['workflow_vbox'].pack_end(self.wf_view) + + self._wf_menu = workflow.WorkflowMenu(self.workflow) + self._wf_menu.show() + wf_menuitem = gtk.MenuItem('Fu_nctions') + wf_menuitem.set_submenu(self._wf_menu) + wf_menuitem.show() + + self['menubar1'].insert(wf_menuitem, 3) # Connect signals signals = {'on_quit1_activate' : (gtk.main_quit), @@ -198,7 +206,7 @@ class FluentApp: def set_workflow(self, workflow): self.workflow = workflow - self.wf_menu.set_workflow(self.workflow) + self.wf_view.set_workflow(self.workflow) def show(self): self.init_gui() diff --git a/fluents/workflow.py b/fluents/workflow.py index 01a302f..e3ee296 100644 --- a/fluents/workflow.py +++ b/fluents/workflow.py @@ -377,3 +377,28 @@ def toggled(renderer, path, store): it = store.get_iter(path) old_value = store.get_value(it, 1) store.set_value(it, 1, not old_value) + + +class WorkflowMenu (gtk.Menu): + + def __init__(self, workflow): + gtk.Menu.__init__(self) + self._workflow = workflow + for stage in workflow.stages: + self.append(self._create_stage_item(stage)) + + def _create_stage_item(self, stage): + stage_menu_item = gtk.MenuItem(stage.name) + stage_menu_item.show() + stage_menu = gtk.Menu() + stage_menu_item.set_submenu(stage_menu) + + for fun in stage.functions: + stage_menu.append(self._create_function_item(fun)) + return stage_menu_item + + def _create_function_item(self, function): + menuitem = gtk.MenuItem(function.name) + menuitem.show() + return menuitem +