3 import findrox
; findrox
.version(1, 9, 6)
5 from rox
import g
, processes
, saving
6 from cStringIO
import StringIO
8 def try_interface(uri
):
10 launcher
= processes
.PipeThroughCommand(
11 ["0launch", "-d", "--", uri
],
15 except processes
.ChildError
, ex
:
16 if '(256)' not in str(ex
):
19 rox
.report_exception()
24 if len(sys
.argv
) == 1:
25 # By default, create a launcher for ourselves
26 uri
= 'http://rox.sourceforge.net/2005/interfaces/AddApp'
27 if not try_interface(uri
):
29 elif sys
.argv
[1] == '--prompt':
30 from chooser
import Chooser
35 if resp
!= g
.RESPONSE_OK
:
38 uri
= m
.uri
.get_text()
39 if try_interface(uri
):
42 elif len(sys
.argv
) == 2:
44 if not try_interface(uri
):
46 elif len(sys
.argv
) == 3 and sys
.argv
[1] == '--show-help':
48 help.show_help(sys
.argv
[2])
51 rox
.alert("Multiple arguments to AddApp (%s)!" % `sys
.argv
[1:]`
)
54 from launcher
import AppLauncher
56 launcher
= AppLauncher(uri
)
57 box
= saving
.SaveBox(launcher
, os
.path
.basename(uri
), 'inode/directory')
64 icon_pixbuf
= g
.gdk
.pixbuf_new_from_file(launcher
.icon
.name
)
65 image
.set_from_pixbuf(icon_pixbuf
)
66 box
.set_type('inode/directory', image
)
68 launcher
.delete_icon()
70 rox
.report_exception()