[orca/orca-gnome3: 2/23] Added some usefull methods in dbus server



commit 6566cc4fa8bc61d38a08c635a11bc9aa9c2123f4
Author: José Ignacio �lvarez Ruiz <jialvarez emergya es>
Date:   Tue Mar 22 18:48:02 2011 +0100

    Added some usefull methods in dbus server

 src/orca/dbusserver.py       |   59 ++++++++++++++++++++++++++++++++++--------
 src/orca/settings_manager.py |    3 ++
 2 files changed, 51 insertions(+), 11 deletions(-)
---
diff --git a/src/orca/dbusserver.py b/src/orca/dbusserver.py
index dacd6c2..9804914 100644
--- a/src/orca/dbusserver.py
+++ b/src/orca/dbusserver.py
@@ -30,6 +30,7 @@ import dbus.service
 
 import debug
 import settings
+
 import orca
 _settingsManager = getattr(orca, '_settingsManager')
 
@@ -144,25 +145,61 @@ class Server(dbus.service.Object):
         return result
 
     @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
+                         in_signature='', out_signature='aas')
+    def availableProfiles(self):
+        return _settingsManager._backend.availableProfiles()
+
+    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
+                         in_signature='s', out_signature='a{sv}a{sv}a{sv}')
+    def getPreferences(self, profile):
+        return _settingsManager.getPreferences(profile)
+
+    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
+                         in_signature='s', out_signature='a{sv}')
+    def getGeneralSettings(self, profile='default'):
+        return _settingsManager.getGeneralSettings(profile)
+
+    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
+                         in_signature='s', out_signature='a{sv}')
+    def getPronunciations(self, profile='default'):
+        return _settingsManager.getPronunciations(profile)
+
+    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
+                         in_signature='s', out_signature='a{sv}')
+    def getKeybindings(self, profile='default'):
+        return _settingsManager.getPronunciations(profile)
+
+    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
                          in_signature='s', out_signature='v')
     def getSetting(self, settingName):
-        return str(_settingsManager.getSetting(settingName))
+        return _settingsManager.getSetting(settingName)
 
     @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
-                         in_signature='s', out_signature='s')
-    def getPreferences(self, profile='default'):
-        return str(_settingsManager.getPreferences(profile))
+                         in_signature='sv', out_signature='')
+    def setSetting(self, settingName, settingValue):
+        _settingsManager.setSetting(settingName, settingValue)
 
-    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
-                         in_signature='', out_signature='b')
-    def isFirstStart(self):
-        return _settingsManager.isFirstStart()
+        settingValueToUpdate = {dbus.Boolean:   bool,
+                                dbus.Int32:     int,
+                                dbus.String:    str,
+                                dbus.Double:    float}
+
+        _settingsManager.updateSetting(settingName, 
+                settingValueToUpdate[type(settingValue)](settingValue))
+
+        _settingsManager.saveSettings(_settingsManager.general, 
+                                      _settingsManager.pronunciations, 
+                                      _settingsManager.keybindings)
 
     @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
-                         in_signature='s', out_signature='s')
-    def getGeneralSettings(self, profile='default'):
-        return str(_settingsManager.getGeneralSettings(profile))
+                         in_signature='s', out_signature='')
+    def setProfile(self, profile):
+        _settingsManager.setProfile(profile)
 
+    @dbus.service.method(dbus_interface='org.gnome.Orca.Settings',
+                         in_signature='', out_signature='')
+    def quitOrca(self):
+        orca.quitOrca()
 
 def init():
     """Sets up the Orca DBus service.  This will only take effect once
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index c9576b7..38756db 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -391,6 +391,9 @@ class SettingsManager(object):
         self.profileKeybindings = self.defaultKeybindings.copy()
         self.profileKeybindings.update(keybindings)
 
+    def updateSetting(self, settingName, settingValue):
+        self.general.update({settingName:settingValue})
+
     def saveSettings(self, general, pronunciations, keybindings):
         """Let the active backend to store the default settings and
         the profiles' ones."""



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