[orca/orca-gnome3: 72/87] Fourth speech plugin approximation



commit 3532a0feacaa370cb7dc3ba18712bf6bf3e63d71
Author: Javier Hernández Antúnez <jhernandez emergya es>
Date:   Wed Mar 30 20:16:45 2011 +0200

    Fourth speech plugin approximation

 src/orca/baseplugins/speech.py     |   16 ++++++++++++++--
 src/orca/orca.py                   |    6 +++---
 src/orca/orca_gui_prefs.py         |   17 +++++++++--------
 src/orca/pluglib/plugin_manager.py |   11 +++++------
 src/orca/scripts/default.py        |    2 +-
 5 files changed, 32 insertions(+), 20 deletions(-)
---
diff --git a/src/orca/baseplugins/speech.py b/src/orca/baseplugins/speech.py
index 88294df..bddb0c2 100644
--- a/src/orca/baseplugins/speech.py
+++ b/src/orca/baseplugins/speech.py
@@ -75,7 +75,9 @@ class speechPlugin(IPlugin, IPresenter):
         global ACSS
         global _
         global log
+        global _settingsManager
 
+        import orca.orca as orca
         import orca.settings as settings
         import orca.orca_state as orca_state
         import logging
@@ -92,8 +94,15 @@ class speechPlugin(IPlugin, IPresenter):
         from orca.acss import ACSS
         from orca.orca_i18n import _           # for gettext support
 
-        settings.enableSpeech = True
+        _settingsManager = getattr(orca, '_settingsManager')
+
+        plugins = _settingsManager.getPlugins(_settingsManager.getSetting('activeProfile')[1])
+        print 'estoy en el enable del speech y plugins = ', plugins
+
+        self.isActive = plugins['speech']['active']
 
+        settings.enableSpeech = True
+        self.shutdown()
         self.init()
 
     def getSpeechServerFactories(self):
@@ -246,7 +255,9 @@ class speechPlugin(IPlugin, IPresenter):
         string or an array of arrays of objects returned by a speech
         generator."""
 
-        if settings.silenceSpeech or not settings.enableSpeech:
+        #print "ACTIVO = ", self.isActive
+        if settings.silenceSpeech or not settings.enableSpeech or not \
+                self.isActive:
             return
 
         print "someone has called me to speak %s" % content
@@ -486,6 +497,7 @@ class speechPlugin(IPlugin, IPresenter):
 
     def disable(self):
         settings.enableSpeech = False
+        self.isActive = False
         self.shutdown()
 
 IPlugin.register(speechPlugin)
diff --git a/src/orca/orca.py b/src/orca/orca.py
index e2ef4a0..f7db0be 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -1554,10 +1554,10 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
     # Enable starting plugins
     activeStartingPlugins(activePlugins)
 
-    #print 'el if =', (settings.enableSpeech and 'speech' in activePlugins)
+    speech = _pluginManager.getPluginObject('speech')
 
     if settings.enableSpeech and 'speech' in activePlugins:
-        speech = _pluginManager.getPluginObject('speech')
+        #speech = _pluginManager.getPluginObject('speech')
 #        if speech == None: import dummyspeech as speech
         try:
             speech.init()
@@ -1575,7 +1575,7 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False):
             debug.println(debug.LEVEL_SEVERE,
                           "Could not initialize connection to speech.")
     else:
-        if speech == None: import dummyspeech as speech
+        #if speech == None: import dummyspeech as speech
         debug.println(debug.LEVEL_CONFIGURATION,
                       "Speech module has NOT been initialized.")
 
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index eb417e9..c9692f0 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -60,7 +60,7 @@ _pluginManager = getattr(orca, '_pluginManager')
 
 global speech
 speech = _pluginManager.getPluginObject('speech')
-if speech == None: import dummyspeech as speech
+#if speech == None: import dummyspeech as speech
 import speechserver
 
 # needed to fill the graphical treeview
@@ -2337,7 +2337,7 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         if plugin_name == 'speech':
             self.__updateSpeechTab(active)
-            self.__reloadSpeechModule()
+            self.__reloadSpeechModule(active)
             self.applyButtonClicked(self.get_widget('notebook'))
 
 # nacho's
@@ -2354,14 +2354,15 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
             speechTab.show()
         else:
             speechTab.hide()
-            speech.shutdown()
+            #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 __reloadSpeechModule(self, active):
+        speech.isActive = active
+#        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"""
diff --git a/src/orca/pluglib/plugin_manager.py b/src/orca/pluglib/plugin_manager.py
index 5b63e57..b53666b 100644
--- a/src/orca/pluglib/plugin_manager.py
+++ b/src/orca/pluglib/plugin_manager.py
@@ -123,13 +123,14 @@ class ModulePluginManager(IPluginManager):
         # in the appropiate backend form and if a plugin is active,
         # we will load it
         new_plugins = {}
+
         for path in self.plugin_paths:
             if not path in sys.path:
                 sys.path.insert(0, path)
             for module in [os.path.basename(os.path.splitext(x)[0])
                     for x in glob.glob(os.path.join(path, '[!_]*.py'))]:
                 new_plugins.update(self.inspect_plugin_module(module, path))
-                
+
         new_plugins.update(self.plugins)
         self.plugins = new_plugins
 
@@ -138,13 +139,13 @@ class ModulePluginManager(IPluginManager):
         
         # the idea is not repeat this load unnecessarily
         module = imp.load_module(module_name, modfile, name, desc)
-        
+
         for (the_name, klass) in inspect.getmembers(module, inspect.isclass):
             if issubclass(klass, IPlugin) and the_name != "IPlugin":
                 klass_update = {'class': klass}
                 object_update = {'object': None}
                 type_update = {'type': 'Generic'}
-                dict_plugins.update(type_update)               
+                dict_plugins.update(type_update)
                 dict_plugins.update(klass_update)
                 dict_plugins.update(object_update)
 # nacho's
@@ -153,7 +154,6 @@ class ModulePluginManager(IPluginManager):
 #                dict_plugins.update(type_update) 
 
     def setPluginTypes(self, plugin, module):
-        print module
         types = []
         for (the_name, klass) in inspect.getmembers(module, inspect.isclass):
             if issubclass(plugin['class'], ICommand) and the_name != "ICommand":
@@ -254,7 +254,6 @@ class ModulePluginManager(IPluginManager):
 #            disabling_plugins['active'] = False
 #            self.store_conf.updatePlugin({plugin_name: disabling_plugins})
     
-        
         print "Unloaded module " + str(plugin_name)
             
         # this *only* delete the name from sys.modules,
@@ -305,7 +304,6 @@ class ModulePluginManager(IPluginManager):
 
     plugins = property(plugins_getter, plugins_setter)
 
-
     # Configuration purposes
 
 #    def addPluginConf(self, name, registered, module_name, path):
@@ -329,6 +327,7 @@ class ModulePluginManager(IPluginManager):
         return self.plugins[plugin_name]['active']
 
     def getPluginObject(self, plugin_name):
+        #print "getPluginObject :: '%s'" % plugin_name
         if not 'object' in self.plugins[plugin_name]:
             self.enablePlugin(plugin_name)
         #else:
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index d61407e..44c08b8 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -60,7 +60,7 @@ import orca.settings as settings
 
 global speech
 speech = _pluginManager.getPluginObject('speech')
-if speech == None: import orca.dummyspeech as speech
+#if speech == None: import orca.dummyspeech as speech
 import orca.speechserver as speechserver
 
 import orca.mouse_review as mouse_review



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]