Skip to content

Commit 2628af6

Browse files
committed
Support 'icon_prop_key' entry in ibus-mozc.
Fixes #344. Showing a status icon instead of the IME's product icon is a new feature introduced by ibus/ibus@23c45b9 and has been available since IBus 1.5.11. Hence this CL adds 'icon_prop_key' to mozc.xml when the IBus version is 1.5.11 or later. Although supporting new IBus feature is not our goal any more, supporting his feature before we delete ibus-mozc in #287 may help some people. One thing you should keep in mind is that the version of IBus is checked at build time, not run-time. This means that if you upgrade IBus from 1.5.10 or prior to 1.5.11 or later then you have to rebuild ibus-mozc so that mozc.xml can be updated. BUG=#344 TEST=manually done on Fedora 23 KDE Plasma Desktop. REF_BUG= REF_CL=111381977
1 parent 0f2711e commit 2628af6

File tree

2 files changed

+40
-57
lines changed

2 files changed

+40
-57
lines changed

src/mozc_version_template.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MAJOR=2
22
MINOR=17
3-
BUILD=2312
3+
BUILD=2313
44
REVISION=102
55
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
66
# downloaded by NaCl Mozc.

src/unix/ibus/gen_mozc_xml.py

+39-56
Original file line numberDiff line numberDiff line change
@@ -56,45 +56,6 @@
5656
'textdomain': 'ibus-mozc',
5757
}
5858

59-
# Information to generate <engines> part of mozc.xml.
60-
IBUS_ENGINE_COMMON_PROPS = {
61-
'description': '%(product_name)s (Japanese Input Method)',
62-
'language': 'ja',
63-
'icon': '%(ibus_mozc_icon_path)s',
64-
'rank': '80',
65-
}
66-
67-
# Information to generate <engines> part of mozc.xml for IBus 1.5 or later.
68-
IBUS_1_5_ENGINE_COMMON_PROPS = {
69-
'description': '%(product_name)s (Japanese Input Method)',
70-
'language': 'ja',
71-
'icon': '%(ibus_mozc_icon_path)s',
72-
'rank': '80',
73-
'symbol': '&#x3042;',
74-
}
75-
76-
# A dictionary from platform to engines that are used in the platform. The
77-
# information is used to generate <engines> part of mozc.xml.
78-
IBUS_ENGINES_PROPS = {
79-
# On Linux, we provide only one engine for the Japanese keyboard layout.
80-
'Linux': {
81-
# DO NOT change the engine name 'mozc-jp'. The names is referenced by
82-
# unix/ibus/mozc_engine.cc.
83-
'name': ['mozc-jp'],
84-
'longname': ['%(product_name)s'],
85-
'layout': ['jp'],
86-
},
87-
# On Linux (IBus >= 1.5), we use special label 'default' for the keyboard
88-
# layout.
89-
'Linux-IBus1.5': {
90-
# DO NOT change the engine name 'mozc-jp'. The names is referenced by
91-
# unix/ibus/mozc_engine.cc.
92-
'name': ['mozc-jp'],
93-
'longname': ['%(product_name)s'],
94-
'layout': ['default'],
95-
},
96-
}
97-
9859
# A dictionary from --branding to a product name which is embedded into the
9960
# properties above.
10061
PRODUCT_NAMES = {
@@ -175,10 +136,10 @@ def OutputCpp(param_dict, component, engine_common, engines):
175136
print CPP_FOOTER % guard_name
176137

177138

178-
def IsIBus15OrGreater(options):
179-
"""Returns True when the version of ibus-1.0 is 1.5 or greater."""
139+
def CheckIBusVersion(options, minimum_version):
140+
"""Tests if ibus version is equal to or greater than the given value."""
180141
command_line = [options.pkg_config_command, '--exists',
181-
'ibus-1.0 >= 1.5.0']
142+
'ibus-1.0 >= %s' % minimum_version]
182143
return_code = subprocess.call(command_line)
183144
if return_code == 0:
184145
return True
@@ -211,24 +172,46 @@ def main():
211172
setup_arg = []
212173
setup_arg.append(os.path.join(options.server_dir, 'mozc_tool'))
213174
setup_arg.append('--mode=config_dialog')
214-
if IsIBus15OrGreater(options):
215-
# A tentative workaround against IBus 1.5
216-
platform = 'Linux-IBus1.5'
217-
common_props = IBUS_1_5_ENGINE_COMMON_PROPS
218-
else:
219-
platform = 'Linux'
220-
common_props = IBUS_ENGINE_COMMON_PROPS
221175

222-
param_dict = {'product_name': PRODUCT_NAMES[options.branding],
223-
'ibus_mozc_path': options.ibus_mozc_path,
224-
'ibus_mozc_icon_path': options.ibus_mozc_icon_path}
176+
param_dict = {
177+
'product_name': PRODUCT_NAMES[options.branding],
178+
'ibus_mozc_path': options.ibus_mozc_path,
179+
'ibus_mozc_icon_path': options.ibus_mozc_icon_path,
180+
}
181+
182+
engine_common_props = {
183+
'description': '%(product_name)s (Japanese Input Method)',
184+
'language': 'ja',
185+
'icon': '%(ibus_mozc_icon_path)s',
186+
'rank': '80',
187+
}
188+
189+
# DO NOT change the engine name 'mozc-jp'. The names is referenced by
190+
# unix/ibus/mozc_engine.cc.
191+
engines_props = {
192+
'name': ['mozc-jp'],
193+
'longname': ['%(product_name)s'],
194+
}
195+
196+
# IBus 1.5.11 and greater supports 'icon_prop_key'.
197+
# See ibus/ibus@23c45b970b195008a54884a1a9d810e7f8b22c5c
198+
if CheckIBusVersion(options, '1.5.11'):
199+
# Make sure that the property key 'InputMode' matches to the property name
200+
# specified to |ibus_property_new| in unix/ibus/property_handler.cc
201+
engine_common_props['icon_prop_key'] = 'InputMode'
202+
203+
if CheckIBusVersion(options, '1.5.0'):
204+
engine_common_props['symbol'] = '&#x3042;'
205+
engines_props['layout'] = ['default']
206+
else:
207+
engines_props['layout'] = ['jp']
225208

226209
if options.output_cpp:
227-
OutputCpp(param_dict, IBUS_COMPONENT_PROPS, common_props,
228-
IBUS_ENGINES_PROPS[platform])
210+
OutputCpp(param_dict, IBUS_COMPONENT_PROPS, engine_common_props,
211+
engines_props)
229212
else:
230-
OutputXml(param_dict, IBUS_COMPONENT_PROPS, common_props,
231-
IBUS_ENGINES_PROPS[platform], setup_arg)
213+
OutputXml(param_dict, IBUS_COMPONENT_PROPS, engine_common_props,
214+
engines_props, setup_arg)
232215
return 0
233216

234217
if __name__ == '__main__':

0 commit comments

Comments
 (0)