55 | 55 |
'textdomain': 'ibus-mozc',
|
56 | 56 |
}
|
57 | 57 |
|
58 | |
# Information to generate <engines> part of mozc.xml.
|
59 | |
IBUS_ENGINE_COMMON_PROPS = {
|
60 | |
'description': '%(product_name)s (Japanese Input Method)',
|
61 | |
'language': 'ja',
|
62 | |
'icon': '%(ibus_mozc_icon_path)s',
|
63 | |
'rank': '80',
|
64 | |
}
|
65 | |
|
66 | |
# Information to generate <engines> part of mozc.xml for IBus 1.5 or later.
|
67 | |
IBUS_1_5_ENGINE_COMMON_PROPS = {
|
68 | |
'description': '%(product_name)s (Japanese Input Method)',
|
69 | |
'language': 'ja',
|
70 | |
'icon': '%(ibus_mozc_icon_path)s',
|
71 | |
'rank': '80',
|
72 | |
'symbol': 'あ',
|
73 | |
}
|
74 | |
|
75 | |
# A dictionary from platform to engines that are used in the platform. The
|
76 | |
# information is used to generate <engines> part of mozc.xml.
|
77 | |
IBUS_ENGINES_PROPS = {
|
78 | |
# On Linux, we provide only one engine for the Japanese keyboard layout.
|
79 | |
'Linux': {
|
80 | |
# DO NOT change the engine name 'mozc-jp'. The names is referenced by
|
81 | |
# unix/ibus/mozc_engine.cc.
|
82 | |
'name': ['mozc-jp'],
|
83 | |
'longname': ['%(product_name)s'],
|
84 | |
'layout': ['jp'],
|
85 | |
},
|
86 | |
# On Linux (IBus >= 1.5), we use special label 'default' for the keyboard
|
87 | |
# layout.
|
88 | |
'Linux-IBus1.5': {
|
89 | |
# DO NOT change the engine name 'mozc-jp'. The names is referenced by
|
90 | |
# unix/ibus/mozc_engine.cc.
|
91 | |
'name': ['mozc-jp'],
|
92 | |
'longname': ['%(product_name)s'],
|
93 | |
'layout': ['default'],
|
94 | |
},
|
95 | |
}
|
96 | |
|
97 | 58 |
# A dictionary from --branding to a product name which is embedded into the
|
98 | 59 |
# properties above.
|
99 | 60 |
PRODUCT_NAMES = {
|
|
174 | 135 |
print CPP_FOOTER % guard_name
|
175 | 136 |
|
176 | 137 |
|
177 | |
def IsIBus15OrGreater(options):
|
178 | |
"""Returns True when the version of ibus-1.0 is 1.5 or greater."""
|
|
138 |
def CheckIBusVersion(options, minimum_version):
|
|
139 |
"""Tests if ibus version is equal to or greater than the given value."""
|
179 | 140 |
command_line = [options.pkg_config_command, '--exists',
|
180 | |
'ibus-1.0 >= 1.5.0']
|
|
141 |
'ibus-1.0 >= %s' % minimum_version]
|
181 | 142 |
return_code = subprocess.call(command_line)
|
182 | 143 |
if return_code == 0:
|
183 | 144 |
return True
|
|
210 | 171 |
setup_arg = []
|
211 | 172 |
setup_arg.append(os.path.join(options.server_dir, 'mozc_tool'))
|
212 | 173 |
setup_arg.append('--mode=config_dialog')
|
213 | |
if IsIBus15OrGreater(options):
|
214 | |
# A tentative workaround against IBus 1.5
|
215 | |
platform = 'Linux-IBus1.5'
|
216 | |
common_props = IBUS_1_5_ENGINE_COMMON_PROPS
|
|
174 |
|
|
175 |
param_dict = {
|
|
176 |
'product_name': PRODUCT_NAMES[options.branding],
|
|
177 |
'ibus_mozc_path': options.ibus_mozc_path,
|
|
178 |
'ibus_mozc_icon_path': options.ibus_mozc_icon_path,
|
|
179 |
}
|
|
180 |
|
|
181 |
engine_common_props = {
|
|
182 |
'description': '%(product_name)s (Japanese Input Method)',
|
|
183 |
'language': 'ja',
|
|
184 |
'icon': '%(ibus_mozc_icon_path)s',
|
|
185 |
'rank': '80',
|
|
186 |
}
|
|
187 |
|
|
188 |
# DO NOT change the engine name 'mozc-jp'. The names is referenced by
|
|
189 |
# unix/ibus/mozc_engine.cc.
|
|
190 |
engines_props = {
|
|
191 |
'name': ['mozc-jp'],
|
|
192 |
'longname': ['%(product_name)s'],
|
|
193 |
}
|
|
194 |
|
|
195 |
# IBus 1.5.11 and greater supports 'icon_prop_key'.
|
|
196 |
# See ibus/ibus@23c45b970b195008a54884a1a9d810e7f8b22c5c
|
|
197 |
if CheckIBusVersion(options, '1.5.11'):
|
|
198 |
# Make sure that the property key 'InputMode' matches to the property name
|
|
199 |
# specified to |ibus_property_new| in unix/ibus/property_handler.cc
|
|
200 |
engine_common_props['icon_prop_key'] = 'InputMode'
|
|
201 |
|
|
202 |
if CheckIBusVersion(options, '1.5.0'):
|
|
203 |
engine_common_props['symbol'] = 'あ'
|
|
204 |
engines_props['layout'] = ['default']
|
217 | 205 |
else:
|
218 | |
platform = 'Linux'
|
219 | |
common_props = IBUS_ENGINE_COMMON_PROPS
|
220 | |
|
221 | |
param_dict = {'product_name': PRODUCT_NAMES[options.branding],
|
222 | |
'ibus_mozc_path': options.ibus_mozc_path,
|
223 | |
'ibus_mozc_icon_path': options.ibus_mozc_icon_path}
|
|
206 |
engines_props['layout'] = ['jp']
|
224 | 207 |
|
225 | 208 |
if options.output_cpp:
|
226 | |
OutputCpp(param_dict, IBUS_COMPONENT_PROPS, common_props,
|
227 | |
IBUS_ENGINES_PROPS[platform])
|
|
209 |
OutputCpp(param_dict, IBUS_COMPONENT_PROPS, engine_common_props,
|
|
210 |
engines_props)
|
228 | 211 |
else:
|
229 | |
OutputXml(param_dict, IBUS_COMPONENT_PROPS, common_props,
|
230 | |
IBUS_ENGINES_PROPS[platform], setup_arg)
|
|
212 |
OutputXml(param_dict, IBUS_COMPONENT_PROPS, engine_common_props,
|
|
213 |
engines_props, setup_arg)
|
231 | 214 |
return 0
|
232 | 215 |
|
233 | 216 |
if __name__ == '__main__':
|