summaryrefslogtreecommitdiffstats
path: root/build_tools/l7/larch0/gui/front/mainwindow.py
diff options
context:
space:
mode:
Diffstat (limited to 'build_tools/l7/larch0/gui/front/mainwindow.py')
-rw-r--r--build_tools/l7/larch0/gui/front/mainwindow.py132
1 files changed, 132 insertions, 0 deletions
diff --git a/build_tools/l7/larch0/gui/front/mainwindow.py b/build_tools/l7/larch0/gui/front/mainwindow.py
new file mode 100644
index 0000000..407b46a
--- /dev/null
+++ b/build_tools/l7/larch0/gui/front/mainwindow.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python
+#
+# (c) Copyright 2010 Michael Towers (larch42 at googlemail dot com)
+#
+# This file is part of the larch project.
+#
+# larch is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# larch is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with larch; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#----------------------------------------------------------------------------
+#2010.07.13
+
+import __builtin__
+from uim import Uim, debug
+__builtin__.debug = debug
+
+
+_running = False
+def fss(*args, **kargs):
+ while True:
+ if _running:
+ ui.command(':larch.busy', [], True)
+ ok, result = filesystem(*args)
+ if _running:
+ ui.command(':larch.busy', [], False)
+ if ok:
+ filter = kargs.get('filter')
+ return filter(result) if filter else result
+
+ if kargs.get('trap', True):
+ ui.command('errorDialog', result)
+ # That might return, but the gui should quit (soon?).
+ return None
+
+__builtin__.fss = fss
+
+
+
+class Ui(Uim):
+ def __init__(self):
+ Uim.__init__(self)
+
+ def runningtab(self, i=None):
+ if (i == None):
+ i = 1 if progress.active else 0
+ if (i == 0) and hasattr(stage, 'reenter'):
+ stage.reenter()
+ self.command(':tabs.set', i)
+
+ def fileDialog(self, message, startdir=None, create=False,
+ dirsonly=False, file=None, bookmarks=None, filter=None):
+ return self.command('fileDialog', message, startdir, None,
+ dirsonly, create, file, bookmarks, filter)
+
+ def enable_installation_page(self, on):
+ self.command(':notebook.enableTab', 1, on)
+
+ def quit(self):
+ """Do any tidying up which may be necessary.
+ """
+ larchscripts.close()
+ Uim.quit()
+
+ def data(self, key):
+ return self.command('main_page_data.get', key)
+
+__builtin__.ui = Ui()
+
+
+def tab_changed(index):
+ __builtin__.stage = pages[index]
+ stage.enter()
+ui.connect(':notebook*changed', tab_changed)
+
+
+from page_project import ProjectSettings
+from page_installation import Installation
+from page_larchify import Larchify
+from page_mediumprofile import MediumProfile
+from page_medium import Medium
+
+
+from docviewer import DocViewer
+
+from editor import Editor
+
+from logview import Logger, Progress
+
+
+def run_error(message, title=None):
+ ui.command('warningDialog', message, title)
+__builtin__.run_error = run_error
+
+pages = []
+def start():
+ pages.append(ProjectSettings())
+ pages.append(Installation())
+ pages.append(Larchify())
+ pages.append(MediumProfile())
+ pages.append(Medium())
+
+ __builtin__.docviewer = DocViewer()
+ __builtin__.edit = Editor().edit
+
+ __builtin__.progress = Progress()
+ __builtin__.logger = Logger()
+
+ MainWindow = fss('fetch_layout', 'page_main.uim')
+ ui.widgetlist(MainWindow)
+
+ ui.connect('$$$uiclose$$$', ui.quit)
+ ui.connect('$$$uiquit$$$', ui.quit)
+ ui.connect('$$$cancel$$$', larchscripts.interrupt)
+
+ ui.command(':larch.pack')
+ # Set up the first gui page (project settings)
+ pages[0].setup()
+ ui.command(':larch.show')
+ _running = True
+ ui.run()
+