Coverage Report - orca.orca_gui_prefs

ModuleCoverage %
orca.orca_gui_prefs
44%
1
# Orca
2
#
3
# Copyright 2006-2007 Sun Microsystems Inc.
4
#
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Library General Public
7
# License as published by the Free Software Foundation; either
8
# version 2 of the License, or (at your option) any later version.
9
#
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# Library General Public License for more details.
14
#
15
# You should have received a copy of the GNU Library General Public
16
# License along with this library; if not, write to the
17
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
# Boston, MA 02111-1307, USA.
19
20
# TODO:
21
#
22
# - Improve reclaimation of "old" speech servers in _setupSpeechServers().
23
# - Implement the Help button callback.
24
25 1
"""Displays a GUI for the user to set Orca preferences."""
26
27 1
__id__        = "$Id: orca_gui_prefs.py 1973 2007-02-02 23:22:35Z wwalker $"
28 1
__version__   = "$Revision: 1973 $"
29 1
__date__      = "$Date: 2007-02-02 15:22:35 -0800 (Fri, 02 Feb 2007) $"
30 1
__copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
31 1
__license__   = "LGPL"
32
33 1
import os
34 1
import commands
35 1
import sys
36 1
import debug
37 1
import gettext
38 1
import gtk
39 1
import gtk.glade
40 1
import gobject
41 1
import pango   # for ellipsize property constants of CellRendererText
42 1
import locale
43
44 1
import acss
45 1
import orca
46 1
import orca_glade
47 1
import orca_prefs
48 1
import orca_state
49 1
import platform
50 1
import settings
51 1
import default    # for the default keyBindings
52 1
import input_event
53 1
import keybindings
54 1
import braille
55 1
import speech
56 1
import speechserver
57
58 1
from orca_i18n import _  # for gettext support
59
60 1
OS = None
61
62 1
(HANDLER, DESCRIP, MOD_MASK1, MOD_USED1, KEY1, TEXT1, MOD_MASK2, MOD_USED2, KEY2, TEXT2, MODIF, EDITABLE) = range(12)
63
64
65 2
class orcaSetupGUI(orca_glade.GladeWrapper):
66
67 1
    def _init(self):
68
        """Initialize the Orca configuration GUI. Read the users current
69
        set of preferences and set the GUI state to match. Setup speech
70
        support and populate the combo box lists on the Speech Tab pane
71
        accordingly.
72
        """
73
74 1
        self.prefsDict = orca_prefs.readPreferences()
75
76
        # ***** Key Bindings treeview initialization *****
77
78 1
        self.keyBindView = self.widgets.get_widget("keyBindingsTreeview")
79 1
        self.keyBindingsModel = gtk.TreeStore(
80
            gobject.TYPE_STRING,  # Handler name
81 1
            gobject.TYPE_STRING,  # Human Readable Description
82 1
            gobject.TYPE_STRING,  # Modifier mask 1
83 1
            gobject.TYPE_STRING,  # Used Modifiers 1
84 1
            gobject.TYPE_STRING,  # Modifier key name 1
85 1
            gobject.TYPE_STRING,  # Text of the Key Binding Shown 1
86 1
            gobject.TYPE_STRING,  # Modifier mask 2
87 1
            gobject.TYPE_STRING,  # Used Modifiers 2
88 1
            gobject.TYPE_STRING,  # Modifier key name 2
89 1
            gobject.TYPE_STRING,  # Text of the Key Binding Shown 2
90 1
            gobject.TYPE_BOOLEAN, # Key Modified by User
91 1
            gobject.TYPE_BOOLEAN) # Row with fields editable or not
92 1
        self.keyBindView.set_model(self.keyBindingsModel)
93 1
        self.keyBindView.set_headers_visible(True)
94
95
        # Treeview Column Implementation:
96
        #      (HANDLER,    DESCRIP,
97
        #       MOD_MASK1,  MOD_USED1,  KEY1,   TEXT1,
98
        #       MOD_MASK2,  MOD_USED2,  KEY2,   TEXT2,
99
        #       MODIF,      EDITABLE)
100
101
        # HANDLER
102
        #
103 1
        column = gtk.TreeViewColumn(_("Handler"),
104 1
                                    gtk.CellRendererText(),
105 1
                                    text=HANDLER)
106 1
        column.set_resizable(True)
107 1
        column.set_visible(False)
108 1
        column.set_sort_column_id(HANDLER)
109 1
        self.keyBindView.append_column(column)
110
111
        # DESCRIP
112
        #
113 1
        rendererText = gtk.CellRendererText()
114 1
        rendererText.set_property("ellipsize", pango.ELLIPSIZE_END)
115 1
        column = gtk.TreeViewColumn(_("Function"), rendererText, text=DESCRIP)
116 1
        column.set_resizable(True)
117 1
        column.set_min_width(380)
118 1
        column.set_sort_column_id(DESCRIP)
119 1
        self.keyBindView.append_column(column)
120
121
        # MOD_MASK1
122
        #
123 1
        column = gtk.TreeViewColumn(_("Mod.Mask 1"),
124 1
                                    gtk.CellRendererText(),
125 1
                                    text=MOD_MASK1)
126 1
        column.set_visible(False)
127 1
        column.set_resizable(True)
128 1
        column.set_sort_column_id(MOD_MASK1)
129 1
        self.keyBindView.append_column(column)
130
131
        # MOD_USED1
132
        #
133 1
        column = gtk.TreeViewColumn(_("Use Mod.1"),
134 1
                                    gtk.CellRendererText(),
135 1
                                    text=MOD_USED1)
136 1
        column.set_visible(False)
137 1
        column.set_resizable(True)
138 1
        column.set_sort_column_id(MOD_USED1)
139 1
        self.keyBindView.append_column(column)
140
141
        # KEY1
142
        #
143 1
        column = gtk.TreeViewColumn(_("Key1"),
144 1
                                    gtk.CellRendererText(),
145 1
                                    text=KEY1)
146 1
        column.set_resizable(True)
147 1
        column.set_visible(False)
148 1
        column.set_sort_column_id(KEY1)
149 1
        self.keyBindView.append_column(column)
150
151
        # TEXT1
152
        #
153 1
        rendererText = gtk.CellRendererText()
154 1
        rendererText.connect("editing-started",
155 1
                             self.editingKey,
156 1
                             self.keyBindingsModel)
157 1
        rendererText.connect('edited',
158 1
                             self.editedKey,
159 1
                             self.keyBindingsModel,
160 1
                             MOD_MASK1, MOD_USED1, KEY1, TEXT1)
161 1
        column = gtk.TreeViewColumn(_("Key Binding"),
162 1
                                    rendererText,
163 1
                                    text=TEXT1,
164 1
                                    editable=EDITABLE)
165 1
        column.set_resizable(True)
166 1
        column.set_sort_column_id(TEXT1)
167 1
        self.keyBindView.append_column(column)
168
169
        # MOD_MASK2
170
        #
171 1
        column = gtk.TreeViewColumn(_("Mod.Mask 2"),
172 1
                                    gtk.CellRendererText(),
173 1
                                    text=MOD_MASK2)
174 1
        column.set_visible(False)
175 1
        column.set_resizable(True)
176 1
        column.set_sort_column_id(MOD_MASK2)
177 1
        self.keyBindView.append_column(column)
178
179
        # MOD_USED2
180
        #
181 1
        column = gtk.TreeViewColumn(_("Use Mod.2"),
182 1
                                    gtk.CellRendererText(),
183 1
                                    text=MOD_USED2)
184 1
        column.set_visible(False)
185 1
        column.set_resizable(True)
186 1
        column.set_sort_column_id(MOD_USED2)
187 1
        self.keyBindView.append_column(column)
188
189
        # KEY2
190
        #
191 1
        column = gtk.TreeViewColumn(_("Key2"), rendererText, text=KEY2)
192 1
        column.set_resizable(True)
193 1
        column.set_visible(False)
194 1
        column.set_sort_column_id(KEY2)
195 1
        self.keyBindView.append_column(column)
196
197
        # TEXT2
198
        #
199 1
        rendererText = gtk.CellRendererText()
200 1
        rendererText.connect("editing-started",
201 1
                             self.editingKey,
202 1
                             self.keyBindingsModel)
203 1
        rendererText.connect('edited',
204 1
                             self.editedKey,
205 1
                             self.keyBindingsModel,
206 1
                             MOD_MASK2, MOD_USED2, KEY2, TEXT2)
207 1
        column = gtk.TreeViewColumn(_("Alternate"),
208 1
                                    rendererText,
209 1
                                    text=TEXT2,
210 1
                                    editable=EDITABLE)
211 1
        column.set_resizable(True)
212 1
        column.set_sort_column_id(TEXT2)
213 1
        self.keyBindView.append_column(column)
214
215
        # MODIF
216
        #
217 1
        rendererToggle = gtk.CellRendererToggle()
218 1
        rendererToggle.connect('toggled',
219 1
                               self.keyModifiedToggle,
220 1
                               self.keyBindingsModel,
221 1
                               MODIF)
222 1
        column = gtk.TreeViewColumn(_("Modified"),
223 1
                                    rendererToggle,
224 1
                                    active=MODIF,
225 1
                                    activatable=EDITABLE)
226
        #column.set_visible(False)
227 1
        column.set_resizable(True)
228 1
        column.set_sort_column_id(MODIF)
229 1
        self.keyBindView.append_column(column)
230
231
        # EDITABLE
232
        #
233 1
        rendererToggle = gtk.CellRendererToggle()
234 1
        rendererToggle.set_property('activatable',False)
235 1
        column = gtk.TreeViewColumn(_("Modified"),
236 1
                                    rendererToggle,
237 1
                                    active=EDITABLE)
238 1
        column.set_visible(False)
239 1
        column.set_resizable(True)
240 1
        column.set_sort_column_id(EDITABLE)
241 1
        self.keyBindView.append_column(column)
242
243
        # Populates the treeview with all the keybindings:
244
        #
245 1
        self._populateKeyBindings()
246
247 1
        self.keyBindView.show()
248
249 1
        self.window = self.widgets.get_widget("orcaSetupWindow")
250 1
        self.window.resize(790,580);
251
252 1
        self._setKeyEchoItems()
253
254 1
        self.speechSystemsModel  = self._initComboBox(self.speechSystems)
255 1
        self.speechServersModel  = self._initComboBox(self.speechServers)
256 1
        self.speechFamiliesModel = self._initComboBox(self.speechFamilies)
257 1
        self._initSpeechState()
258
259 0
        self._initGUIState()
260
261 1
    def _getACSSForVoiceType(self, voiceType):
