Codebase list mozc / df5acdd
Merge pull request #354 from google/fix_issue_344 Support 'icon_prop_key' entry in ibus-mozc. Yohei Yukawa 8 years ago
2 changed file(s) with 40 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
00 MAJOR=2
11 MINOR=17
2 BUILD=2312
2 BUILD=2313
33 REVISION=102
44 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
55 # downloaded by NaCl Mozc.
5555 'textdomain': 'ibus-mozc',
5656 }
5757
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': '&#x3042;',
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
9758 # A dictionary from --branding to a product name which is embedded into the
9859 # properties above.
9960 PRODUCT_NAMES = {
174135 print CPP_FOOTER % guard_name
175136
176137
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."""
179140 command_line = [options.pkg_config_command, '--exists',
180 'ibus-1.0 >= 1.5.0']
141 'ibus-1.0 >= %s' % minimum_version]
181142 return_code = subprocess.call(command_line)
182143 if return_code == 0:
183144 return True
210171 setup_arg = []
211172 setup_arg.append(os.path.join(options.server_dir, 'mozc_tool'))
212173 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'] = '&#x3042;'
204 engines_props['layout'] = ['default']
217205 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']
224207
225208 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)
228211 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)
231214 return 0
232215
233216 if __name__ == '__main__':