Commit 132ae389 authored by Daiki Ueno's avatar Daiki Ueno

Terminate eekboard-inscript when the window is closed.

parent 72f84fa4
......@@ -44,18 +44,30 @@ class Context(gobject.GObject):
}
__gproperties__ = {
'keyboard-visible': (bool, None, None, False, gobject.PARAM_READABLE),
'keyboard-visible': (bool, None, None, False, gobject.PARAM_READWRITE),
}
def __init__(self, giobject):
super(Context, self).__init__()
import sys
self.__properties = dict()
self.__giobject = giobject
self.__giobject.connect('enabled', lambda *args: self.emit('enabled'))
self.__giobject.connect('disabled', lambda *args: self.emit('disabled'))
self.__giobject.connect('key-pressed', lambda *args: self.emit('key-pressed', args[1]))
self.__giobject.connect('key-released', lambda *args: self.emit('key-released', args[1]))
self.__giobject.connect('destroyed', lambda *args: self.emit('destroyed'))
self.__giobject.connect('notify::keyboard-visible', self.__notify_keyboard_visible_cb)
def do_set_property(self, pspec, value):
self.__properties[pspec.name] = value
def do_get_property(self, pspec):
return self.__properties[pspec.name]
def __notify_keyboard_visible_cb(self, *args):
self.set_property('keyboard-visible',
self.__giobject.get_property(args[1].name))
self.notify('keyboard-visible')
def get_giobject(self):
return self.__giobject
......
......@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
import gtk, eekboard, virtkey
import gobject, gtk, eekboard, virtkey
import sys, os.path, re
KEYCODE_TABLE = {
......@@ -77,7 +77,15 @@ class MapFile(object):
def __add_text_entry(self, text, insert):
self.__add_entry(text, 0, insert)
class Keyboard(object):
class Keyboard(gobject.GObject):
__gtype_name__ = "PYInscriptKeyboard"
__gsignals__ = {
'quit': (
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
()),
}
def __init__(self, client_name, map_path, kbd_path):
self.__keyboard = self.__create_keyboard(map_path, kbd_path)
self.__eekboard = eekboard.Eekboard()
......@@ -89,6 +97,8 @@ class Keyboard(object):
self.__virtkey = virtkey.virtkey()
self.__english = False
self.__eekboard.connect('destroyed', self.__destroyed_cb)
self.__context.connect('destroyed', self.__destroyed_cb)
self.__context.connect('notify::keyboard-visible', self.__notify_keyboard_visible_cb)
def __create_keyboard(self, map_path, kbd_path):
def __each_key(element, data):
......@@ -96,11 +106,13 @@ class Keyboard(object):
# keycode 37 is used to toggle English/Inscript
if keycode == 37:
matrix = eekboard.SymbolMatrix.new(2, 1)
keysym = eekboard.Keysym.new(65507)
keysym = eekboard.Keysym.new(0)
keysym.set_label("Ind")
keysym.set_category(eekboard.SymbolCategory.FUNCTION)
matrix.set_symbol(0, 0, keysym)
keysym = eekboard.Keysym.new(65507)
keysym = eekboard.Keysym.new(0)
keysym.set_label("Eng")
keysym.set_category(eekboard.SymbolCategory.FUNCTION)
matrix.set_symbol(1, 0, keysym)
element.set_symbol_matrix(matrix)
return
......@@ -134,9 +146,15 @@ class Keyboard(object):
keyboard.foreach_child(__each_section, mapfile)
return keyboard
def __destroyed_cb(self, eekboard):
def __destroyed_cb(self, *args):
# self.emit('quit')
gtk.main_quit()
def __notify_keyboard_visible_cb(self, obj, pspec):
if not obj.get_property(pspec.name):
# self.emit('quit')
gtk.main_quit()
def enable(self):
self.__eekboard.push_context(self.__context)
......
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