262
        """Return the ACSS value for the the given voice type.
263
264
        Arguments:
265
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink",
266
        where the string is localized).
267
268
        Returns the voice dictionary for the given voice type.
269
        """
270
271 0
        if voiceType == _("Default"):
272 0
            voiceACSS = self.defaultVoice
273 0
        elif voiceType == _("Uppercase"):
274 0
            voiceACSS = self.uppercaseVoice
275 0
        elif voiceType == _("Hyperlink"):
276 0
            voiceACSS = self.hyperlinkVoice
277
        else:
278 0
            voiceACSS = self.defaultVoice
279
280 0
        return voiceACSS
281
282 1
    def _getKeyValueForVoiceType(self, voiceType, key, useDefault=True):
283
        """Look for the value of the given key in the voice dictionary
284
           for the given voice type.
285
286
        Arguments:
287
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
288
        - key: the key to look for in the voice dictionary.
289
        - useDefault: if True, and the key isn't found for the given voice
290
                      type, the look for it in the default voice dictionary
291
                      as well.
292
293
        Returns the value of the given key, or None if it's not set.
294
        """
295
296 0
        if voiceType == _("Default"):
297 0
            voice = self.defaultVoice
298 0
        elif voiceType == _("Uppercase"):
299 0
            voice = self.uppercaseVoice
300 0
            if not voice.has_key(key):
301 0
                if not useDefault:
302 0
                    return None
303 0
                voice = self.defaultVoice
304 0
        elif voiceType == _("Hyperlink"):
305 0
            voice = self.hyperlinkVoice
306 0
            if not voice.has_key(key):
307 0
                if not useDefault:
308 0
                    return None
309 0
                voice = self.defaultVoice
310
        else:
311 0
            voice = self.defaultVoice
312
313 0
        if voice.has_key(key):
314 0
            return voice[key]
315
        else:
316 0
            return None
317
318 1
    def _getFamilyNameForVoiceType(self, voiceType):
319
        """Gets the name of the voice family for the given voice type.
320
321
        Arguments:
322
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
323
324
        Returns the name of the voice family for the given voice type,
325
        or None if not set.
326
        """
327
328 0
        familyName = None
329 0
        family = self._getKeyValueForVoiceType(voiceType, acss.ACSS.FAMILY)
330
331 0
        if family and family.has_key(speechserver.VoiceFamily.NAME):
332 0
            familyName = family[speechserver.VoiceFamily.NAME]
333
334 0
        return familyName
335
336 1
    def _setFamilyNameForVoiceType(self, voiceType, name, language):
337
        """Sets the name of the voice family for the given voice type.
338
339
        Arguments:
340
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
341
        - name: the name of the voice family to set.
342
        - language: the locale of the voice family to set.
343
        """
344
345 0
        family = self._getKeyValueForVoiceType(voiceType,
346 0
                                               acss.ACSS.FAMILY,
347 0
                                               False)
348 0
        if family:
349 0
            family[speechserver.VoiceFamily.NAME] = name
350 0
            family[speechserver.VoiceFamily.LOCALE] = language
351
        else:
352 0
            voiceACSS = self._getACSSForVoiceType(voiceType)
353 0
            voiceACSS[acss.ACSS.FAMILY] = {}
354 0
            voiceACSS[acss.ACSS.FAMILY][speechserver.VoiceFamily.NAME] = name
355 0
            voiceACSS[acss.ACSS.FAMILY][speechserver.VoiceFamily.LOCALE] = language
356
357
        #voiceACSS = self._getACSSForVoiceType(voiceType)
358
        #settings.voices[voiceType] = voiceACSS
359
360 1
    def _getRateForVoiceType(self, voiceType):
361
        """Gets the speaking rate value for the given voice type.
362
363
        Arguments:
364
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
365
366
        Returns the rate value for the given voice type, or None if
367
        not set.
368
        """
369
370 0
        return self._getKeyValueForVoiceType(voiceType, acss.ACSS.RATE)
371
372 1
    def _setRateForVoiceType(self, voiceType, value):
373
        """Sets the speaking rate value for the given voice type.
374
375
        Arguments:
376
        - voiceType: the voice type (Default, Uppercase or Hyperlink).
377
        - value: the rate value to set.
378
        """
379
380 0
        voiceACSS = self._getACSSForVoiceType(voiceType)
381 0
        voiceACSS[acss.ACSS.RATE] = value
382
        #settings.voices[voiceType] = voiceACSS
383
384 1
    def _getPitchForVoiceType(self, voiceType):
385
        """Gets the pitch value for the given voice type.
386
387
        Arguments:
388
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
389
390
        Returns the pitch value for the given voice type, or None if
391
        not set.
392
        """
393
394 0
        return self._getKeyValueForVoiceType(voiceType,
395 0
                                             acss.ACSS.AVERAGE_PITCH)
396
397 1
    def _setPitchForVoiceType(self, voiceType, value):
398
        """Sets the pitch value for the given voice type.
399
400
        Arguments:
401
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
402
        - value: the pitch value to set.
403
        """
404
405 0
        voiceACSS = self._getACSSForVoiceType(voiceType)
406 0
        voiceACSS[acss.ACSS.AVERAGE_PITCH] = value
407
        #settings.voices[voiceType] = voiceACSS
408
409 1
    def _getVolumeForVoiceType(self, voiceType):
410
        """Gets the volume (gain) value for the given voice type.
411
412
        Arguments:
413
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
414
415
        Returns the volume (gain) value for the given voice type, or
416
        None if not set.
417
        """
418
419 0
        return self._getKeyValueForVoiceType(voiceType, acss.ACSS.GAIN)
420
421 1
    def _setVolumeForVoiceType(self, voiceType, value):
422
        """Sets the volume (gain) value for the given voice type.
423
424
        Arguments:
425
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
426
        - value: the volume (gain) value to set.
427
        """
428
429 0
        voiceACSS = self._getACSSForVoiceType(voiceType)
430 0
        voiceACSS[acss.ACSS.GAIN] = value
431
        #settings.voices[voiceType] = voiceACSS
432
433 1
    def _setVoiceSettingsForVoiceType(self, voiceType):
434
        """Sets the family, rate, pitch and volume GUI components based
435
        on the given voice type.
436
437
        Arguments:
438
        - voiceType: the voice type ("Default", "Uppercase" or "Hyperlink").
439
        """
440
441 0
        familyName = self._getFamilyNameForVoiceType(voiceType)
442 0
        self._setSpeechFamiliesChoice(familyName)
443
444 0
        rate = self._getRateForVoiceType(voiceType)
445 0
        if rate:
446 0
            self.rateScale.set_value(rate)
447
448 0
        pitch = self._getPitchForVoiceType(voiceType)
449 0
        if pitch:
450 0
            self.pitchScale.set_value(pitch)
451
452 0
        volume = self._getVolumeForVoiceType(voiceType)
453 0
        if volume:
454 0
            self.volumeScale.set_value(volume)
455
456 1
    def _setSpeechFamiliesChoice(self, familyName):
457
        """Sets the active item in the families ("Person:") combo box
458
        to the given family name.
459
460
        Arguments:
461
        - families: the list of available voice families.
462
        - familyName: the family name to use to set the active combo box item.
463
        """
464
465 0
        if len(self.speechFamiliesChoices) == 0:
466 0
            return
467
468 0
        valueSet = False
469 0
        i = 0
470 0
        for family in self.speechFamiliesChoices:
471 0
            name = family[speechserver.VoiceFamily.NAME]
472 0
            if name == familyName:
473 0
                self.speechFamilies.set_active(i)
474 0
                self.speechFamiliesChoice = self.speechFamiliesChoices[i]
475 0
                valueSet = True
476 0
                break
477 0
            i += 1
478
479 0
        if not valueSet:
480 0
            debug.println(debug.LEVEL_FINEST,
481 0
                          "Could not find speech family match for %s" \
482
                          % familyName)
483 0
            self.speechFamilies.set_active(0)
484 0
            self.speechFamiliesChoice = self.speechFamiliesChoices[0]
485
486 1
    def _setupFamilies(self):
487
        """Gets the list of voice families for the current speech server.
488
        If there aren't any families, set the 'enableSpeech' to False and
489
        return, otherwise get the information associated with each voice
490
        family and add an entry for it to the families GtkComboBox list.
491
        """
492
493 0
        self.speechFamiliesModel.clear()
494 0
        families = self.speechServersChoice.getVoiceFamilies()
495 0
        self.speechFamiliesChoices = []
496 0
        if len(families) == 0:
497 0
            debug.println(debug.LEVEL_SEVERE, _("Speech not available."))
498 0
            debug.printStack(debug.LEVEL_FINEST)
499 0
            self.prefsDict["enableSpeech"] = False
500 0
            self.speechFamiliesChoice = None
501 0
            return
502
503 0
        i = 0
504 0
        for family in families:
505 0
            name = family[speechserver.VoiceFamily.NAME] \
506
                   + " (%s)" % family[speechserver.VoiceFamily.LOCALE]
507 0
            self.speechFamiliesChoices.append(family)
508 0
            self.speechFamiliesModel.append((i, name))
509 0
            i += 1
510
511
        # The family name will be selected as part of selecting the
512
        # voice type.  Whenever the families change, we'll reset the
513
        # voice type selection to the first one ("Default").
514
        #
515 0
        self.voiceTypes.set_active(0)
516 0
        voiceType = self.voiceTypes.get_active_text()
517 0
        self._setVoiceSettingsForVoiceType(voiceType)
518
519 1
    def _setSpeechServersChoice(self, serverInfo):
520
        """Sets the active item in the speech servers combo box to the
521
        given server.
522
523
        Arguments:
524
        - serversChoices: the list of available speech servers.
525
        - serverInfo: the speech server to use to set the active combo
526
        box item.
527
        """
528
529 0
        if len(self.speechServersChoices) == 0:
530 0
            return
531
532
        # We'll fallback to whatever we happen to be using in the event
533
        # that this preference has never been set.
534
        #
535 0
        if not serverInfo:
536 0
            serverInfo = speech._speechserver.getInfo()
537
538 0
        valueSet = False
539 0
        i = 0
540 0
        for server in self.speechServersChoices:
541 0
            if serverInfo == server.getInfo():
542 0
                self.speechServers.set_active(i)
543 0
                self.speechServersChoice = server
544 0
                valueSet = True
545 0
                break
546 0
            i += 1
547
548 0
        if not valueSet:
549 0
            debug.println(debug.LEVEL_FINEST,
550 0
                          "Could not find speech server match for %s" \
551
                          %  repr(serverInfo))
552 0
            self.speechServers.set_active(0)
553 0
            self.speechServersChoice = self.speechServersChoices[0]
