Commit 425fe782 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Add toggle English.

parent aa883159
......@@ -55,6 +55,7 @@ class InscriptKeyboard(object):
self.__keyboard.connect('key-pressed', self.__key_pressed_cb)
self.__keyboard.connect('key-released', self.__key_released_cb)
self.__virtkey = virtkey.virtkey()
self.__english = False
def enable(self):
self.__eekboard.push_context(self.__context)
......@@ -66,15 +67,26 @@ class InscriptKeyboard(object):
self.__context.show_keyboard()
def set_group(self, group):
self.__context.set_group(group)
self.__group = group
self.__context.set_group(self.__group)
def __key_pressed_cb(self, keyboard, key):
if key.get_keycode() == 37:
return
symbol = key.get_symbol()
if isinstance(symbol, eekboard.Keysym):
xkeysym = symbol.get_xkeysym()
self.__virtkey.press_keysym(xkeysym)
def __key_released_cb(self, keyboard, key):
if key.get_keycode() == 37:
if self.__english:
self.__context.set_group(self.__group)
self.__english = False
else:
self.__context.set_group(0)
self.__english = True
return
symbol = key.get_symbol()
if isinstance(symbol, eekboard.Keysym):
xkeysym = symbol.get_xkeysym()
......@@ -90,12 +102,13 @@ if __name__ == "__main__":
help="Specify language code to LANGCODE",
metavar="LANGCODE")
(options, args) = parser.parse_args()
group = 0
group = 1
if options.langcode:
group = None
for index, langcode in enumerate(GROUPS):
if langcode.startswith(options.langcode):
group = index
group = index + 1
break
if group is None:
print >> sys.stderr, "Unknown langcode %s" % options.langcode
exit(1)
......
......@@ -134,7 +134,10 @@ keyboard = eekboard.XmlKeyboard(os.path.abspath(sys.argv[1]))
def each_key(element, data):
keycode = element.get_keycode()
matrix = Eek.SymbolMatrix.new(len(files), 4)
matrix = Eek.SymbolMatrix.new(len(files) + 1, 4)
for l in xrange(4):
keysym = element.get_symbol_at_index(0, l, 0, 0)
matrix.set_symbol(0, l, keysym)
for g, f in enumerate(files):
entry = f.get_entry_for_keycode(keycode)
for l in xrange(4):
......@@ -146,8 +149,8 @@ def each_key(element, data):
except:
pass
if not keysym:
keysym = element.get_symbol_at_index(g, l, 0, 0)
matrix.set_symbol(g, l, keysym)
keysym = element.get_symbol_at_index(g + 1, l, 0, 0)
matrix.set_symbol(g + 1, l, keysym)
element.set_symbol_matrix(matrix)
def each_section(element, data):
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment