New release.
[zeroinstall.git] / 0launch-gui
blob125f6ce1fdc660a5d31a3eff7df8b7e000da1e4a
1 #!/usr/bin/env python
2 import os, sys
3 from optparse import OptionParser
4 import gui
6 __builtins__._ = lambda x: x
8 parser = OptionParser(usage="usage: %prog [options] interface [args]")
9 parser.add_option("-d", "--download-only", help="fetch but don't run", action='store_true')
10 parser.add_option("-n", "--no-self-update", help="don't check for updates to the GUI itself", action='store_true')
11 parser.add_option("-r", "--refresh", help="refresh all used interfaces", action='store_true')
12 parser.add_option("-v", "--version", help="display version information", action='store_true')
14 parser.disable_interspersed_args()
16 (options, args) = parser.parse_args()
18 if options.version:
19 print "0launch-gui (zero-install) " + gui.version
20 print "Copyright (C) 2005 Thomas Leonard"
21 print "This program comes with ABSOLUTELY NO WARRANTY,"
22 print "to the extent permitted by law."
23 print "You may redistribute copies of this program"
24 print "under the terms of the GNU General Public License."
25 print "For more information about these matters, see the file named COPYING."
26 sys.exit(0)
28 if len(args) < 1:
29 parser.print_help()
30 sys.exit(1)
32 interface_uri = args[0]
33 prog_args = args[1:]
35 from zeroinstall.injector import model, autopolicy, namespaces
36 import gtk
38 if not hasattr(gtk, 'combo_box_new_text'):
39 import combo_compat
41 gtk.rc_parse_string('style "scrolled" { '
42 'GtkScrolledWindow::scrollbar-spacing = 0}\n'
43 'class "GtkScrolledWindow" style : gtk "scrolled"\n')
45 if options.no_self_update is not True:
46 gui_policy = autopolicy.AutoPolicy(namespaces.injector_gui_uri)
47 if gui_policy.need_download():
48 # Need to refresh the GUI itself first!
49 prog_args = ['--no-self-update'] + sys.argv[1:]
50 print `prog_args`
51 interface_uri = namespaces.injector_gui_uri
52 download_only = False
54 policy = gui.GUIPolicy(interface_uri, prog_args,
55 download_only = bool(options.download_only))
56 if options.refresh:
57 policy.refresh_all(force = False)
58 policy.main()