Blame SOURCES/0001-Changes-in-dconf-values-now-get-applied-immediately.patch

b385cc
From fdda5c156d851446497bb042e1614ef1c55d9e92 Mon Sep 17 00:00:00 2001
b385cc
From: Mike FABIAN <mfabian@redhat.com>
b385cc
Date: Thu, 10 Jan 2013 11:37:59 +0100
b385cc
Subject: [PATCH] Changes in dconf values now get applied immediately
b385cc
b385cc
Changing values of dconf keys for example with
b385cc
b385cc
   dconf write /desktop/ibus/engine/table/cangjie3/chinesemode 3
b385cc
b385cc
was not applied immediately to the ibus-table engine, only
b385cc
when changing to a different input method and back this
b385cc
change was applied.
b385cc
b385cc
This commit fixes this problem.
b385cc
---
b385cc
 engine/table.py | 72 ++++++++++++++++++++++++++++++++++++++++++---------------
b385cc
 1 file changed, 53 insertions(+), 19 deletions(-)
b385cc
b385cc
diff --git a/engine/table.py b/engine/table.py
b385cc
index e171949..24ca921 100644
b385cc
--- a/engine/table.py
b385cc
+++ b/engine/table.py
b385cc
@@ -26,6 +26,7 @@ __all__ = (
b385cc
 )
b385cc
 
b385cc
 import os
b385cc
+import string
b385cc
 from gi.repository import IBus
b385cc
 from gi.repository import GLib
b385cc
 from curses import ascii
b385cc
@@ -1894,27 +1895,60 @@ class tabengine (IBus.Engine):
b385cc
             return True
b385cc
         return False
b385cc
 
b385cc
+    def config_section_normalize(self, section):
b385cc
+        # This function replaces _: with - in the dconf
b385cc
+        # section and converts to lower case to make
b385cc
+        # the comparison of the dconf sections work correctly.
b385cc
+        # I avoid using .lower() here because it is locale dependent,
b385cc
+        # when using .lower() this would not achieve the desired
b385cc
+        # effect of comparing the dconf sections case insentively
b385cc
+        # in some locales, it would fail for example if Turkish
b385cc
+        # locale (tr_TR.UTF-8) is set.
b385cc
+        if type(section) == type(u''):
b385cc
+            # translate() does not work in Python’s internal Unicode type
b385cc
+            section = section.encode('utf-8')
b385cc
+        return re.sub(r'[_:]', r'-', section).translate(
b385cc
+            string.maketrans(string.ascii_uppercase, string.ascii_lowercase ))
b385cc
+
b385cc
     def config_value_changed_cb (self, config, section, name, value):
b385cc
+        if self.config_section_normalize(self._config_section) != self.config_section_normalize(section):
b385cc
+            return
b385cc
+        print "config value %(n)s for engine %(en)s changed" %{'n': name, 'en': self._name}
b385cc
         value = variant_to_value(value)
b385cc
-        if section == self._config_section:
b385cc
-            if name == u'AutoCommit':
b385cc
-                self._auto_commit = value
b385cc
-            elif name == u'ChineseMode':
b385cc
-                self._editor._chinese_mode = value
b385cc
-            elif name == u'EnDefFullWidthLetter':
b385cc
-                self._full_width_letter[0] = value
b385cc
-            elif name == u'EnDefFullWidthPunct':
b385cc
-                self._full_width_punct[0] = value
b385cc
-            elif name == u'LookupTableOrientation':
b385cc
-                self._editor._lookup_table.set_orientation (value)
b385cc
-            elif name == u'LookupTableSelectKeys':
b385cc
-                self._editor.set_select_keys (value)
b385cc
-            elif name == u'OneChar':
b385cc
-                self._editor._onechar = value
b385cc
-            elif name == u'TabDefFullWidthLetter':
b385cc
-                self._full_width_letter[1] = value
b385cc
-            elif name == u'TabDefFullWidthPunct':
b385cc
-                self._full_width_punct[1] = value
b385cc
+        if name == u'autocommit':
b385cc
+            self._auto_commit = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
+        elif name == u'chinesemode':
b385cc
+            self._editor._chinese_mode = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
+        elif name == u'endeffullwidthletter':
b385cc
+            self._full_width_letter[0] = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
+        elif name == u'endeffullwidthpunct':
b385cc
+            self._full_width_punct[0] = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
+        elif name == u'lookuptableorientation':
b385cc
+            self._editor._lookup_table.set_orientation (value)
b385cc
+            return
b385cc
+        elif name == u'lookuptableselectkeys':
b385cc
+            self._editor.set_select_keys (value)
b385cc
+            return
b385cc
+        elif name == u'onechar':
b385cc
+            self._editor._onechar = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
+        elif name == u'tabdeffullwidthletter':
b385cc
+            self._full_width_letter[1] = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
+        elif name == u'tabdeffullwidthpunct':
b385cc
+            self._full_width_punct[1] = value
b385cc
+            self._refresh_properties()
b385cc
+            return
b385cc
 
b385cc
     # for further implementation :)
b385cc
     @classmethod
b385cc
-- 
b385cc
1.7.11.7
b385cc