[orca/orca-gnome3: 71/87] Third speech plugin approximation
- From: Alejandro Leiva <aleiva src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/orca-gnome3: 71/87] Third speech plugin approximation
- Date: Fri, 1 Apr 2011 11:18:46 +0000 (UTC)
commit 3d4e0af815b61b3863632ee3545f67783f5268c8
Author: Javier Hernández Antúnez <jhernandez emergya es>
Date: Wed Mar 30 16:04:44 2011 +0200
Third speech plugin approximation
src/orca/baseplugins/speech.py | 6 ++--
src/orca/dummyspeech.py | 4 +-
src/orca/orca.py | 2 +-
src/orca/orca_gui_prefs.py | 19 ++++++++++-
src/orca/pluglib/plugin_manager.py | 62 +++++++++++++++++------------------
src/orca/scripts/default.py | 2 +
6 files changed, 56 insertions(+), 39 deletions(-)
---
diff --git a/src/orca/baseplugins/speech.py b/src/orca/baseplugins/speech.py
index 87199c4..88294df 100644
--- a/src/orca/baseplugins/speech.py
+++ b/src/orca/baseplugins/speech.py
@@ -246,11 +246,11 @@ class speechPlugin(IPlugin, IPresenter):
string or an array of arrays of objects returned by a speech
generator."""
- print "someone has called me to speak %s" % content
-
- if settings.silenceSpeech:
+ if settings.silenceSpeech or not settings.enableSpeech:
return
+ print "someone has called me to speak %s" % content
+
validTypes = (basestring, list, sound.Sound, speech_generator.Pause,
speech_generator.LineBreak, ACSS)
error = "bad content sent to speech.speak: '%s'"
diff --git a/src/orca/dummyspeech.py b/src/orca/dummyspeech.py
index c8ebbea..57dac81 100644
--- a/src/orca/dummyspeech.py
+++ b/src/orca/dummyspeech.py
@@ -18,7 +18,7 @@ def _speak(text, acss, interrupt):
print '_speak'
def speak(content, acss=None, interrupt=True):
- print 'speak'
+ print 'speak from %s' % orca_state.activeScript
def speakKeyEvent(event_string, eventType):
print 'speakKeyEvent'
@@ -33,7 +33,7 @@ def getInfo():
print 'getInfo'
def stop():
- print 'stop'
+ print 'stop from %s' % orca_state.activeScript
def updatePunctuationLevel(script=None, inputEvent=None):
print 'updatePunctuationLevel'
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 20ef59b..e2ef4a0 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -1558,7 +1558,7 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
if settings.enableSpeech and 'speech' in activePlugins:
speech = _pluginManager.getPluginObject('speech')
- if speech == None: import dummyspeech as speech
+# if speech == None: import dummyspeech as speech
try:
speech.init()
if reloaded and not skipReloadMessage:
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index be9a3e3..eb417e9 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -58,6 +58,7 @@ _settingsManager = getattr(orca, '_settingsManager')
_scriptManager = getattr(orca, '_scriptManager')
_pluginManager = getattr(orca, '_pluginManager')
+global speech
speech = _pluginManager.getPluginObject('speech')
if speech == None: import dummyspeech as speech
import speechserver
@@ -837,6 +838,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
box item.
"""
+ global speech
+
if len(self.speechServersChoices) == 0:
return
@@ -989,6 +992,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
"""Initialize the various speech components.
"""
+ global speech
+
print 'in orca_gui_prefs::_initSpeechState(self)'
voices = self.prefsDict["voices"]
@@ -2251,6 +2256,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
self._initPluginsTreeView()
+ self.__updateSpeechTab(self.currentPluginsStatus['speech']['active'])
+
def _initPluginsTreeView(self):
self.plugins_store.clear()
@@ -2330,7 +2337,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
if plugin_name == 'speech':
self.__updateSpeechTab(active)
-
+ self.__reloadSpeechModule()
+ self.applyButtonClicked(self.get_widget('notebook'))
# nacho's
# if active:
@@ -2348,6 +2356,13 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
speechTab.hide()
speech.shutdown()
+ # We really need this method?
+ def __reloadSpeechModule(self):
+ global speech
+ del(speech)
+ speech = _pluginManager.getPluginObject('speech')
+ if speech == None: import dummyspeech as speech
+
def __initProfileCombo(self):
"""Adding available profiles and setting active as the active one"""
@@ -4202,6 +4217,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
the treeview.
"""
+ global speech
+
orca_state.capturingKeys = False
myiter = treeModel.get_iter_from_string(path)
originalBinding = treeModel.get_value(myiter, text)
diff --git a/src/orca/pluglib/plugin_manager.py b/src/orca/pluglib/plugin_manager.py
index a09f370..5b63e57 100644
--- a/src/orca/pluglib/plugin_manager.py
+++ b/src/orca/pluglib/plugin_manager.py
@@ -173,29 +173,30 @@ class ModulePluginManager(IPluginManager):
load_plugins = self.plugins['plugins']
for module_name, data in load_plugins.iteritems():
- if load_plugins[module_name]['active'] == True:
- try:
- # if active, add the class into the plugin list
- self.load_class_in_plugin(load_plugins[module_name],
- module_name, [load_plugins[module_name]['path']])
-
- plugin_class = load_plugins[module_name]['class']
-
- # we have the class now, we can get an object
- plugin_object = plugin_class()
- if isinstance(plugin_object, IConfigurable):
- plugin_object.load()
-
- load_plugins[module_name]['object'] = plugin_object
- print "Starting existent module: " + str(module_name)
- except Exception, e:
- raise PluginManagerError, 'Cannot load module %s: %s' % \
- (module_name, e)
- else:
- # plugin not active, bring into plugin list
- # maintained in memory but not get the class
- load_plugins[module_name].update({'class': None})
- load_plugins[module_name].update({'object': None})
+# This comments make plugins allways enabled
+# if load_plugins[module_name]['active'] == True:
+ try:
+ # if active, add the class into the plugin list
+ self.load_class_in_plugin(load_plugins[module_name],
+ module_name, [load_plugins[module_name]['path']])
+
+ plugin_class = load_plugins[module_name]['class']
+
+ # we have the class now, we can get an object
+ plugin_object = plugin_class()
+ if isinstance(plugin_object, IConfigurable):
+ plugin_object.load()
+
+ load_plugins[module_name]['object'] = plugin_object
+ print "Starting existent module: " + str(module_name)
+ except Exception, e:
+ raise PluginManagerError, 'Cannot load module %s: %s' % \
+ (module_name, e)
+# else:
+# # plugin not active, bring into plugin list
+# # maintained in memory but not get the class
+# load_plugins[module_name].update({'class': None})
+# load_plugins[module_name].update({'object': None})
self.plugins = load_plugins
@@ -245,7 +246,7 @@ class ModulePluginManager(IPluginManager):
# plugin_object.removePluginKeybinding()
plugin_object.disable()
- self.plugins[plugin_name]['object'] = None
+ #self.plugins[plugin_name]['object'] = None
# nacho's
# # make the plugin inactive in the appropiated backend
@@ -258,7 +259,7 @@ class ModulePluginManager(IPluginManager):
# this *only* delete the name from sys.modules,
# not the module itself. See http://bit.ly/gbjPnB
- del (plugin_name)
+ #del (plugin_name)
def get_plugins(self):
@@ -325,16 +326,13 @@ class ModulePluginManager(IPluginManager):
#
def isEnabled(self, plugin_name):
- if self.getPluginObject(plugin_name) == None:
- return False
- else:
- return True
+ return self.plugins[plugin_name]['active']
def getPluginObject(self, plugin_name):
if not 'object' in self.plugins[plugin_name]:
- return None
- else:
- return self.plugins[plugin_name]['object']
+ self.enablePlugin(plugin_name)
+ #else:
+ return self.plugins[plugin_name]['object']
def getPlugins(self):
self.scanPluginsDir()
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index dc2a4ef..d61407e 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -57,6 +57,8 @@ import orca.settings as settings
#import orca.speech as speech
#import orca.speechserver as speechserver
+
+global speech
speech = _pluginManager.getPluginObject('speech')
if speech == None: import orca.dummyspeech as speech
import orca.speechserver as speechserver
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]