Include details of the selected implementations in bug reports
[0compile.git] / gui.py
blob25bcdf0af1b21d69abac495b8b56380f69104e77
1 # Copyright (C) 2006, Thomas Leonard
2 # See http://0install.net/0compile.html
4 # This is normally called by 0launch's GUI.
6 import sys, os, __main__
7 from zeroinstall.injector.iface_cache import iface_cache
8 from logging import info
10 from support import *
12 def do_gui(args):
13 "gui [--no-prompt] [SOURCE-URI]"
14 if args and args[0] == '--no-prompt':
15 del args[0]
16 # This option no longer has any effect, since it is the default.
17 # However, 0launch's GUI passes it.
19 import gui_support
20 import gtk
22 try:
23 if len(args) == 0:
24 pass
25 elif len(args) == 1:
26 import setup
27 def get_dir_callback(default_dir):
28 compile_dir = gui_support.choose_dir(_('Create build directory'), default_dir)
29 if compile_dir:
30 return compile_dir
31 raise SafeException("Cancelled at user's request")
32 setup.do_setup(args, get_dir_callback)
33 else:
34 raise __main__.UsageError()
36 buildenv = BuildEnv()
37 box = gui_support.CompileBox(buildenv.interface)
38 box.connect('destroy', lambda b: gtk.main_quit())
39 box.show()
41 gtk.main()
42 except KeyboardInterrupt:
43 pass
44 except SafeException, ex:
45 gui_support.alert(None, '%s' % ex)
46 sys.exit(1)
47 except Exception, ex:
48 import traceback
49 traceback.print_exc()
50 gui_support.alert(None, '%s: %s' % (ex.__class__, ex))
51 sys.exit(1)
53 __main__.commands.append(do_gui)