554
555 0
        self._setupFamilies()
556
557 1
    def _setupSpeechServers(self):
558
        """Gets the list of speech servers for the current speech factory.
559
        If there aren't any servers, set the 'enableSpeech' to False and
560
        return, otherwise get the information associated with each speech
561
        server and add an entry for it to the speechServers GtkComboBox list.
562
        Set the current choice to be the first item.
563
        """
564
565 0
        self.speechServersModel.clear()
566 0
        self.speechServersChoices = \
567
                self.speechSystemsChoice.SpeechServer.getSpeechServers()
568 0
        if len(self.speechServersChoices) == 0:
569 0
            debug.println(debug.LEVEL_SEVERE, _("Speech not available."))
570 0
            debug.printStack(debug.LEVEL_FINEST)
571 0
            self.prefsDict["enableSpeech"] = False
572 0
            self.speechServersChoice = None
573 0
            self.speechFamiliesChoices = []
574 0
            self.speechFamiliesChoice = None
575 0
            return
576
577 0
        i = 0
578 0
        for server in self.speechServersChoices:
579 0
            name = server.getInfo()[0]
580 0
            self.speechServersModel.append((i, name))
581 0
            i += 1
582
583 0
        self._setSpeechServersChoice(self.prefsDict["speechServerInfo"])
584
585 0
        debug.println(
586
            debug.LEVEL_FINEST,
587 0
            "orca_gui_prefs._setupSpeechServers: speechServersChoice: %s" \
588
            % self.speechServersChoice.getInfo())
589
590 1
    def _setSpeechSystemsChoice(self, systemName):
591
        """Set the active item in the speech systems combo box to the
592
        given system name.
593
594
        Arguments:
595
        - factoryChoices: the list of available speech factories (systems).
596
        - systemName: the speech system name to use to set the active combo
597
        box item.
598
        """
599
600 1
        if len(self.speechSystemsChoices) == 0:
601 0
            return
602
603 1
        valueSet = False
604 1
        i = 0
605 1
        for speechSystem in self.speechSystemsChoices:
606 1
            name = speechSystem.__name__
607 1
            if name.endswith(systemName):
608 0
                self.speechSystems.set_active(i)
609 0
                self.speechSystemsChoice = self.speechSystemsChoices[i]
610 0
                valueSet = True
611 0
                break
612 0
            i += 1
613
614 0
        if not valueSet:
615 0
            debug.println(debug.LEVEL_FINEST,
616 0
                          "Could not find speech system match for %s" \
617
                          % systemName)
618 0
            self.speechSystems.set_active(0)
619 0
            self.speechSystemsChoice = self.speechSystemsChoices[0]
620
621 0
        self._setupSpeechServers()
622
623 1
    def _setupSpeechSystems(self, factories):
624
        """Sets up the speech systems combo box and sets the selection
625
        to the preferred speech system.
626
627
        Arguments:
628
        -factories: the list of known speech factories (working or not)
629
        """
630 1
        self.speechSystemsModel.clear()
631 1
        self.workingFactories = []
632 3
        for factory in factories:
633 2
            try:
634 2
                servers = factory.SpeechServer.getSpeechServers()
635 1
                if len(servers):
636 1
                    self.workingFactories.append(factory)
637 1
            except:
638 1
                debug.printException(debug.LEVEL_FINEST)
639 1
                pass
640
641 1
        self.speechSystemsChoices = []
642 1
        if len(self.workingFactories) == 0:
643 0
            debug.println(debug.LEVEL_SEVERE, _("Speech not available."))
644 0
            debug.printStack(debug.LEVEL_FINEST)
645 0
            self.prefsDict["enableSpeech"] = False
646 0
            self.speechSystemsChoice = None
647 0
            self.speechServersChoices = []
648 0
            self.speechServersChoice = None
649 0
            self.speechFamiliesChoices = []
650 0
            self.speechFamiliesChoice = None
651 0
            return
652
653 1
        i = 0
654 2
        for workingFactory in self.workingFactories:
655 1
            self.speechSystemsChoices.append(workingFactory)
656 1
            name = workingFactory.SpeechServer.getFactoryName()
657 1
            self.speechSystemsModel.append((i, name))
658 1
            i += 1
659
660 1
        self._setSpeechSystemsChoice(self.prefsDict["speechServerFactory"])
661
662 0
        debug.println(
663
            debug.LEVEL_FINEST,
664 0
            "orca_gui_prefs._setupSpeechSystems: speechSystemsChoice: %s" \
665
            % self.speechSystemsChoice)
666
667 1
    def _initSpeechState(self):
668
        """Initialize the various speech components.
669
        """
670
671 1
        voices = self.prefsDict["voices"]
672 1
        self.defaultVoice   = acss.ACSS(voices[settings.DEFAULT_VOICE])
673 1
        self.uppercaseVoice = acss.ACSS(voices[settings.UPPERCASE_VOICE])
674 1
        self.hyperlinkVoice = acss.ACSS(voices[settings.HYPERLINK_VOICE])
675
676
        # Just a note on general naming pattern:
677
        #
678
        # *        = The name of the combobox
679
        # *Model   = the name of the comobox model
680
        # *Choices = the Orca/speech python objects
681
        # *Choice  = a value from *Choices
682
        #
683
        # Where * = speechSystems, speechServers, speechFamilies
684
        #
685 1
        factories = speech.getSpeechServerFactories()
686 1
        if len(factories) == 0:
687 0
            self.prefsDict["enableSpeech"] = False
688 0
            return
689
690 1
        speech.init()
691
692
        # This cascades into systems->servers->voice_type->families...
693
        #
694 1
        self.initializingSpeech = True
695 1
        self._setupSpeechSystems(factories)
696 0
        self.initializingSpeech = False
697
698 1
    def _initGUIState(self):
699
        """Adjust the settings of the various components on the
700
        configuration GUI depending upon the users preferences.
701
        """
702
703 0
        prefs = self.prefsDict
704
705
        # Speech pane.
706
        #
707 0
        enable = prefs["enableSpeech"]
708 0
        self.speechSupportCheckbutton.set_active(enable)
709 0
        self.speechTable.set_sensitive(enable)
710
711 0
        if prefs["verbalizePunctuationStyle"] == \
712
                               settings.PUNCTUATION_STYLE_NONE:
713 0
            self.noneButton.set_active(True)
714 0
        elif prefs["verbalizePunctuationStyle"] == \
715
                               settings.PUNCTUATION_STYLE_SOME:
716 0
            self.someButton.set_active(True)
717 0
        elif prefs["verbalizePunctuationStyle"] == \
718
                               settings.PUNCTUATION_STYLE_MOST:
719 0
            self.mostButton.set_active(True)
720
        else:
721 0
            self.allButton.set_active(True)
722
723 0
        if prefs["speechVerbosityLevel"] == settings.VERBOSITY_LEVEL_BRIEF:
724 0
            self.speechBriefButton.set_active(True)
725
        else:
726 0
            self.speechVerboseButton.set_active(True)
727
728 0
        if prefs["readTableCellRow"]:
729 0
            self.rowSpeechButton.set_active(True)
730
        else:
731 0
            self.cellSpeechButton.set_active(True)
732
733 0
        self.speechIndentationCheckbutton.set_active(\
734
            prefs["enableSpeechIndentation"])
735
736 0
        self.speakBlankLinesCheckButton.set_active(\
737
            prefs["speakBlankLines"])
738
739
        # Braille pane.
740
        #
741 0
        self.brailleSupportCheckbutton.set_active(prefs["enableBraille"])
742 0
        self.brailleMonitorCheckbutton.set_active(prefs["enableBrailleMonitor"])
743 0
        state = prefs["brailleRolenameStyle"] == \
744
                            settings.BRAILLE_ROLENAME_STYLE_SHORT
745 0
        self.abbrevRolenames.set_active(state)
746 0
        if prefs["brailleVerbosityLevel"] == settings.VERBOSITY_LEVEL_BRIEF:
747 0
            self.brailleBriefButton.set_active(True)
748
        else:
749 0
            self.brailleVerboseButton.set_active(True)
750
751
        # Key Echo pane.
752
        #
753 0
        self.keyEchoCheckbutton.set_active(prefs["enableKeyEcho"])
754 0
        self.printableCheckbutton.set_active(prefs["enablePrintableKeys"])
755 0
        self.modifierCheckbutton.set_active(prefs["enableModifierKeys"])
756 0
        self.lockingCheckbutton.set_active(prefs["enableLockingKeys"])
757 0
        self.functionCheckbutton.set_active(prefs["enableFunctionKeys"])
758 0
        self.actionCheckbutton.set_active(prefs["enableActionKeys"])
759 0
        self.echoByWordCheckbutton.set_active(prefs["enableEchoByWord"])
760
761
        # Magnifier pane.
762
        #
763
        # Set the sensitivity of the items on the magnifier pane, depending
764
        # upon whether the "Enable Magnifier" checkbox is checked.
765
        #
766 0
        enable = prefs["enableMagnifier"]
767 0
        self.magnifierSupportCheckbutton.set_active(enable)
768 0
        self.magnifierTable.set_sensitive(enable)
769
770
        # Get the 'Cursor on/off' preference and set the checkbox accordingly.
771
        #
772 0
        value = prefs["enableMagCursor"]
773 0
        self.magCursorOnOffCheckButton.set_active(value)
774
775
        # Get the 'Explicit cursor size' preference and set the checkbox
776
        # accordingly. If the value is not checked, then the cursor size
777
        # spin button and label need to be set insensitive.
778
        #
779 0
        explicitSizeChecked = prefs["enableMagCursorExplicitSize"]
780 0
        self.magCursorSizeCheckButton.set_active(explicitSizeChecked)
781 0
        self.magCursorSizeSpinButton.set_sensitive(explicitSizeChecked)
782 0
        self.magCursorSizeLabel.set_sensitive(explicitSizeChecked)
783
784
        # Get the cursor size preference and set the cursor size spin
785
        # button value accordingly.
786
        #
787 0
        cursorSize = prefs["magCursorSize"]
788 0
        self.magCursorSizeSpinButton.set_value(cursorSize)
789
790
        # Get the cursor color preference and set the cursor color button
791
        # accordingly.
792
        #
793 0
        cursorColor = prefs["magCursorColor"]
794 0
        color = gtk.gdk.color_parse(cursorColor)
795 0
        self.magCursorColorButton.set_color(color)
796
797
        # Get the 'Cross-hair on/off' preference and set the checkbox
798
        # accordingly.
799
        #
800 0
        value = prefs["enableMagCrossHair"]
801 0
        self.magCrossHairOnOffCheckButton.set_active(value)
