1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
#
# mouse_gui.py: gui mouse configuration.
#
# Copyright 2000-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import gtk
import string
import gobject
import gui
from iw_gui import *
from re import *
from rhpl.translate import _, N_
from flags import flags
class MouseWindow(InstallWindow):
windowTitle = N_("Mouse Configuration")
htmlTag = "mouse"
def getNext(self):
self.mouse.setMouse(self.currentMouse,self.emulate3.get_active())
mouse = self.mice[self.currentMouse]
(make, model, gpmproto, xproto, device, emulate3) = mouse
if device == "ttyS":
self.mouse.setDevice(self.serialDevice)
else:
self.mouse.setDevice(device)
if self.flags.setupFilesystems:
self.mouse.setXProtocol()
return None
def selectDeviceType(self, selection, *args):
if self.ignoreEvents:
return
(model, iter) = selection.get_selected()
if iter:
self.serialDevice = model.get_value(iter, 1)
self.ics.setNextEnabled(True)
else:
self.serialDevice = None
def selectMouseType(self, selection, *args):
if self.ignoreEvents:
return
(model, iter) = selection.get_selected()
if iter is None:
return
if model.iter_has_child(iter):
self.devview.get_selection().unselect_all()
self.devview.set_sensitive(False)
self.emulate3.set_sensitive(False)
self.ics.setNextEnabled(False)
return
cur = model.get_value(iter, 1)
self.emulate3.set_sensitive(True)
(make, model, gpmproto, xproto, device, emulate) = self.mice[cur]
if device == "ttyS":
self.setCurrent(self.serialDevice, cur, emulate, recenter=0)
else:
self.setCurrent(device, cur, emulate, recenter=0)
def setupDeviceList(self):
deviceList = ((_("/dev/ttyS0 (COM1 under DOS)"), "ttyS0" ),
(_("/dev/ttyS1 (COM2 under DOS)"), "ttyS1" ),
(_("/dev/ttyS2 (COM3 under DOS)"), "ttyS2" ),
(_("/dev/ttyS3 (COM4 under DOS)"), "ttyS3" ))
self.devstore = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_STRING)
for descrip, dev in deviceList:
iter = self.devstore.append()
self.devstore.set_value(iter, 0, descrip)
self.devstore.set_value(iter, 1, dev)
self.devstore.set_sort_column_id(0, gtk.SORT_ASCENDING)
self.devview = gtk.TreeView(self.devstore)
col = gtk.TreeViewColumn(_("_Device"), gtk.CellRendererText(), text=0)
self.devview.append_column(col)
selection = self.devview.get_selection()
selection.connect("changed", self.selectDeviceType)
def setupMice(self):
self.mousestore = gtk.TreeStore(gobject.TYPE_STRING,
gobject.TYPE_STRING)
# go though and find all the makes that have more than 1 mouse
toplevels = {}
for key, value in self.mice.items():
(make, model, gpmproto, xproto, device, emulate3) = value
make = _(make)
if toplevels.has_key(make):
toplevels[make] = toplevels[make] + 1
else:
toplevels[make] = 1
# for each toplevel that has more than one mouse, make a parent
# node for it.
for make, count in toplevels.items():
if count > 1:
parent = self.mousestore.append(None)
self.mousestore.set_value(parent, 0, make)
toplevels[make] = parent
else:
del toplevels[make]
# now go and add each child node
for key, value in self.mice.items():
(make, model, gpmproto, xproto, device, emulate3) = value
make = _(make)
model = _(model)
parent = toplevels.get(make)
iter = self.mousestore.append(parent)
# if there is a parent, put only the model in the tree
if parent:
self.mousestore.set_value(iter, 0, model)
else:
# otherwise, put the full device there.
self.mousestore.set_value(iter, 0, "%s %s" % (make, model))
self.mousestore.set_value(iter, 1, key)
self.mousestore.set_sort_column_id(0, gtk.SORT_ASCENDING)
self.mouseview = gtk.TreeView(self.mousestore)
self.mouseview.set_property("headers-visible", True)
col = gtk.TreeViewColumn(_("_Model"), gtk.CellRendererText(), text=0)
self.mouseview.append_column(col)
selection = self.mouseview.get_selection()
selection.connect("changed", self.selectMouseType)
def setCurrent(self, currentDev, currentMouse, emulate3, recenter=1):
self.ignoreEvents = 1
self.currentMouse = currentMouse
parent = None
iter = self.mousestore.get_iter_first()
fndmouse = 0
# iterate over the list, looking for the current mouse selection
while iter:
# if this is a parent node, get the first child and iter over them
if self.mousestore.iter_has_child(iter):
parent = iter
iter = self.mousestore.iter_children(parent)
continue
# if it's not a parent node and the mouse matches, select it.
elif self.mousestore.get_value(iter, 1) == currentMouse:
if parent:
path = self.mousestore.get_path(parent)
self.mouseview.expand_row(path, True)
selection = self.mouseview.get_selection()
selection.unselect_all()
selection.select_iter(iter)
path = self.mousestore.get_path(iter)
col = self.mouseview.get_column(0)
self.mouseview.set_cursor(path, col, False)
if recenter:
self.mouseview.scroll_to_cell(path, col, True,
0.5, 0.5)
fndmouse = 1
break
# get the next row.
iter = self.mousestore.iter_next(iter)
# if there isn't a next row and we had a parent, go to the node
# after the parent we've just gotten the children of.
if not iter and parent:
parent = self.mousestore.iter_next(parent)
iter = parent
# set up the device list if we have a serial port
if currentDev and currentDev.startswith('ttyS'):
self.serialDevice = currentDev
selection = self.devview.get_selection()
path = (int(self.serialDevice[4]),)
selection.select_path(path)
col = self.devview.get_column(0)
self.devview.set_cursor(path, col, False)
if recenter:
self.devview.scroll_to_cell(path, col, True, 0.5, 0.5)
self.ics.setNextEnabled(True)
self.devview.set_sensitive(True)
elif currentDev:
self.devview.get_selection().unselect_all();
self.devview.set_sensitive(False)
self.ics.setNextEnabled(True)
else:
# XXX - see if this is the 'No - mouse' case
if fndmouse:
cur = self.mousestore.get_value(iter, 1)
(make, model, gpmproto, xdev, device, emulate3) = self.mice[cur]
else:
xdev = None
if xdev == "none":
self.devview.get_selection().unselect_all();
self.devview.set_sensitive(False)
self.ics.setNextEnabled(True)
else:
# otherwise disable the list
self.devview.get_selection().unselect_all();
self.serialDevice = None
self.ics.setNextEnabled(False)
self.devview.set_sensitive(True)
self.emulate3.set_active(emulate3)
self.ignoreEvents = 0
# MouseWindow tag="mouse"
def getScreen(self, mouse):
self.mouse = mouse
self.flags = flags
self.ignoreEvents = 0
self.mice = mouse.mouseModels
self.serialDevice = None
currentDev = mouse.getDevice()
currentMouse, emulate3 = mouse.getMouse()
# populate the big widgets with the available selections
self.setupMice()
self.setupDeviceList()
self.emulate3 = gtk.CheckButton(_("_Emulate 3 buttons"))
self.setCurrent(currentDev, currentMouse, emulate3)
# set up the box for this screen
box = gtk.VBox(False, 5)
box.set_border_width(5)
# top header, includes graphic and instructions
hbox = gtk.HBox(False, 5)
pix = gui.readImageFromFile ("gnome-mouse.png")
if pix:
a = gtk.Alignment()
a.add(pix)
a.set(0.0, 0.0, 0.0, 0.0)
hbox.pack_start(a, False)
label = gui.MnemonicLabel(_("Select the appropriate mouse for the system."))
label.set_line_wrap(True)
label.set_size_request(350, -1)
hbox.pack_start(label, False)
box.pack_start(hbox, False)
# next is the mouse tree
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
sw.add(self.mouseview)
box.pack_start(sw)
label.set_mnemonic_widget(self.mouseview)
gui.setupTreeViewFixupIdleHandler(self.mouseview, self.mousestore)
# then the port list
serial_sw = gtk.ScrolledWindow()
serial_sw.set_shadow_type(gtk.SHADOW_IN)
serial_sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
serial_sw.add(self.devview)
box.pack_start(serial_sw, False)
# finally the emulate 3 buttons
box.pack_start(self.emulate3, False)
return box
|