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

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