Minor updates to feed to remove deprecated features.
[AddApp.git] / Zero2Bundle / chooser.py
blobc50001122913137464bd10469b9eef64116732f5
1 import rox
2 from rox import g, loading
3 import codecs
5 class Chooser(rox.Dialog, loading.XDSLoader):
6 def __init__(self):
7 rox.Dialog.__init__(self)
8 loading.XDSLoader.__init__(self, ['text/x-moz-url'])
10 vbox = g.VBox(False, 2)
11 self.vbox.pack_start(vbox, True, True, 0)
12 vbox.set_border_width(10)
14 message = g.Label('Enter the URI of a program available through the Zero Install\n'
15 'Injector system, or drag a link from a web browser into this\n'
16 'window.')
17 self.set_has_separator(False)
18 vbox.pack_start(message)
20 self.uri = g.Entry()
21 self.uri.set_text('http://rox.sourceforge.net/2005/interfaces/ROX-Filer')
22 vbox.pack_start(self.uri)
23 self.uri.set_activates_default(True)
25 self.vbox.show_all()
27 fetching = g.Label('Checking interface URI...')
28 vbox.pack_start(fetching)
30 self.add_button(g.STOCK_CANCEL, g.RESPONSE_CANCEL)
31 self.add_button(g.STOCK_ADD, g.RESPONSE_OK)
32 self.set_default_response(g.RESPONSE_OK)
34 def xds_load_uris(self, uris):
35 assert uris
36 if len(uris) > 1:
37 rox.error("Can't handle multiple URIs at once! (got %s)" % repr(uris))
38 return
39 self.uri.set_text(uris[0])
41 def xds_load_from_selection(self, selection, leafname = None):
42 if selection.data is None:
43 g.gdk.beep() # Load aborted
44 return
45 data = codecs.utf_16_decode(selection.data)[0]
46 uri = data.split('\n')[0]
47 self.xds_load_uris([uri])