802
803
        # Get the 'Cross-hair clip on/off' preference and set the checkbox
804
        # accordingly.
805
        #
806 0
        value = prefs["enableMagCrossHairClip"]
807 0
        self.magCrossHairClipCheckButton.set_active(value)
808
809
        # Get the cross-hair size preference and set the cross-hair size
810
        # spin button value accordingly.
811
        #
812 0
        crosshairSize = prefs["magCrossHairSize"]
813 0
        self.magCrossHairSizeSpinButton.set_value(crosshairSize)
814
815
        # Get the width and the height of the screen.
816
        #
817 0
        self.screenWidth = gtk.gdk.screen_get_default().get_width()
818 0
        self.screenHeight = gtk.gdk.screen_get_default().get_height()
819
820
        # Get the zoomer placement top preference and set the top spin
821
        # button value accordingly. Set the top spin button "max size" to
822
        # the height of the screen.
823
        #
824 0
        topPosition = prefs["magZoomerTop"]
825 0
        self.magZoomerTopSpinButton.set_value(topPosition)
826 0
        self.magZoomerTopSpinButton.set_range(0, self.screenHeight)
827
828
        # Get the zoomer placement left preference and set the left spin
829
        # button value accordingly. Set the left spin button "max size" to
830
        # the width of the screen.
831
        #
832 0
        leftPosition = prefs["magZoomerLeft"]
833 0
        self.magZoomerLeftSpinButton.set_value(leftPosition)
834 0
        self.magZoomerLeftSpinButton.set_range(0, self.screenWidth)
835
836
        # Get the zoomer placement right preference and set the right spin
837
        # button value accordingly. Set the right spin button "max size" to
838
        # the width of the screen.
839
        #
840 0
        rightPosition = prefs["magZoomerRight"]
841 0
        self.magZoomerRightSpinButton.set_value(rightPosition)
842 0
        self.magZoomerRightSpinButton.set_range(0, self.screenWidth)
843
844
        # Get the zoomer placement bottom preference and set the bottom
845
        # spin button value accordingly. Set the bottom spin button "max size"
846
        # to the height of the screen.
847
        #
848 0
        bottomPosition = prefs["magZoomerBottom"]
849 0
        self.magZoomerBottomSpinButton.set_value(bottomPosition)
850 0
        self.magZoomerBottomSpinButton.set_range(0, self.screenHeight)
851
852
        # Get the zoom factor preference and set the zoom factor spin
853
        # button value accordingly.
854
        #
855 0
        zoomFactor = prefs["magZoomFactor"]
856 0
        self.magZoomFactorSpinButton.set_value(zoomFactor)
857
858
        # Get the 'Invert Colors' preference and set the checkbox accordingly.
859
        #
860 0
        value = prefs["enableMagZoomerColorInversion"]
861 0
        self.magInvertColorsCheckBox.set_active(value)
862
863
        # Get the smoothing preference and set the active value for the
864
        # smoothing combobox accordingly.
865
        #
866 0
        smoothingMode = prefs["magSmoothingMode"]
867 0
        if smoothingMode == settings.MAG_SMOOTHING_MODE_BILINEAR:
868 0
            mode = _("Bilinear")
869 0
        elif smoothingMode == settings.MAG_SMOOTHING_MODE_NONE:
870 0
            mode = _("None")
871
        else:
872 0
            mode = _("Bilinear")
873 0
        index = self._getComboBoxIndex(self.magSmoothingComboBox, mode)
874 0
        self.magSmoothingComboBox.set_active(index)
875
876
        # Get the mouse tracking preference and set the active value for
877
        # the mouse tracking combobox accordingly.
878
        #
879 0
        mouseTrackingMode = prefs["magMouseTrackingMode"]
880 0
        if mouseTrackingMode == settings.MAG_MOUSE_TRACKING_MODE_CENTERED:
881 0
            mode = _("Centered")
882 0
        elif mouseTrackingMode == settings.MAG_MOUSE_TRACKING_MODE_NONE:
883 0
            mode = _("None")
884 0
        elif mouseTrackingMode == settings.MAG_MOUSE_TRACKING_MODE_PROPORTIONAL:
885 0
            mode = _("Proportional")
886 0
        elif mouseTrackingMode == settings.MAG_MOUSE_TRACKING_MODE_PUSH:
887 0
            mode = _("Push")
888
        else:
889 0
            mode = _("Centered")
890 0
        index = self._getComboBoxIndex(self.magMouseTrackingComboBox, mode)
891 0
        self.magMouseTrackingComboBox.set_active(index)
892
893
        # Get the magnification source and target displays.
894
        #
895 0
        sourceDisplay = prefs["magSourceDisplay"]
896 0
        self.magSourceDisplayEntry.set_text(sourceDisplay)
897
898 0
        targetDisplay = prefs["magTargetDisplay"]
899 0
        self.magTargetDisplayEntry.set_text(targetDisplay)
900
901
        # General pane.
902
        #
903 0
        self.showMainWindowCheckButton.set_active(prefs["showMainWindow"])
904
905 0
        self.disableKeyGrabPref = commands.getoutput( \
906
                              "gconftool-2 --get /apps/gksu/disable-grab")
907 0
        if self.disableKeyGrabPref == "true":
908 0
            self.disableKeyGrabCheckButton.set_active(True)
909
        else:
910 0
            self.disableKeyGrabCheckButton.set_active(False)
911
912 0
        if prefs["keyboardLayout"] == settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP:
913 0
            self.generalDesktopButton.set_active(True)
914
        else:
915 0
            self.generalLaptopButton.set_active(True)
916
917 1
    def _getComboBoxIndex(self, combobox, str):
918
        """ For each of the entries in the given combo box, look for str.
919
            Return the index of the entry if str is found.
920
921
        Arguments:
922
        - combobox: the GtkComboBox to search.
923
        - str: the string to search for.
924
925
        Returns the index of the first entry in combobox with str, or
926
        0 if not found.
927
        """
928
929 0
        model = combobox.get_model()
930 0
        iter = model.get_iter_first()
931 0
        for i in range(0, len(model)):
932 0
            name = model.get_value(iter, 0)
933 0
            if name == str:
934 0
                return i
935 0
            iter = model.iter_next(iter)
936
937 0
        return 0
938
939 1
    def _showGUI(self):
940
        """Show the Orca configuration GUI window. This assumes that
941
        the GUI has already been created.
942
        """
943
944
        # We want the Orca preferences window to have focus when it is
945
        # shown. First try using the present() call. If this isn't present
946
        # in the version of pygtk that the user is using, fall back to
947
        # trying to set the current time on the Preferences window using
948
        # set_user_time. If that isn't found, then catch the exception and
949
        # fail gracefully.
950
        #
951 0
        self.orcaSetupWindow.realize()
952 0
        try:
953 0
            if settings.showMainWindow:
954 0
                self.orcaSetupWindow.present()
955
            else:
956 0
                self.orcaSetupWindow.window.set_user_time(\
957
                    orca_state.lastInputEventTimestamp)
958 0
        except:
959 0
            try:
960 0
                self.orcaSetupWindow.window.set_user_time(\
961
                    orca_state.lastInputEventTimestamp)
962 0
            except AttributeError:
963 0
                debug.printException(debug.LEVEL_FINEST)
964
965 0
        self.orcaSetupWindow.show()
966
967 1
    def _initComboBox(self, combobox):
968
        """Initialize the given combo box to take a list of int/str pairs.
969
970
        Arguments:
971
        - combobox: the GtkComboBox to initialize.
972
        """
973
974 3
        cell = gtk.CellRendererText()
975 3
        combobox.pack_start(cell, True)
976 3
        combobox.add_attribute(cell, 'text', 1)
977 3
        model = gtk.ListStore(int, str)
978 3
        combobox.set_model(model)
979
980 3
        return model
981
982 1
    def _setKeyEchoItems(self):
983
        """[In]sensitize the checkboxes for the various types of key echo,
984
        depending upon whether the value of the key echo check button is set.
985
        """
986
987 1
        enable = self.keyEchoCheckbutton.get_active()
988 1
        self.printableCheckbutton.set_sensitive(enable)
989 1
        self.modifierCheckbutton.set_sensitive(enable)
990 1
        self.lockingCheckbutton.set_sensitive(enable)
991 1
        self.functionCheckbutton.set_sensitive(enable)
992 1
        self.actionCheckbutton.set_sensitive(enable)
993
994 1
    def _say(self, text, stop=False):
995
        """If the text field is not None, speaks the given text, optionally
996
        interrupting anything currently being spoken.
997
998
        Arguments:
999
        - text: the text to print and speak
1000
        - stop: if True, interrupt any speech currently being spoken
1001
        """
1002
1003 0
        if stop:
1004 0
            speech.stop()
1005
1006 0
        speech.speak(text)
1007
1008 1
    def _createNode(self, appName):
1009
        """Create a new root node in the TreeStore model with the name of the
1010
            application.
1011
1012
        Arguments:
1013
        - appName: the name of the TreeStore Node (the same of the application)
1014
        """
1015
1016 2
        model = self.keyBindingsModel
1017
1018 2
        iter = model.append(None)
1019 2
        model.set(iter,
1020 2
                  DESCRIP, appName,
1021 2
                  MODIF, False)
1022
1023 2
        return iter
1024
1025 1
    def _getIterOf(self, appName):
1026
        """Returns the gtk.TreeIter of the TreeStore model
1027
        that matches the application name passed as argument
1028
1029
        Arguments:
1030
        - appName: a string with the name of the application of the node wanted
1031
                    it's the same that the field DESCRIP of the model treeStore
1032
        """
1033
1034 0
        model = self.keyBindingsModel
1035
1036 0
        for row in model:
1037 0
            if ((model.iter_depth(row.iter) == 0) \
1038
                and (row[DESCRIP] == appName)):
1039 0
                return row.iter
1040
1041 0
        return None
1042
1043 1
    def _addAlternateKeyBinding(self, kb):
1044
        """Adds an alternate keybinding to the existing handler and
1045
        returns true.  In case it doesn't exist yet, just returns
1046
        false.
1047
1048
        Argument:
1049
        - kb: the keybinding to be added as an alternate keybinding.
1050
        """
1051
1052 59
        model = self.keyBindingsModel
1053 59
        iter = model.get_iter_first()
1054 59
        exist = False
1055
1056 118
        while iter != None:
1057 59
            iterChild = model.iter_children(iter)
1058 1227
            while iterChild != None:
1059 1168
                if model.get(iterChild,DESCRIP)[0] == kb.handler._description:
1060 16
                    exist = True
