Update year to 2009 in various places
[zeroinstall/zeroinstall-rsl.git] / zeroinstall / gtkui / desktop.py
blob6863bc553f0b7fdb02a7248876b68565bfbe3bdf
1 """Code for the B{0desktop} command."""
3 # Copyright (C) 2009, Thomas Leonard
4 # See the README file for details, or visit http://0install.net.
6 import sys
7 from optparse import OptionParser
8 import logging
10 def main(command_args):
11 """Implements the logic of the 0desktop command.
12 @param command_args: the command-line arguments"""
13 parser = OptionParser(usage="usage: %prog [options] [URI]")
14 parser.add_option("-m", "--manage", help="manage added applications", action='store_true')
15 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
16 parser.add_option("-V", "--version", help="display version information", action='store_true')
18 (options, args) = parser.parse_args(command_args)
20 if options.verbose:
21 logger = logging.getLogger()
22 if options.verbose == 1:
23 logger.setLevel(logging.INFO)
24 else:
25 logger.setLevel(logging.DEBUG)
26 hdlr = logging.StreamHandler()
27 fmt = logging.Formatter("%(levelname)s:%(message)s")
28 hdlr.setFormatter(fmt)
29 logger.addHandler(hdlr)
31 if options.version:
32 import zeroinstall
33 print "0desktop (zero-install) " + zeroinstall.version
34 print "Copyright (C) 2009 Thomas Leonard"
35 print "This program comes with ABSOLUTELY NO WARRANTY,"
36 print "to the extent permitted by law."
37 print "You may redistribute copies of this program"
38 print "under the terms of the GNU Lesser General Public License."
39 print "For more information about these matters, see the file named COPYING."
40 sys.exit(0)
42 if not args:
43 interface_uri = None
44 elif len(args) == 1:
45 interface_uri = args[0]
46 else:
47 parser.print_help()
48 sys.exit(1)
50 import pygtk; pygtk.require('2.0')
51 import gtk
53 if options.manage:
54 from zeroinstall.gtkui.applistbox import AppListBox, AppList
55 from zeroinstall.injector.iface_cache import iface_cache
56 box = AppListBox(iface_cache, AppList())
57 else:
58 from zeroinstall.gtkui.addbox import AddBox
59 box = AddBox(interface_uri)
61 box.window.connect('destroy', gtk.main_quit)
62 box.window.show()
63 gtk.main()