|
56 | 56 | 'textdomain': 'ibus-mozc',
|
57 | 57 | }
|
58 | 58 |
|
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': 'あ', |
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 |
| - |
98 | 59 | # A dictionary from --branding to a product name which is embedded into the
|
99 | 60 | # properties above.
|
100 | 61 | PRODUCT_NAMES = {
|
@@ -175,10 +136,10 @@ def OutputCpp(param_dict, component, engine_common, engines):
|
175 | 136 | print CPP_FOOTER % guard_name
|
176 | 137 |
|
177 | 138 |
|
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.""" |
180 | 141 | command_line = [options.pkg_config_command, '--exists',
|
181 |
| - 'ibus-1.0 >= 1.5.0'] |
| 142 | + 'ibus-1.0 >= %s' % minimum_version] |
182 | 143 | return_code = subprocess.call(command_line)
|
183 | 144 | if return_code == 0:
|
184 | 145 | return True
|
@@ -211,24 +172,46 @@ def main():
|
211 | 172 | setup_arg = []
|
212 | 173 | setup_arg.append(os.path.join(options.server_dir, 'mozc_tool'))
|
213 | 174 | 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 |
221 | 175 |
|
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'] = 'あ' |
| 205 | + engines_props['layout'] = ['default'] |
| 206 | + else: |
| 207 | + engines_props['layout'] = ['jp'] |
225 | 208 |
|
226 | 209 | 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) |
229 | 212 | 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) |
232 | 215 | return 0
|
233 | 216 |
|
234 | 217 | if __name__ == '__main__':
|
|
0 commit comments