1061 16
                    model.set(iterChild,
1062 16
                              MOD_MASK2, kb.modifier_mask,
1063 16
                              MOD_USED2, kb.modifiers,
1064 16
                              KEY2, kb.keysymstring,
1065 16
                              TEXT2,keybindings.getModifierNames(kb.modifiers)\
1066
                                  + kb.keysymstring)
1067 1168
                iterChild = model.iter_next(iterChild)
1068 59
            iter = model.iter_next(iter)
1069
1070 59
        return exist
1071
1072 1
    def _insertRow(self, handl, kb, parent=None, modif=False):
1073
        """Appends a new row with the new keybinding data to the treeview
1074
1075
        Arguments:
1076
        - handl:  the name of the handler associated to the keyBinding
1077
        - kb:     the new keybinding.
1078
        - parent: the parent node of the treeview, where to append the kb
1079
        - modif:  whether to check the modified field or not.
1080
1081
        Returns a gtk.TreeIter pointing at the new row.
1082
        """
1083
1084 43
        model = self.keyBindingsModel
1085
1086 43
        if parent == None:
1087 0
            parent = self._getIterOf(_("Orca"))
1088
1089 43
        if parent != None:
1090 43
            myiter = model.append(parent)
1091 43
            model.set (myiter,
1092 43
                       HANDLER,   handl,
1093 43
                       DESCRIP,   kb.handler._description,
1094 43
                       MOD_MASK1, kb.modifier_mask,
1095 43
                       MOD_USED1, kb.modifiers,
1096 43
                       KEY1,      kb.keysymstring,
1097 43
                       TEXT1,     keybindings.getModifierNames(kb.modifiers) \
1098
                                  + kb.keysymstring,
1099 43
                       MODIF,     modif,
1100 43
                       EDITABLE,  True)
1101 43
            return myiter
1102
        else:
1103 0
            return None
1104
1105 1
    def _insertRowBraille(self, handl, com, inputEvHand, parent=None, modif=False):
1106
        """Appends a new row with the new braille binding data to the treeview
1107
1108
        Arguments:
1109
        - handl:       the name of the handler associated to the brailleBinding
1110
        - com:         the BrlTTY command
1111
        - inputEvHand: the inputEventHandler with the new brailleBinding
1112
        - parent:      the parent node of the treeview, where to append the kb
1113
        - modif:       whether to check the modified field or not.
1114
1115
        Returns a gtk.TreeIter pointing at the new row.
1116
        """
1117
1118 7
        model = self.keyBindingsModel
1119
1120 7
        if parent == None:
1121 0
            parent = self._getIterOf(_("Braille Bindings"))
1122
1123 7
        if parent != None:
1124 7
            myiter = model.append(parent)
1125 7
            model.set (myiter,
1126 7
                       HANDLER,  handl,
1127 7
                       DESCRIP,  inputEvHand._description,
1128 7
                       KEY1,     com,
1129 7
                       TEXT1,    braille.command_name[com],
1130 7
                       MODIF,    modif,
1131 7
                       EDITABLE, False)
1132 7
            return myiter
1133
        else:
1134 0
            return None
1135
1136 1
    def _markModified(self):
1137
        """ Mark as modified the user custom key bindings:
1138
        """
1139
1140 1
        try:
1141 1
            defScript = default.Script(None)
1142 1
            defScript.setupInputEventHandlers()
1143 1
            keyBinds = keybindings.KeyBindings()
1144 1
            keyBinds = settings.overrideKeyBindings(defScript,keyBinds)
1145 1
            keyBind = keybindings.KeyBinding(None,None,None,None)
1146 1
            treeModel = self.keyBindingsModel
1147
1148 1
            iter = treeModel.get_iter_first()
1149 2
            while iter != None:
1150 1
                iterChild = treeModel.iter_children(iter)
1151 44
                while iterChild != None:
1152 43
                    descrip = treeModel.get_value(iterChild, DESCRIP)
1153 43
                    keyBind.handler=input_event.InputEventHandler(None,descrip)
1154 43
                    if keyBinds.hasKeyBinding(keyBind,
1155 43
                                              typeOfSearch="description"):
1156 0
                        treeModel.set_value(iterChild, MODIF, True)
1157 43
                    iterChild = treeModel.iter_next(iterChild)
1158 1
                iter = treeModel.iter_next(iter)
1159 0
        except:
1160 0
            debug.printException(debug.LEVEL_SEVERE)
1161
1162 1
    def _populateKeyBindings(self):
1163
        """Fills the TreeView with the list of Orca keybindings
1164
        """
1165 1
        self.keyBindingsModel.clear()
1166
1167 1
        self.kbindings = keybindings.KeyBindings()
1168
1169
        # KeyBindings from the default script, in default.py (Orca's default)
1170
        #
1171 1
        iterOrca = self._createNode(_("Orca"))
1172 1
        defScript = default.Script(None)
1173 1
        self.kbindingsDef = defScript.getKeyBindings()
1174
1175 60
        for kb in self.kbindingsDef.keyBindings:
1176 59
            if not self.kbindings.hasKeyBinding(kb, typeOfSearch="strict"):
1177 59
                if not self._addAlternateKeyBinding(kb):
1178 43
                    handl = defScript.getInputEventHandlerKey(kb.handler)
1179 43
                    self._insertRow(handl, kb, iterOrca)
1180
1181 1
        self.orcaModKeyEntry = self.widgets.get_widget("orcaModKeyEntry")
1182 1
        self.orcaModKeyEntry.set_text(
1183
            str(settings.orcaModifierKeys)[1:-1].replace("'",""))
1184
1185 1
        self._markModified()
1186
1187
        # Braille Bindings from default script, in default.py
1188
        #
1189 1
        iterBB = self._createNode(_("Braille Bindings"))
1190
1191 1
        self.bbindings = defScript.getBrailleBindings()
1192 8
        for com, inputEvHand in self.bbindings.iteritems():
1193 7
            handl = defScript.getInputEventHandlerKey(inputEvHand)
1194 7
            self._insertRowBraille(handl, com, inputEvHand, iterBB)
1195
1196 1
        self.keyBindView.expand_all()
1197 1
        self.keyBindingsModel.set_sort_column_id(TEXT1, gtk.SORT_ASCENDING)
1198
1199 1
    def speechSupportChecked(self, widget):
1200
        """Signal handler for the "toggled" signal for the
1201
           speechSupportCheckbutton GtkCheckButton widget. The user has
1202
           [un]checked the 'Enable Speech" checkbox. Set the 'enableSpeech'
1203
           preference to the new value. Set the rest of the speech pane items
1204
           [in]sensensitive depending upon whether this checkbox is checked.
1205
1206
        Arguments:
1207
        - widget: the component that generated the signal.
1208
        """
1209
1210 0
        enable = widget.get_active()
1211 0
        self.prefsDict["enableSpeech"] = enable
1212 0
        self.speechTable.set_sensitive(enable)
1213
1214 1
    def speechSystemsChanged(self, widget):
1215
        """Signal handler for the "changed" signal for the speechSystems
1216
           GtkComboBox widget. The user has selected a different speech
1217
           system. Clear the existing list of speech servers, and setup
1218
           a new list of speech servers based on the new choice. Setup a
1219
           new list of voices for the first speech server in the list.
1220
1221
        Arguments:
1222
        - widget: the component that generated the signal.
1223
        """
1224
1225 0
        if self.initializingSpeech:
1226 0
            return
1227
1228 0
        selectedIndex = widget.get_active()
1229 0
        self.speechSystemsChoice = self.speechSystemsChoices[selectedIndex]
1230 0
        self._setupSpeechServers()
1231
1232 1
    def speechServersChanged(self, widget):
1233
        """Signal handler for the "changed" signal for the speechServers
1234
           GtkComboBox widget. The user has selected a different speech
1235
           server. Clear the existing list of voices, and setup a new
1236
           list of voices based on the new choice.
1237
1238
        Arguments:
1239
        - widget: the component that generated the signal.
1240
        """
1241
1242 0
        if self.initializingSpeech:
1243 0
            return
1244
1245 0
        selectedIndex = widget.get_active()
1246 0
        self.speechServersChoice = self.speechServersChoices[selectedIndex]
1247
1248
        # Whenever the speech servers change, we need to make sure we
1249
        # clear whatever family was in use by the current voice types.
1250
        # Otherwise, we can end up with family names from one server
1251
        # bleeding over (e.g., "Paul" from Fonix ends up getting in
1252
        # the "Default" voice type after we switch to eSpeak).
1253
        #
1254 0
        try:
1255 0
            del self.defaultVoice[acss.ACSS.FAMILY]
1256 0
            del self.uppercaseVoice[acss.ACSS.FAMILY]
1257 0
            del self.hyperlinkVoice[acss.ACSS.FAMILY]
1258 0
        except:
1259 0
            pass
1260
1261 0
        self._setupFamilies()
1262
1263 1
    def speechFamiliesChanged(self, widget):
1264
        """Signal handler for the "value_changed" signal for the families
1265
           GtkComboBox widget. The user has selected a different voice
1266
           family. Save the new voice family name based on the new choice.
1267
1268
        Arguments:
1269
        - widget: the component that generated the signal.
1270
        """
1271
1272 0
        if self.initializingSpeech:
1273 0
            return
1274
1275 0
        selectedIndex = widget.get_active()
1276 0
        try:
1277 0
            family = self.speechFamiliesChoices[selectedIndex]
1278 0
            name = family[speechserver.VoiceFamily.NAME]
1279 0
            language = family[speechserver.VoiceFamily.LOCALE]
1280 0
            voiceType = self.voiceTypes.get_active_text()
1281 0
            self._setFamilyNameForVoiceType(voiceType, name, language)
1282 0
        except:
1283 0
            debug.printException(debug.LEVEL_SEVERE)
1284 0
            pass
1285
1286 1
    def voiceTypesChanged(self, widget):
1287
        """Signal handler for the "changed" signal for the voiceTypes
1288
           GtkComboBox widget. The user has selected a different voice
1289
           type. Setup the new family, rate, pitch and volume component
1290
           values based on the new choice.
1291
1292
        Arguments:
1293
        - widget: the component that generated the signal.
1294
        """
1295
1296 0
        if self.initializingSpeech:
1297 0
            return
1298
1299 0
        voiceType = widget.get_active_text()
1300 0
        self._setVoiceSettingsForVoiceType(voiceType)
1301
1302 1
    def rateValueChanged(self, widget):
1303
        """Signal handler for the "value_changed" signal for the rateScale
1304
           GtkHScale widget. The user has changed the current rate value.
1305
           Save the new rate value based on the currently selected voice
1306
           type.
1307
1308
        Arguments:
1309
        - widget: the component that generated the signal.
1310
        """
