Process minibuffer defaults to previous command.
[rox-edit.git] / findrox.py
blob00fc96a3e05cd51ef37c1b37fbb2599e398b6220
1 # Most of the common code needed by ROX applications is in ROX-Lib2.
2 # Except this code, which is needed to find ROX-Lib2 in the first place!
4 # Just make sure you import findrox before importing anything inside
5 # ROX-Lib2...
7 import os, sys
8 from os.path import exists
9 import string
11 try:
12 path = os.environ['LIBDIRPATH']
13 paths = string.split(path, ':')
14 except KeyError:
15 paths = [ os.environ['HOME'] + '/lib', '/usr/local/lib', '/usr/lib' ]
17 paths = map(lambda p: os.path.join(p, 'ROX-Lib2'), paths)
18 for p in paths:
19 if exists(p):
20 sys.path.append(os.path.join(p, 'python'))
21 break
22 else:
23 err = "This program needs ROX-Lib2 to run.\n" + \
24 "I tried all of these places:\n\n" + \
25 string.join(paths, '\n') + '\n\n' + \
26 "ROX-Lib2 is available from:\nhttp://rox.sourceforge.net"
27 try:
28 sys.stderr.write('*** ' + err + '\n')
29 except:
30 pass
31 try:
32 import pygtk; pygtk.require('2.0')
33 import gtk as g
34 except:
35 import gtk
36 win = gtk.GtkDialog()
37 message = gtk.GtkLabel(err +
38 '\n\nAlso, pygtk2 needs to be present')
39 win.set_title('Missing ROX-Lib2')
40 win.set_position(gtk.WIN_POS_CENTER)
41 message.set_padding(20, 20)
42 win.vbox.pack_start(message)
44 ok = gtk.GtkButton("OK")
45 ok.set_flags(gtk.CAN_DEFAULT)
46 win.action_area.pack_start(ok)
47 ok.connect('clicked', gtk.mainquit)
48 ok.grab_default()
50 win.connect('destroy', gtk.mainquit)
51 win.show_all()
52 gtk.mainloop()
53 else:
54 box = g.MessageDialog(None, g.MESSAGE_ERROR, 0,
55 g.BUTTONS_OK, err)
56 box.set_title('Missing ROX-Lib2')
57 box.set_position(g.WIN_POS_CENTER)
58 box.set_default_response(g.RESPONSE_OK)
59 box.run()
60 sys.exit(1)