In the 0compile-env.xml file, list the interfaces sorted by URI. Having
[0compile.git] / gui.py
blob55ff7773bd04a07d8d41dc046ff535c99af1550d
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 prompt = True
15 if args and args[0] == '--no-prompt':
16 del args[0]
17 prompt = False
19 import gui_support
20 import gtk
22 if len(args) == 0:
23 env = BuildEnv()
24 interface = env.interface
25 build_dir = None
26 prompt = False
27 elif len(args) == 1:
28 interface = args[0]
29 default_dir = os.path.basename(interface)
30 if default_dir.endswith('.xml'):
31 default_dir = default_dir[:-4]
32 assert '/' not in default_dir
34 interface = model.canonical_iface_uri(args[0])
36 build_dir = gui_support.choose_dir(_('Create build directory'), default_dir)
37 if not build_dir: return
38 else:
39 raise __main__.UsageError()
41 try:
42 import setup
43 setup.setup(interface, build_dir, prompt)
44 if build_dir:
45 os.chdir(build_dir)
47 box = gui_support.CompileBox(interface)
48 box.connect('destroy', lambda b: gtk.main_quit())
49 box.show()
51 gtk.main()
52 except KeyboardInterrupt:
53 pass
54 except Exception, ex:
55 import traceback
56 traceback.print_exc()
57 gui_support.alert(None, '%s: %s' % (ex.__class__, ex))
59 __main__.commands.append(do_gui)