1311
1312 0
        rate = widget.get_value()
1313 0
        voiceType = self.voiceTypes.get_active_text()
1314 0
        self._setRateForVoiceType(voiceType, rate)
1315
1316 1
    def pitchValueChanged(self, widget):
1317
        """Signal handler for the "value_changed" signal for the pitchScale
1318
           GtkHScale widget. The user has changed the current pitch value.
1319
           Save the new pitch value based on the currently selected voice
1320
           type.
1321
1322
        Arguments:
1323
        - widget: the component that generated the signal.
1324
        """
1325
1326 0
        pitch = widget.get_value()
1327 0
        voiceType = self.voiceTypes.get_active_text()
1328 0
        self._setPitchForVoiceType(voiceType, pitch)
1329
1330 1
    def volumeValueChanged(self, widget):
1331
        """Signal handler for the "value_changed" signal for the voiceScale
1332
           GtkHScale widget. The user has changed the current volume value.
1333
           Save the new volume value based on the currently selected voice
1334
           type.
1335
1336
        Arguments:
1337
        - widget: the component that generated the signal.
1338
        """
1339
1340 0
        volume = widget.get_value()
1341 0
        voiceType = self.voiceTypes.get_active_text()
1342 0
        self._setVolumeForVoiceType(voiceType, volume)
1343
1344 1
    def speechIndentationChecked(self, widget):
1345
        """Signal handler for the "toggled" signal for the
1346
           speechIndentationCheckbutton GtkCheckButton widget. The user has
1347
           [un]checked the 'Speak indentation and justification' checkbox.
1348
           Set the 'enableSpeechIndentation' preference to the new value.
1349
1350
        Arguments:
1351
        - widget: the component that generated the signal.
1352
        """
1353
1354 0
        enable = widget.get_active()
1355 0
        self.prefsDict["enableSpeechIndentation"] = enable
1356
1357 1
    def speakBlankLinesChecked(self, widget):
1358
        """Signal handler for the "toggled" signal for the
1359
           speakBlankLinesCheckButton GtkCheckButton widget. The user has
1360
           [un]checked the 'Speak blank lines' checkbox.
1361
           Set the 'speakBlankLines' preference to the new value.
1362
1363
        Arguments:
1364
        - widget: the component that generated the signal.
1365
        """
1366
1367 0
        self.prefsDict["speakBlankLines"] = widget.get_active()
1368
1369 1
    def brailleSupportChecked(self, widget):
1370
        """Signal handler for the "toggled" signal for the
1371
           brailleSupportCheckbutton GtkCheckButton widget. The user has
1372
           [un]checked the 'Enable Braille support" checkbox. Set the
1373
           'enableBraille' preference to the new value.
1374
1375
        Arguments:
1376
        - widget: the component that generated the signal.
1377
        """
1378
1379 0
        self.prefsDict["enableBraille"] = widget.get_active()
1380
1381 1
    def brailleMonitorChecked(self, widget):
1382
        """Signal handler for the "toggled" signal for the
1383
           brailleMonitorCheckbutton GtkCheckButton widget. The user has
1384
           [un]checked the 'Enable Braille monitor" checkbox. Set the
1385
           'enableBrailleMonitor' preference to the new value.
1386
1387
        Arguments:
1388
        - widget: the component that generated the signal.
1389
        """
1390
1391 0
        self.prefsDict["enableBrailleMonitor"] = widget.get_active()
1392
1393 1
    def keyEchoChecked(self, widget):
1394
        """Signal handler for the "toggled" signal for the
1395
           keyEchoCheckbutton GtkCheckButton widget. The user has
1396
           [un]checked the 'Enable Key Echo" checkbox. Set the
1397
           'enableKeyEcho' preference to the new value. [In]sensitize
1398
           the checkboxes for the various types of key echo, depending
1399
           upon whether this value is checked or unchecked.
1400
1401
        Arguments:
1402
        - widget: the component that generated the signal.
1403
        """
1404
1405 0
        self.prefsDict["enableKeyEcho"] = widget.get_active()
1406 0
        self._setKeyEchoItems()
1407
1408 1
    def printableKeysChecked(self, widget):
1409
        """Signal handler for the "toggled" signal for the
1410
           printableCheckbutton GtkCheckButton widget. The user has
1411
           [un]checked the 'Enable alphanumeric and punctuation keys"
1412
           checkbox. Set the 'enablePrintableKeys' preference to the
1413
           new value.
1414
1415
        Arguments:
1416
        - widget: the component that generated the signal.
1417
        """
1418
1419 0
        self.prefsDict["enablePrintableKeys"] = widget.get_active()
1420
1421 1
    def modifierKeysChecked(self, widget):
1422
        """Signal handler for the "toggled" signal for the
1423
           modifierCheckbutton GtkCheckButton widget. The user has
1424
           [un]checked the 'Enable modifier keys" checkbox. Set the
1425
           'enableModifierKeys' preference to the new value.
1426
1427
        Arguments:
1428
        - widget: the component that generated the signal.
1429
        """
1430
1431 0
        self.prefsDict["enableModifierKeys"] = widget.get_active()
1432
1433 1
    def lockingKeysChecked(self, widget):
1434
        """Signal handler for the "toggled" signal for the
1435
           lockingCheckbutton GtkCheckButton widget. The user has
1436
           [un]checked the 'Enable locking keys" checkbox. Set the
1437
           'enableLockingKeys' preference to the new value.
1438
1439
        Arguments:
1440
        - widget: the component that generated the signal.
1441
        """
1442
1443 0
        self.prefsDict["enableLockingKeys"] = widget.get_active()
1444
1445 1
    def functionKeysChecked(self, widget):
1446
        """Signal handler for the "toggled" signal for the
1447
           functionCheckbutton GtkCheckButton widget. The user has
1448
           [un]checked the 'Enable locking keys" checkbox. Set the
1449
           'enableLockingKeys' preference to the new value.
1450
1451
        Arguments:
1452
        - widget: the component that generated the signal.
1453
        """
1454
1455 0
        self.prefsDict["enableFunctionKeys"] = widget.get_active()
1456
1457 1
    def actionKeysChecked(self, widget):
1458
        """Signal handler for the "toggled" signal for the
1459
           actionCheckbutton GtkCheckButton widget. The user has
1460
           [un]checked the 'Enable action keys" checkbox. Set the
1461
           'enableActionKeys' preference to the new value.
1462
1463
        Arguments:
1464
        - widget: the component that generated the signal.
1465
        """
1466 0
        self.prefsDict["enableActionKeys"] = widget.get_active()
1467
1468 1
    def echoByWordChecked(self, widget):
1469
        """Signal handler for the "toggled" signal for the
1470
           echoByWordCheckbutton GtkCheckButton widget. The user has
1471
           [un]checked the 'Enable Echo by Word" checkbox. Set the
1472
           'enableEchoByWord' preference to the new value.
1473
1474
        Arguments:
1475
        - widget: the component that generated the signal.
1476
        """
1477
1478 0
        self.prefsDict["enableEchoByWord"] = widget.get_active()
1479
1480 1
    def punctuationLevelChanged(self, widget):
1481
        """Signal handler for the "toggled" signal for the noneButton,
1482
           someButton or allButton GtkRadioButton widgets. The user has
1483
           toggled the speech punctuation level value. If this signal
1484
           was generated as the result of a radio button getting selected
1485
           (as opposed to a radio button losing the selection), set the
1486
           'verbalizePunctuationStyle' preference to the new value.
1487
1488
        Arguments:
1489
        - widget: the component that generated the signal.
1490
        """
1491
1492 0
        if widget.get_active():
1493 0
            if widget.get_label() == _("_None"):
1494 0
                self.prefsDict["verbalizePunctuationStyle"] = \
1495
                    settings.PUNCTUATION_STYLE_NONE
1496 0
            elif widget.get_label() == _("So_me"):
1497 0
                self.prefsDict["verbalizePunctuationStyle"] = \
1498
                    settings.PUNCTUATION_STYLE_SOME
1499 0
            elif widget.get_label() == _("M_ost"):
1500 0
                self.prefsDict["verbalizePunctuationStyle"] = \
1501
                    settings.PUNCTUATION_STYLE_MOST
1502
            else:
1503 0
                self.prefsDict["verbalizePunctuationStyle"] = \
1504
                    settings.PUNCTUATION_STYLE_ALL
1505
1506 1
    def speechVerbosityChanged(self, widget):
1507
        """Signal handler for the "toggled" signal for the speechBriefButton,
1508
           or speechVerboseButton GtkRadioButton widgets. The user has
1509
           toggled the speech verbosity level value. If this signal was
1510
           generated as the result of a radio button getting selected
1511
           (as opposed to a radio button losing the selection), set the
1512
           'speechVerbosityLevel' preference to the new value.
1513
1514
        Arguments:
1515
        - widget: the component that generated the signal.
1516
        """
1517
1518 0
        if widget.get_active():
1519 0
            if widget.get_label() == _("Brie_f"):
1520 0
                self.prefsDict["speechVerbosityLevel"] = \
1521
                    settings.VERBOSITY_LEVEL_BRIEF
1522
            else:
1523 0
                self.prefsDict["speechVerbosityLevel"] = \
1524
                    settings.VERBOSITY_LEVEL_VERBOSE
1525
1526 1
    def tableSpeechChanged(self, widget):
1527
        """Signal handler for the "toggled" signal for the cellSpeechButton,
1528
           or rowSpeechButton GtkRadioButton widgets. The user has
1529
           toggled the table row speech type value. If this signal was
1530
           generated as the result of a radio button getting selected
1531
           (as opposed to a radio button losing the selection), set the
1532
           'readTableCellRow' preference to the new value.
1533
1534
        Arguments:
1535
        - widget: the component that generated the signal.
1536
        """
1537
1538 0
        if widget.get_active():
1539 0
            if widget.get_label() == _("Speak current _cell"):
1540 0
                self.prefsDict["readTableCellRow"] = False
1541
            else:
1542 0
                self.prefsDict["readTableCellRow"] = True
1543
1544 1
    def abbrevRolenamesChecked(self, widget):
1545
        """Signal handler for the "toggled" signal for the abbrevRolenames
1546
           GtkCheckButton widget. The user has [un]checked the 'Abbreviated
1547
           Rolenames" checkbox. Set the 'brailleRolenameStyle' preference
1548
           to the new value.
1549
1550
        Arguments:
1551
        - widget: the component that generated the signal.
1552
        """
1553
1554 0
        if widget.get_active():
1555 0
            self.prefsDict["brailleRolenameStyle"] = \
