Only display selected dependencies in autocompile output
[0compile.git] / gui.py
bloba2124721a4618140c7e229e1b04a5967d072058b
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, __main__
8 from zeroinstall import SafeException
10 from support import BuildEnv, _
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, old versions of 0launch's GUI pass it (< 0.52)
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 SafeException("usage: 0compile gui URI")
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)