Attachments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #1341: sugar-1341.patch

File sugar-1341.patch, 6.2 KB (added by alsroot, 4 years ago)
  • extensions/cpsection/keyboard/model.py

    From d1d5e650b4715433e9daad4c6599597ca41dc66a Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Wed, 16 Sep 2009 12:01:27 +0000
    Subject: Sugar craches during undo for the first Keyboard component startup #1341
    
    ---
     extensions/cpsection/keyboard/model.py |   13 +++--
     extensions/cpsection/keyboard/p        |   88 ++++++++++++++++++++++++++++++++
     extensions/cpsection/keyboard/view.py  |    2 +-
     3 files changed, 98 insertions(+), 5 deletions(-)
     create mode 100644 extensions/cpsection/keyboard/p
    
    diff --git a/extensions/cpsection/keyboard/model.py b/extensions/cpsection/keyboard/model.py
    index a5721cd..dcfbc13 100644
    a b  
    8787        if model: 
    8888            return model 
    8989        else: 
    90             return self._configrec.get_model() 
     90            model = self._configrec.get_model() 
     91            self.set_model(model) 
     92            return model 
    9193 
    9294    def get_current_layouts(self): 
    9395        """Return the enabled keyboard layouts with variants""" 
     
    107109                layout_list.append('%s(%s)' % (layout, variants[i])) 
    108110            i += 1 
    109111 
     112        self.set_layouts(layout_list) 
     113 
    110114        return layout_list 
    111115 
    112116    def get_current_option_group(self): 
    113117        """Return the enabled option for switching keyboard group""" 
    114118        options = self._gconf_client.get_list(_OPTIONS_KEY, gconf.VALUE_STRING) 
    115          
     119 
    116120        if not options: 
    117121            options = self._configrec.get_options() 
     122            self.set_option_group(options) 
    118123 
    119124        for option in options: 
    120125            if option.startswith(_GROUP_NAME): 
    121126                return option 
    122          
     127 
    123128        return None 
    124129     
    125130    def get_max_layouts(self): 
     
    135140    def set_option_group(self, option_group): 
    136141        """Sets the supplied option for switching keyboard group""" 
    137142        #XXX: Merge, not overwrite previous options 
    138         options = [option_group] 
     143        options = [option_group or '' ] 
    139144        self._gconf_client.set_list(_OPTIONS_KEY, gconf.VALUE_STRING, options) 
    140145        self._configrec.set_options(options) 
    141146        self._configrec.activate(self._engine) 
  • (a) /dev/null vs. (b) b/extensions/cpsection/keyboard/p

    diff --git a/extensions/cpsection/keyboard/p b/extensions/cpsection/keyboard/p
    new file mode 100644
    index 0000000..fdf9a64
    a b  
     1diff --git a/extensions/cpsection/keyboard/model.py b/extensions/cpsection/keyboard/model.py 
     2index a5721cd..ab2cd88 100644 
     3--- a/extensions/cpsection/keyboard/model.py 
     4+++ b/extensions/cpsection/keyboard/model.py 
     5@@ -18,6 +18,7 @@ 
     6  
     7 import xklavier 
     8 import gconf 
     9+import logging 
     10  
     11  
     12 _GROUP_NAME = 'grp' # The XKB name for group switch options 
     13@@ -87,7 +88,10 @@ class KeyboardManager(object): 
     14         if model: 
     15             return model 
     16         else: 
     17-            return self._configrec.get_model() 
     18+            model = self._configrec.get_model() 
     19+            logging.error('> %r', model) 
     20+            self._gconf_client.set_string(_MODEL_KEY, model) 
     21+            return model 
     22  
     23     def get_current_layouts(self): 
     24         """Return the enabled keyboard layouts with variants""" 
     25@@ -107,14 +111,21 @@ class KeyboardManager(object): 
     26                 layout_list.append('%s(%s)' % (layout, variants[i])) 
     27             i += 1 
     28  
     29+        logging.error('>> %r', layout_list) 
     30+        self._gconf_client.set_list(_LAYOUTS_KEY, gconf.VALUE_STRING, 
     31+                layout_list) 
     32+ 
     33         return layout_list 
     34  
     35     def get_current_option_group(self): 
     36         """Return the enabled option for switching keyboard group""" 
     37         options = self._gconf_client.get_list(_OPTIONS_KEY, gconf.VALUE_STRING) 
     38-         
     39+ 
     40         if not options: 
     41             options = self._configrec.get_options() 
     42+            logging.error('>>> %r', options) 
     43+            self._gconf_client.set_list(_OPTIONS_KEY, gconf.VALUE_STRING, 
     44+                    options) 
     45  
     46         for option in options: 
     47             if option.startswith(_GROUP_NAME): 
     48@@ -128,6 +139,7 @@ class KeyboardManager(object): 
     49  
     50     def set_model(self, model): 
     51         """Sets the supplied keyboard model""" 
     52+        logging.error('-> %r', model) 
     53         self._gconf_client.set_string(_MODEL_KEY, model) 
     54         self._configrec.set_model(model) 
     55         self._configrec.activate(self._engine) 
     56@@ -135,13 +147,18 @@ class KeyboardManager(object): 
     57     def set_option_group(self, option_group): 
     58         """Sets the supplied option for switching keyboard group""" 
     59         #XXX: Merge, not overwrite previous options 
     60-        options = [option_group] 
     61+        if option_group is None: 
     62+            options = [] 
     63+        else: 
     64+            options = [option_group] 
     65+        logging.error('->>> %r', options) 
     66         self._gconf_client.set_list(_OPTIONS_KEY, gconf.VALUE_STRING, options) 
     67         self._configrec.set_options(options) 
     68         self._configrec.activate(self._engine) 
     69  
     70     def set_layouts(self, layouts): 
     71         """Sets the supplied keyboard layouts (with variants)""" 
     72+        logging.error('->> %r', layouts) 
     73         self._gconf_client.set_list(_LAYOUTS_KEY, gconf.VALUE_STRING, layouts) 
     74         layouts_list = [] 
     75         variants_list = [] 
     76diff --git a/extensions/cpsection/keyboard/view.py b/extensions/cpsection/keyboard/view.py 
     77index 04edc4d..074d298 100644 
     78--- a/extensions/cpsection/keyboard/view.py 
     79+++ b/extensions/cpsection/keyboard/view.py 
     80@@ -30,7 +30,7 @@ CLASS = 'Language' 
     81 ICON = 'module-keyboard' 
     82 TITLE = _('Keyboard') 
     83  
     84-_APPLY_TIMEOUT = 3000 
     85+_APPLY_TIMEOUT = 500 
     86  
     87 #TODO: This cpsection adds checks for xklavier in bin/sugar-session and 
     88 #      src/jarabe/controlpanel/gui.py. We should get rid of these checks 
  • extensions/cpsection/keyboard/view.py

    diff --git a/extensions/cpsection/keyboard/view.py b/extensions/cpsection/keyboard/view.py
    index 04edc4d..074d298 100644
    a b  
    3030ICON = 'module-keyboard' 
    3131TITLE = _('Keyboard') 
    3232 
    33 _APPLY_TIMEOUT = 3000 
     33_APPLY_TIMEOUT = 500 
    3434 
    3535#TODO: This cpsection adds checks for xklavier in bin/sugar-session and 
    3636#      src/jarabe/controlpanel/gui.py. We should get rid of these checks