1556
                settings.BRAILLE_ROLENAME_STYLE_SHORT
1557
        else:
1558 0
            self.prefsDict["brailleRolenameStyle"] = \
1559
                settings.BRAILLE_ROLENAME_STYLE_LONG
1560
1561 1
    def brailleVerbosityChanged(self, widget):
1562
        """Signal handler for the "toggled" signal for the brailleBriefButton,
1563
           or brailleVerboseButton GtkRadioButton widgets. The user has
1564
           toggled the braille verbosity level value. If this signal was
1565
           generated as the result of a radio button getting selected
1566
           (as opposed to a radio button losing the selection), set the
1567
           'brailleVerbosityLevel' preference to the new value.
1568
1569
        Arguments:
1570
        - widget: the component that generated the signal.
1571
        """
1572
1573 0
        if widget.get_active():
1574 0
            if widget.get_label() == _("Brie_f"):
1575 0
                self.prefsDict["brailleVerbosityLevel"] = \
1576
                    settings.VERBOSITY_LEVEL_BRIEF
1577
            else:
1578 0
                self.prefsDict["brailleVerbosityLevel"] = \
1579
                    settings.VERBOSITY_LEVEL_VERBOSE
1580
1581 1
    def magnifierSupportChecked(self, widget):
1582
        """Signal handler for the "toggled" signal for the
1583
           magnifierSupportCheckbutton GtkCheckButton widget.
1584
           The user has [un]checked the 'Enable Magnification" checkbox.
1585
           Set the 'enableMagnifier' preference to the new value.
1586
           Set the rest of the magnifier pane items [in]sensensitive
1587
           depending upon whether this checkbox is checked.
1588
1589
        Arguments:
1590
        - widget: the component that generated the signal.
1591
        """
1592
1593 0
        enable = widget.get_active()
1594 0
        self.prefsDict["enableMagnifier"] = enable
1595 0
        self.magnifierTable.set_sensitive(enable)
1596
1597 1
    def magCursorOnOffChecked(self, widget):
1598
        """Signal handler for the "toggled" signal for the
1599
           magCursorOnOffCheckButton GtkCheckButton widget.
1600
           The user has [un]checked the magnification cursor settings
1601
           'Cursor on/off' checkbox. Set the 'enableMagCursor' preference
1602
           to the new value.
1603
1604
        Arguments:
1605
        - widget: the component that generated the signal.
1606
        """
1607
1608 0
        self.prefsDict["enableMagCursor"] = widget.get_active()
1609
1610 1
    def magCursorExplicitSizeChecked(self, widget):
1611
        """Signal handler for the "toggled" signal for the
1612
           magCursorSizeCheckButton GtkCheckButton widget.
1613
           The user has [un]checked the magnification cursor settings
1614
           'Explicit cursor size' checkbox. Set the
1615
           'enableMagCursorExplicitSize' preference to the new value.
1616
           [Un]sensitize the cursor size spin button and label depending
1617
           upon whether this checkbox is checked.
1618
1619
        Arguments:
1620
        - widget: the component that generated the signal.
1621
        """
1622
1623 0
        enable = widget.get_active()
1624 0
        self.prefsDict["enableMagCursorExplicitSize"] = enable
1625 0
        self.magCursorSizeSpinButton.set_sensitive(enable)
1626 0
        self.magCursorSizeLabel.set_sensitive(enable)
1627
1628 1
    def magCursorSizeValueChanged(self, widget):
1629
        """Signal handler for the "value_changed" signal for the
1630
           magCursorSizeSpinButton GtkSpinButton widget.
1631
           The user has changed the value of the magnification
1632
           cursor settings cursor size spin button. Set the
1633
           'magCursorSize' preference to the new integer value.
1634
1635
        Arguments:
1636
        - widget: the component that generated the signal.
1637
        """
1638
1639 0
        self.prefsDict["magCursorSize"] = widget.get_value_as_int()
1640
1641 1
    def magCursorColorSet(self, widget):
1642
        """Signal handler for the "color_set" signal for the
1643
           magCursorColorButton GtkColorButton widget.
1644
           The user has changed the value of the magnification
1645
           cursor settings cursor color button. Set the 'magCursorColor'
1646
           preference to the new value.
1647
1648
        Arguments:
1649
        - widget: the component that generated the signal.
1650
        """
1651
1652 0
        color = widget.get_color()
1653 0
        cursorColor = "#%04X%04X%04X" % (color.red, color.green, color.blue)
1654 0
        self.prefsDict["magCursorColor"] = cursorColor
1655
1656 1
    def magCrossHairOnOffChecked(self, widget):
1657
        """Signal handler for the "toggled" signal for the
1658
           magCrossHairOnOffCheckButton GtkCheckButton widget.
1659
           The user has [un]checked the magnification cross-hair settings
1660
           'Cross-hair on/off' checkbox. Set the 'enableMagCrossHair'
1661
           preference to the new value.
1662
1663
        Arguments:
1664
        - widget: the component that generated the signal.
1665
        """
1666
1667 0
        self.prefsDict["enableMagCrossHair"] = widget.get_active()
1668
1669 1
    def magCrossHairClipOnOffChecked(self, widget):
1670
        """Signal handler for the "toggled" signal for the
1671
           magCrossHairClipCheckButton GtkCheckButton widget.
1672
           The user has [un]checked the magnification cross-hair settings
1673
           'Cross-hair clip on/off' checkbox. Set the 'enableMagCrossHairClip'
1674
           preference to the new value.
1675
1676
        Arguments:
1677
        - widget: the component that generated the signal.
1678
        """
1679
1680 0
        self.prefsDict["enableMagCrossHairClip"] = widget.get_active()
1681
1682 1
    def magCrossHairSizeValueChanged(self, widget):
1683
        """Signal handler for the "value_changed" signal for the
1684
           magCrossHairSizeSpinButton GtkSpinButton widget.
1685
           The user has changed the value of the magnification
1686
           cross-hair settings cross-hair size spin button. Set the
1687
           'magCrossHairSize' preference to the new integer value.
1688
1689
        Arguments:
1690
        - widget: the component that generated the signal.
1691
        """
1692
1693 0
        self.prefsDict["magCrossHairSize"] = widget.get_value_as_int()
1694
1695 1
    def magZoomerTopValueChanged(self, widget):
1696
        """Signal handler for the "value_changed" signal for the
1697
           magZoomerTopSpinButton GtkSpinButton widget.
1698
           The user has changed the value of the magnification
1699
           zoomer placement top spin button. Set the 'magZoomerTop'
1700
           preference to the new integer value.
1701
1702
        Arguments:
1703
        - widget: the component that generated the signal.
1704
        """
1705
1706 0
        self.prefsDict["magZoomerTop"] = widget.get_value_as_int()
1707
1708 1
    def magZoomerBottomValueChanged(self, widget):
1709
        """Signal handler for the "value_changed" signal for the
1710
           magZoomerBottomSpinButton GtkSpinButton widget.
1711
           The user has changed the value of the magnification
1712
           zoomer placement bottom spin button. Set the 'magZoomerBottom'
1713
           preference to the new integer value.
1714
1715
        Arguments:
1716
        - widget: the component that generated the signal.
1717
        """
1718
1719 0
        self.prefsDict["magZoomerBottom"] = widget.get_value_as_int()
1720
1721 1
    def magZoomerLeftValueChanged(self, widget):
1722
        """Signal handler for the "value_changed" signal for the
1723
           magZoomerLeftSpinButton GtkSpinButton widget.
1724
           The user has changed the value of the magnification
1725
           zoomer placement left spin button. Set the 'magZoomerLeft'
1726
           preference to the new integer value.
1727
1728
        Arguments:
1729
        - widget: the component that generated the signal.
1730
        """
1731
1732 0
        self.prefsDict["magZoomerLeft"] = widget.get_value_as_int()
1733
1734 1
    def magZoomerRightValueChanged(self, widget):
1735
        """Signal handler for the "value_changed" signal for the
1736
           magZoomerRightSpinButton GtkSpinButton widget.
1737
           The user has changed the value of the magnification
1738
           zoomer placement right spin button. Set the 'magZoomerRight'
1739
           preference to the new integer value.
1740
1741
        Arguments:
1742
        - widget: the component that generated the signal.
1743
        """
1744
1745 0
        self.prefsDict["magZoomerRight"] = widget.get_value_as_int()
1746
1747 1
    def magZoomFactorValueChanged(self, widget):
1748
        """Signal handler for the "value_changed" signal for the
1749
           magZoomFactorSpinButton GtkSpinButton widget.
1750
           The user has changed the value of the magnification
1751
           zoom factor spin button. Set the 'magZoomFactor'
1752
           preference to the new value.
1753
1754
        Arguments:
1755
        - widget: the component that generated the signal.
1756
        """
1757
1758 0
        self.prefsDict["magZoomFactor"] = widget.get_value_as_int()
1759
1760 1
    def magSmoothingChanged(self, widget):
1761
        """Signal handler for the "changed" signal for the
1762
           magSmoothingComboBox GtkComboBox widget. The user has
1763
           selected a different magnification smoothing style.
1764
           Set the 'magSmoothingMode' preference to the new value.
1765
1766
        Arguments:
1767
        - widget: the component that generated the signal.
1768
        """
1769
1770 0
        smoothingMode = widget.get_active_text()
1771 0
        if smoothingMode ==  _("Bilinear"):
1772 0
            mode = settings.MAG_SMOOTHING_MODE_BILINEAR
1773 0
        elif smoothingMode == _("None"):
1774 0
            mode = settings.MAG_SMOOTHING_MODE_NONE
1775
        else:
1776 0
            mode = settings.MAG_SMOOTHING_MODE_BILINEAR
1777 0
        self.prefsDict["magSmoothingMode"] = mode
1778
1779 1
    def magMouseTrackingChanged(self, widget):
1780
        """Signal handler for the "changed" signal for the
1781
           magMouseTrackingComboBox GtkComboBox widget. The user has
1782
           selected a different magnification mouse tracking style.
1783
           Set the 'magMouseTrackingMode' preference to the new value.
1784
1785
        Arguments:
1786
        - widget: the component that generated the signal.
1787
        """
1788
1789 0
        mouseTrackingMode = widget.get_active_text()
1790 0
        if mouseTrackingMode ==  _("Centered"):
1791 0
            mode = settings.MAG_MOUSE_TRACKING_MODE_CENTERED
1792 0
        elif mouseTrackingMode == _("Push"):
1793 0
            mode = settings.MAG_MOUSE_TRACKING_MODE_PUSH
1794 0
        elif mouseTrackingMode == _("Proportional"):
