summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2012-07-04 19:46:02 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2012-07-04 19:48:33 +0900
commit84dc1120d2f14cd9cd8d8e36fa352b48c495649a (patch)
treeda9ae26d306ba2b987dc21870a2f95041b50ec27
parentea0c706a7e2f6ccb6dc92d9ef0d0eaa6c23ab920 (diff)
downloadibus-anthy-1.4.y.tar.gz
Fixed MBCS dict file names (#1479)1.4.y
-rw-r--r--engine/engine.py25
-rw-r--r--setup/main.py24
2 files changed, 33 insertions, 16 deletions
diff --git a/engine/engine.py b/engine/engine.py
index f9614dd..8a3d778 100644
--- a/engine/engine.py
+++ b/engine/engine.py
@@ -831,10 +831,12 @@ class Engine(IBus.Engine):
i = prop_name.find('.')
if i < 0:
return
- id = prop_name[i + 1:].encode('utf-8')
+ # The id is already quoted.
+ id = prop_name[i + 1:]
file = None
- files = self.__prefs.get_value('dict', 'files')
+ single_files = self.__get_single_dict_files()
+
if id == 'embedded':
pass
elif id == 'anthy_zipcode' or id == 'ibus_symbol' or \
@@ -842,7 +844,7 @@ class Engine(IBus.Engine):
file = self.__prefs.get_value('dict', id)[0]
else:
found = False
- for file in files:
+ for file in single_files:
if id == self._get_quoted_id(file):
found = True
break
@@ -853,12 +855,16 @@ class Engine(IBus.Engine):
dict_name = 'default'
self.__dict_mode = 0
else:
+ if file not in single_files:
+ print >> sys.stderr, "Index error ", file, single_files
+ return
dict_name = 'ibus__' + id
- self.__dict_mode = files.index(file) + 1
+ self.__dict_mode = single_files.index(file) + 1
self.__prop_dict[prop_name].set_state(state)
self.update_property(self.__prop_dict[prop_name])
self.__context.init_personality()
- self.__context.do_set_personality(dict_name)
+ # dict_name is unicode but the argument is str.
+ self.__context.do_set_personality(str(dict_name))
prop = self.__prop_dict[u'DictMode']
section = 'dict/file/' + id
@@ -1648,13 +1654,18 @@ class Engine(IBus.Engine):
has_mbcs = True
break
if has_mbcs:
- import urllib
- id = urllib.quote(id)
+ id = id.encode('hex')
if id.find('/') >=0:
id = id[id.rindex('/') + 1:]
if id.find('.') >=0:
id = id[:id.rindex('.')]
+
+ if id.startswith('0x'):
+ id = id.encode('hex')
+ has_mbcs = True
+ if has_mbcs:
+ id = '0x' + id
return id
@classmethod
diff --git a/setup/main.py b/setup/main.py
index 0ee846e..d85b248 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -548,33 +548,38 @@ class AnthySetup(object):
has_mbcs = True
break
if has_mbcs:
- import urllib
- id = urllib.quote(id)
+ id = id.encode('hex')
if id.find('/') >=0:
id = id[id.rindex('/') + 1:]
if id.find('.') >=0:
id = id[:id.rindex('.')]
+
+ if id.startswith('0x'):
+ id = id.encode('hex')
+ has_mbcs = True
+ if has_mbcs:
+ id = '0x' + id
return id
def __get_dict_file_from_id(self, selected_id):
- found = False
- files = self.prefs.get_value('dict', 'files')
-
if selected_id == 'anthy_zipcode':
return self.prefs.get_value('dict', 'anthy_zipcode')[0]
elif selected_id == 'ibus_symbol':
return self.prefs.get_value('dict', 'ibus_symbol')[0]
elif selected_id == 'ibus_oldchar':
return self.prefs.get_value('dict', 'ibus_oldchar')[0]
+
+ files = self.prefs.get_value('dict', 'files')
+ retval = None
+
for file in files:
id = self.__get_quoted_id(file)
+ # The selected_id is already quoted.
if selected_id == id:
- found = True
+ retval = file
break
- if found:
- return file
- return None
+ return retval
def __is_system_dict_file_from_id(self, selected_id):
prefs = self.prefs
@@ -1139,6 +1144,7 @@ class AnthySetup(object):
if dict_file == None:
return
+ # The selected id is already quoted.
section = 'dict/file/' + selected_id
if 'preview_lines' not in self.prefs.keys(section):
section = 'dict/file/default'