diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 05:42:10 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 05:42:10 +0000 |
commit | 1836f91d8ef47e9f7b36c640e41c83f56897d09d (patch) | |
tree | 367cb113073913cde7e35a280453d2ed919b8a47 | |
parent | 7ad52b960b4eaac9dfa83e241dc3ba0d89485035 (diff) | |
download | chromium_src-1836f91d8ef47e9f7b36c640e41c83f56897d09d.zip chromium_src-1836f91d8ef47e9f7b36c640e41c83f56897d09d.tar.gz chromium_src-1836f91d8ef47e9f7b36c640e41c83f56897d09d.tar.bz2 |
Update the overlay generation script to support outputting a list of layouts
that use altgr
BUG=chromium-os:10091
TEST=Run gen_keyboard_overlay_data.py --altgr, and check that it outputs a list of layout names.
Review URL: http://codereview.chromium.org/6835012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81371 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py index 6757363..5059c68 100755 --- a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py +++ b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py @@ -17,6 +17,9 @@ and output the data depending on the option. --js: Generates a JavaScript file used as chrome/browser/resources/keyboard_overlay/keyboard_overlay_data.js + --altgr: Generates a list of layouts to be inserted into + chrome/browser/chromeos/input_method/xkeyboard.cc + These options can be specified at the same time, and the files are generated with corresponding extensions appended at the end of the name specified by @@ -62,6 +65,11 @@ CC_SNIPPET_TEMPLATE=""" localized_strings.SetString("%s", l10n_util::GetStringUTF16(%s)); """ +ALTGR_TEMPLATE="""// These layouts shouldn't remap the right alt key. +const char *kKeepRightAltLayouts[] = { +%s +}; +""" def SplitBehavior(behavior): """Splits the behavior to compose a message or i18n-content value. @@ -137,6 +145,8 @@ def ParseOptions(): help='Output resource file.') parser.add_option('--cc', dest='cc', default=False, action='store_true', help='Output cc file.') + parser.add_option('--altgr', dest='altgr', default=False, action='store_true', + help='Output altgr file.') parser.add_option('--out', dest='out', default='keyboard_overlay_data', help='The output file name without extension.') (options, unused_args) = parser.parse_args() @@ -145,8 +155,8 @@ def ParseOptions(): print 'google.com account is necessary to use this script.' sys.exit(-1) - if (not (options.js or options.grd or options.cc)): - print 'Either --js, --grd or --cc needs to be specified.' + if (not (options.js or options.grd or options.cc or options.altgr)): + print 'Either --js, --grd, --cc or --altgr needs to be specified.' sys.exit(-1) # Get the password from the terminal, if needed. @@ -212,7 +222,8 @@ def FetchSpreadsheetFeeds(client, key, sheets, cols): def FetchKeyboardGlyphData(client): """Fetches the keyboard glyph data from the spreadsheet.""" - languages = ['en_US', 'en_US_colemak', 'en_US_dvorak', 'ar', 'ar_fr', 'bg', + languages = ['en_US', 'en_US_colemak', 'en_US_dvorak', 'en_US_intl', + 'en_US_altgr_intl', 'ar', 'ar_fr', 'bg', 'ca', 'cs', 'da', 'de', 'de_neo', 'el', 'en_fr_hybrid_CA', 'en_GB', 'es', 'es_419', 'et', 'fi', 'fil', 'fr', 'fr_CA', 'hi', 'hr', 'hu', 'id', 'it', 'iw', 'ja', 'ko', 'lt', 'lv', 'nl', 'no', @@ -323,20 +334,40 @@ def OutputCC(hotkey_data, outfile): ToMessageName(behavior))) +def OutputAltGr(keyboard_glyph_data, outfile): + """Outputs the keyboard overlay data as a JSON file.""" + print 'Generating: %s' % outfile + output = [] + for layout in keyboard_glyph_data.keys(): + try: + right_alt = keyboard_glyph_data[layout]["keys"]["E0 38"]["key"].strip() + if right_alt.lower() == "alt gr": + output.append(' "%s",' % layout) + except KeyError: + pass + out = file(outfile, 'w') + out.write(ALTGR_TEMPLATE % "\n".join(output)) + + + def main(): options = ParseOptions() client = InitClient(options) hotkey_data = FetchHotkeyData(client) + if options.js or options.altgr: + keyboard_glyph_data = FetchKeyboardGlyphData(client) + if options.js: layouts = FetchLayoutsData(client) - keyboard_glyph_data = FetchKeyboardGlyphData(client) OutputJson(keyboard_glyph_data, hotkey_data, layouts, 'keyboardOverlayData', options.out + '.js') if options.grd: OutputGrd(hotkey_data, options.out + '.grd') if options.cc: OutputCC(hotkey_data, options.out + '.cc') + if options.altgr: + OutputAltGr(keyboard_glyph_data, options.out + '.altgr') if __name__ == '__main__': |