1795 0
            mode = settings.MAG_MOUSE_TRACKING_MODE_PROPORTIONAL
1796 0
        elif mouseTrackingMode == _("None"):
1797 0
            mode = settings.MAG_MOUSE_TRACKING_MODE_NONE
1798
        else:
1799 0
            mode = settings.MAG_MOUSE_TRACKING_MODE_CENTERED
1800 0
        self.prefsDict["magMouseTrackingMode"] = mode
1801
1802 1
    def magInvertColorsChecked(self, widget):
1803
        """Signal handler for the "toggled" signal for the
1804
           magCrossHairOnOffCheckButton GtkCheckButton widget.
1805
           The user has [un]checked the magnification 'Invert Colors'
1806
           checkbox. Set the 'enableMagZoomerColorInversion' preference
1807
           to the new value.
1808
1809
        Arguments:
1810
        - widget: the component that generated the signal.
1811
        """
1812
1813 0
        self.prefsDict["enableMagZoomerColorInversion"] = widget.get_active()
1814
1815 1
    def keyModifiedToggle(self, cell, path, model, col):
1816
        """When the user changes a checkbox field (boolean field)"""
1817
1818 0
        model[path][col] = not model[path][col]
1819 0
        return
1820
1821 1
    def editingKey(self, cell, editable, path, treeModel):
1822
        """Starts user input of a Key for a selected key binding"""
1823
1824 0
        editable.set_text(_("enter new key"))
1825 0
        orca_state.capturingKeys = True
1826 0
        return
1827
1828 1
    def editedKey(self, cell, path, new_text, treeModel, modMask, modUsed, key, text):
1829
        """The user changes the key for a Keybinding:
1830
            update the model of the treeview
1831
        """
1832
1833 0
        newKeyEvent = orca_state.lastCapturedKey
1834 0
        newKey = str(orca_state.lastCapturedKey.event_string)
1835 0
        mods = keybindings.getModifierNames(newKeyEvent.modifiers)
1836
1837 0
        orca_state.capturingKeys = False
1838
1839 0
        if (newKey != treeModel[path][key]) \
1840
           or (newKeyEvent.modifiers != int(treeModel[path][modUsed])):
1841 0
            iter = treeModel.get_iter_from_string(path)
1842 0
            treeModel.set(iter,
1843 0
                          modMask, newKeyEvent.modifiers,
1844 0
                          modUsed, newKeyEvent.modifiers,
1845 0
                          key, newKey,
1846 0
                          text, mods + newKey,
1847 0
                          MODIF, True)
1848 0
            speech.stop()
1849 0
            speech.speak(_("The new key is: %s") % newKey)
1850 0
        else:
1851 0
            speech.stop()
1852 0
            speech.speak(_("The key entered is the same. Nothing changed."))
1853
1854 0
        return
1855
1856 1
    def magSourceDisplayChanged(self, widget):
1857
        """Signal handler for the "changed" signal for the
1858
           magSourceDisplayDisplayEntry GtkEntry widget.
1859
           The user has changed the value of the magnification source
1860
           display. Set the 'magSourceDisplay' preference
1861
           to the new value.
1862
1863
        Arguments:
1864
        - widget: the component that generated the signal.
1865
        """
1866
1867 0
        self.prefsDict["magSourceDisplay"] = widget.get_text()
1868
1869 1
    def magTargetDisplayChanged(self, widget):
1870
        """Signal handler for the "changed" signal for the
1871
           magTargetDisplayEntry GtkEntry widget.
1872
           The user has changed the value of the magnification target
1873
           display. Set the 'magTargetDisplay' preference
1874
           to the new value.
1875
1876
        Arguments:
1877
        - widget: the component that generated the signal.
1878
        """
1879
1880 0
        self.prefsDict["magTargetDisplay"] = widget.get_text()
1881
1882 1
    def showMainWindowChecked(self, widget):
1883
        """Signal handler for the "toggled" signal for the
1884
           showMainWindowCheckButton GtkCheckButton widget.
1885
           The user has [un]checked the 'Show Orca main window'
1886
           checkbox. Set the 'showMainWindow' preference
1887
           to the new value.
1888
1889
        Arguments:
1890
        - widget: the component that generated the signal.
1891
        """
1892
1893 0
        self.prefsDict["showMainWindow"] = widget.get_active()
1894
1895 1
    def disableKeyGrabChecked(self, widget):
1896
        """Signal handler for the "toggled" signal for the
1897
           disableKeyGrabCheckButton GtkCheckButton widget.
1898
           The user has [un]checked the 'Disable gksu keyboard grab'
1899
           checkbox. Set the gconf '/apps/gksu/disable-grab' resource
1900
           to the new value.
1901
1902
        Arguments:
1903
        - widget: the component that generated the signal.
1904
        """
1905
1906 0
        self.disableKeyGrabPref = widget.get_active()
1907
1908 1
    def keyboardLayoutChanged(self, widget):
1909
        """Signal handler for the "toggled" signal for the generalDesktopButton,
1910
           or generalLaptopButton GtkRadioButton widgets. The user has
1911
           toggled the keyboard layout value. If this signal was
1912
           generated as the result of a radio button getting selected
1913
           (as opposed to a radio button losing the selection), set the
1914
           'keyboardLayout' preference to the new value. Also set the
1915
           matching list of Orca modifier keys
1916
1917
        Arguments:
1918
        - widget: the component that generated the signal.
1919
        """
1920
1921 0
        if widget.get_active():
1922 0
            if widget.get_label() == _("_Desktop"):
1923 0
                self.prefsDict["keyboardLayout"] = \
1924
                    settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP
1925 0
                self.prefsDict["orcaModifierKeys"] = \
1926
                    settings.DESKTOP_MODIFIER_KEYS
1927
            else:
1928 0
                self.prefsDict["keyboardLayout"] = \
1929
                    settings.GENERAL_KEYBOARD_LAYOUT_LAPTOP
1930 0
                self.prefsDict["orcaModifierKeys"] = \
1931
                    settings.LAPTOP_MODIFIER_KEYS
1932
1933 1
    def helpButtonClicked(self, widget):
1934
        """Signal handler for the "clicked" signal for the helpButton
1935
           GtkButton widget. The user has clicked the Help button.
1936
1937
        Arguments:
1938
        - widget: the component that generated the signal.
1939
        """
1940
1941 0
        print "Help not currently implemented."
1942
1943 1
    def applyButtonClicked(self, widget):
1944
        """Signal handler for the "clicked" signal for the applyButton
1945
           GtkButton widget. The user has clicked the Apply button.
1946
           Write out the users preferences. If GNOME accessibility hadn't
1947
           previously been enabled, warn the user that they will need to
1948
           log out. Shut down any active speech servers that were started.
1949
           Reload the users preferences to get the new speech, braille and
1950
           key echo value to take effect. Do not dismiss the configuration
1951
           window.
1952
1953
        Arguments:
1954
        - widget: the component that generated the signal.
1955
        """
1956
1957 0
        enable = self.speechSupportCheckbutton.get_active()
1958 0
        self.prefsDict["enableSpeech"] = enable
1959 0
        self.prefsDict["speechServerFactory"] = \
1960
            self.speechSystemsChoice.__name__
1961 0
        self.prefsDict["speechServerInfo"] = self.speechServersChoice.getInfo()
1962 0
        self.prefsDict["voices"] = {
1963
            settings.DEFAULT_VOICE   : acss.ACSS(self.defaultVoice),
1964
            settings.UPPERCASE_VOICE : acss.ACSS(self.uppercaseVoice),
1965
            settings.HYPERLINK_VOICE : acss.ACSS(self.hyperlinkVoice)
1966
        }
1967
1968 0
        if self.disableKeyGrabPref:
1969 0
            keyGrabState = "true"
1970
        else:
1971 0
            keyGrabState = "false"
1972 0
        os.system("gconftool-2 --type bool --set " \
1973
                  + "/apps/gksu/disable-grab " + keyGrabState)
1974
1975 0
        if orca_prefs.writePreferences(self.prefsDict, self.keyBindingsModel):
1976 0
            self._say(_("Accessibility support for GNOME has just been enabled."))
1977 0
            self._say(_("You need to log out and log back in for the change to take effect."))
1978
1979 0
        orca.loadUserSettings()
1980
1981 0
        self._initSpeechState()
1982
1983 0
        self._populateKeyBindings()
1984
1985 1
    def cancelButtonClicked(self, widget):
1986
        """Signal handler for the "clicked" signal for the cancelButton
1987
           GtkButton widget. The user has clicked the Cancel button.
1988
           Don't write out the preferences. Destroy the configuration window.
1989
1990
        Arguments:
1991
        - widget: the component that generated the signal.
1992
        """
1993
1994 0
        self.orcaSetupWindow.destroy()
1995
1996 1
    def okButtonClicked(self, widget):
1997
        """Signal handler for the "clicked" signal for the okButton
1998
           GtkButton widget. The user has clicked the OK button.
1999
           Write out the users preferences. If GNOME accessibility hadn't
2000
           previously been enabled, warn the user that they will need to
2001
           log out. Shut down any active speech servers that were started.
2002
           Reload the users preferences to get the new speech, braille and
2003
           key echo value to take effect. Hide the configuration window.
2004
2005
        Arguments:
2006
        - widget: the component that generated the signal.
2007
        """
2008
2009 0
        self.applyButtonClicked(widget)
2010 0
        self.orcaSetupWindow.hide()
2011
2012 1
    def windowDestroyed(self, widget):
2013
        """Signal handler for the "destroyed" signal for the orcaSetupWindow
2014
           GtkWindow widget. Reset OS to None, so that the GUI can be rebuilt
2015
           from the Glade file the next time the user wants to display the
2016
           configuration GUI.
2017
2018
        Arguments:
2019
        - widget: the component that generated the signal.
2020
        """
2021
2022 0
        global OS
2023
2024 0
        OS = None
2025
2026 1
def showPreferencesUI():
2027 0
    global OS
2028
2029 1
    if not OS:
2030 1
        gladeFile = os.path.join(platform.prefix,
2031 1
                                 platform.datadirname,
2032 1
                                 platform.package,
2033 1
                                 "glade",
2034 1
                                 "orca-setup.glade")
2035 1
        OS = orcaSetupGUI(gladeFile, "orcaSetupWindow")
2036 1
        OS._init()
2037
2038 0
    OS._showGUI()
2039
2040 1
def main():
2041 0
    locale.setlocale(locale.LC_ALL, '')
2042
2043 0
    showPreferencesUI()
2044
2045 0
    gtk.main()
2046 0
    sys.exit(0)
2047
2048 1
if __name__ == "__main__":
2049 0
    main()