[Sugar-devel] [PATCH 2/2] Only activate keyboard configuration if it was configured, OLPC #11175

Daniel Drake dsd at laptop.org
Thu Oct 6 10:59:29 EDT 2011


Sugar is currently activing a new keyboard config even if the user
did not change any settings.

Avoid this by only activating the configuration if user-specified
settings are found in gconf. Also remove the default 'evdev' model
string so that gconf settings are truly blank unless the user has
selected something.

This fixes the case where keyboard settings were configured elsewhere,
but Sugar ends up throwing those away and applying its own 'blank'
settings.
---
 bin/sugar-session     |    7 ++++++-
 data/sugar.schemas.in |    1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/sugar-session b/bin/sugar-session
index a0ec14f..8ea195f 100755
--- a/bin/sugar-session
+++ b/bin/sugar-session
@@ -127,6 +127,7 @@ def setup_keyboard_cb():
     logging.debug('STARTUP: setup_keyboard_cb')
 
     gconf_client = gconf.client_get_default()
+    have_config = False
 
     try:
         display = gtk.gdk.display_get_default()
@@ -148,20 +149,24 @@ def setup_keyboard_cb():
             variants_list.append(layout.split('(')[1][:-1])
 
         if layouts_list and variants_list:
+            have_config = True
             configrec.set_layouts(layouts_list)
             configrec.set_variants(variants_list)
 
         model = gconf_client.get_string(\
             '/desktop/sugar/peripherals/keyboard/model')
         if model:
+            have_config = True
             configrec.set_model(model)
 
         options = gconf_client.get_list(\
             '/desktop/sugar/peripherals/keyboard/options', gconf.VALUE_STRING)
         if options:
+            have_config = True
             configrec.set_options(options)
 
-        configrec.activate(engine)
+        if have_config:
+            configrec.activate(engine)
     except Exception:
         logging.exception('Error during keyboard configuration')
 
diff --git a/data/sugar.schemas.in b/data/sugar.schemas.in
index b13f746..8b3e1ad 100644
--- a/data/sugar.schemas.in
+++ b/data/sugar.schemas.in
@@ -232,7 +232,6 @@
       <applyto>/desktop/sugar/peripherals/keyboard/model</applyto>
       <owner>sugar</owner>
       <type>string</type>
-      <default>evdev</default>
       <locale name="C">
         <short>Keyboard model</short>
         <long>The keyboard model to be used</long>
-- 
1.7.6.4



More information about the Sugar-devel mailing list