Added accelerator for Download button.
[zeroinstall.git] / 0launch-gui
blob59542b2158800b68ac9a4b449e238572268769b1
1 #!/usr/bin/env python
2 import os, sys
3 from optparse import OptionParser
4 import pygtk; pygtk.require('2.0')
5 import gui
7 __builtins__._ = lambda x: x
9 parser = OptionParser(usage="usage: %prog [options] interface [args]")
10 parser.add_option("-d", "--download-only", help="fetch but don't run", action='store_true')
11 parser.add_option("-m", "--main", help="name of the file to execute")
12 parser.add_option("-n", "--no-self-update", help="don't check for updates to the GUI itself", action='store_true')
13 parser.add_option("-r", "--refresh", help="check for updates of all interfaces", action='store_true')
14 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
15 parser.add_option("-V", "--version", help="display version information", action='store_true')
17 parser.disable_interspersed_args()
19 (options, args) = parser.parse_args()
21 if options.verbose:
22 import logging
23 logger = logging.getLogger()
24 if options.verbose == 1:
25 logger.setLevel(logging.INFO)
26 else:
27 logger.setLevel(logging.DEBUG)
29 if options.version:
30 print "0launch-gui (zero-install) " + gui.version
31 print "Copyright (C) 2005 Thomas Leonard"
32 print "This program comes with ABSOLUTELY NO WARRANTY,"
33 print "to the extent permitted by law."
34 print "You may redistribute copies of this program"
35 print "under the terms of the GNU General Public License."
36 print "For more information about these matters, see the file named COPYING."
37 sys.exit(0)
39 if len(args) < 1:
40 parser.print_help()
41 sys.exit(1)
43 interface_uri = args[0]
44 prog_args = args[1:]
46 from zeroinstall.injector import model, autopolicy, namespaces
47 import gtk
49 if not hasattr(gtk, 'combo_box_new_text'):
50 import combo_compat
52 gtk.rc_parse_string('style "scrolled" { '
53 'GtkScrolledWindow::scrollbar-spacing = 0}\n'
54 'class "GtkScrolledWindow" style : gtk "scrolled"\n')
56 if options.no_self_update is not True:
57 gui_policy = autopolicy.AutoPolicy(namespaces.injector_gui_uri)
58 if gui_policy.need_download():
59 # Need to refresh the GUI itself first!
60 prog_args = ['--no-self-update']
61 if options.main:
62 prog_args += ['--main', options.main]
63 options.main = None
64 prog_args += sys.argv[1:]
66 interface_uri = namespaces.injector_gui_uri
67 options.download_only = False
69 policy = gui.GUIPolicy(interface_uri, prog_args,
70 download_only = bool(options.download_only),
71 refresh = bool(options.refresh),
72 main = options.main)
73 policy.main()