20
20
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
import pida.core.base as base
27
import distutils.spawn as spawn
29
from pkg_resources import Requirement, resource_filename
30
icon_file = resource_filename(Requirement.parse('pida'),
24
from pida.pidagtk.contentview import create_pida_icon
33
im.set_from_file(icon_file)
35
class IComponent(object):
37
def get_sanity_errors(self):
40
class Vim(IComponent):
42
def get_sanity_errors(self):
43
if spawn.find_executable('gvim'):
46
return ['Gvim is not installed']
49
LABEL = 'Vim external'
51
class Culebra(IComponent):
54
def get_sanity_errors(self):
59
errors.append('Gtksourceview is not installed')
63
errors.append('Rat is not installed')
66
EDITORS = [Vim(), Vimmulti(), Culebra()]
27
im.set_from_pixbuf(create_pida_icon())
68
29
class FirstTimeWindow(object):
31
def __init__(self, editors):
71
32
self.win = gtk.Dialog(parent=None,
72
33
title='PIDA First Run Wizard',
73
34
buttons=(gtk.STOCK_QUIT, gtk.RESPONSE_REJECT,
88
49
box.pack_start(l, expand=False, padding=8)
89
50
self.radio = gtk.RadioButton()
90
for editor in EDITORS:
51
for editor in editors:
91
52
ebox = gtk.HBox(spacing=6)
92
53
box.pack_start(ebox, expand=False, padding=4)
93
radio = gtk.RadioButton(self.radio, label=editor.LABEL)
54
radio = gtk.RadioButton(self.radio, label=editor.display_name)
94
55
ebox.pack_start(radio)
95
56
cbox = gtk.VBox(spacing=3)
96
57
label = gtk.Label()
101
62
ebox.pack_start(sanitybut, expand=False, padding=1)
102
63
sanitybut.connect('clicked', self.cb_sanity, editor, radio, label)
103
64
self.cb_sanity(sanitybut, editor, radio, label)
104
errs = editor.get_sanity_errors()
105
65
self.radio = radio
107
67
box.pack_start(bbox, expand=False, padding=4)
112
72
self.win.hide_all()
113
73
editor_name = self.get_editor_option()
114
74
self.win.destroy()
115
self.write_file(filename)
75
# Only write the token file if we want the user chose something
76
if response == gtk.RESPONSE_ACCEPT:
77
self.write_file(filename)
116
78
return (response, editor_name)
118
80
def cb_sanity(self, button, component, radio, label):
119
81
errs = component.get_sanity_errors()
121
84
radio.set_sensitive(False)
122
85
radio.set_active(False)