Add property.
This commit is contained in:
Родитель
ff7292352b
Коммит
e5ca9c4a0a
|
@ -64,27 +64,14 @@ class IEngine (dbus.service.Object):
|
|||
def ForwardKeyEvent (self, keyval, is_press, state): pass
|
||||
|
||||
@signal (signature="saaiib")
|
||||
def UpdatePreedit (self, text, attrs, cursor_pos, show): pass
|
||||
def UpdatePreedit (self, text, attrs, cursor_pos, visible): pass
|
||||
|
||||
@signal (signature="svb")
|
||||
def UpdateAuxString (self, text, attrs, visible): pass
|
||||
|
||||
@signal (signature="vb")
|
||||
def UpdateLookupTable (self, lookup_table, visible): pass
|
||||
|
||||
# below signals are optional. The engine could create and maintain panel by self.
|
||||
@signal (signature="v")
|
||||
def UpdateProperties (self, properties): pass
|
||||
|
||||
@signal (signature="svb")
|
||||
def UpdateAuxString (self, text, attrs, show): pass
|
||||
|
||||
@signal ()
|
||||
def ShowAuxStringChanged (self): pass
|
||||
|
||||
@signal ()
|
||||
def HideAuxStringChanged (self): pass
|
||||
|
||||
@signal (signature="vb")
|
||||
def UpdateLookupTable (self, lookup_table, show): pass
|
||||
|
||||
@signal ()
|
||||
def ShowLookupTable (self): pass
|
||||
|
||||
@signal ()
|
||||
def HideLookupTable (self): pass
|
||||
|
||||
|
|
|
@ -22,31 +22,16 @@ class IPanel (dbus.service.Object):
|
|||
def SetCursorLocation (self, x, y, w, h): pass
|
||||
|
||||
@method (in_signature="svub")
|
||||
def UpdatePreedit (self, text, attrs, cursor_pos, show): pass
|
||||
|
||||
@method ()
|
||||
def ShowPreeditString (self): pass
|
||||
|
||||
@method ()
|
||||
def HidePreeditString (self): pass
|
||||
def UpdatePreedit (self, text, attrs, cursor_pos, visible): pass
|
||||
|
||||
@method (in_signature="svb")
|
||||
def UpdateAuxString (self, text, attrs, show): pass
|
||||
|
||||
@method ()
|
||||
def ShowAuxString (self): pass
|
||||
|
||||
@method ()
|
||||
def HideAuxString (self): pass
|
||||
def UpdateAuxString (self, text, attrs, visible): pass
|
||||
|
||||
@method (in_signature="vb")
|
||||
def UpdateLookupTable (self, lookup_table, show): pass
|
||||
def UpdateLookupTable (self, lookup_table, visible): pass
|
||||
|
||||
@method ()
|
||||
def ShowCandidateWindow (self): pass
|
||||
|
||||
@method ()
|
||||
def HideCandidateWindow (self): pass
|
||||
@method (in_signature="v")
|
||||
def UpdateProperties (self, props): pass
|
||||
|
||||
@method ()
|
||||
def ShowLanguageBar (self): pass
|
||||
|
|
|
@ -65,6 +65,8 @@ class IBus (ibus.Object):
|
|||
self._client_handlers.append (id)
|
||||
id = client.connect ("update-lookup-table", self._update_lookup_table_cb)
|
||||
self._client_handlers.append (id)
|
||||
id = client.connect ("update-properties", self._update_properties_cb)
|
||||
self._client_handlers.append (id)
|
||||
|
||||
self._panel.reset ()
|
||||
self._focused_client = client
|
||||
|
@ -139,15 +141,10 @@ class IBus (ibus.Object):
|
|||
|
||||
self._panel.update_lookup_table (lookup_table, show)
|
||||
|
||||
def _show_lookup_table_cb (self, client, lookup_table):
|
||||
def _update_properties_cb (self, client, properties):
|
||||
assert self._focused_client == client
|
||||
|
||||
self._panel.show_candidate_window ()
|
||||
|
||||
def _hide_lookup_table_cb (self, client, lookup_table):
|
||||
assert self._focused_client == client
|
||||
|
||||
self._panel.hide_candidate_window ()
|
||||
self._panel.update_properties (properties)
|
||||
|
||||
def _client_destroy_cb (self, client):
|
||||
if client == self._focused_client:
|
||||
|
|
|
@ -15,6 +15,10 @@ class Client (ibus.Object):
|
|||
gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT, gobject.TYPE_BOOLEAN)),
|
||||
"update-properties" : (
|
||||
gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT, )),
|
||||
}
|
||||
|
||||
def __init__ (self, name, ibusconn):
|
||||
|
@ -105,12 +109,12 @@ class Client (ibus.Object):
|
|||
def commit_string (self, text):
|
||||
self._ibusconn.emit_dbus_signal ("CommitString", text)
|
||||
|
||||
def update_preedit (self, text, attrs, cursor_pos, show):
|
||||
def update_preedit (self, text, attrs, cursor_pos, visible):
|
||||
if self._use_preedit:
|
||||
self._ibusconn.emit_dbus_signal ("UpdatePreedit", text, attrs, cursor_pos, show)
|
||||
self._ibusconn.emit_dbus_signal ("UpdatePreedit", text, attrs, cursor_pos, visible)
|
||||
else:
|
||||
# show preedit on panel
|
||||
self.emit ("update-preedit", text, attrs, cursor_pos, show)
|
||||
self.emit ("update-preedit", text, attrs, cursor_pos, visible)
|
||||
|
||||
def set_engine (self, engine):
|
||||
if self._engine == engine:
|
||||
|
@ -141,17 +145,20 @@ class Client (ibus.Object):
|
|||
def _commit_string_cb (self, engine, text):
|
||||
self.commit_string (text)
|
||||
|
||||
def _update_preedit_cb (self, engine, text, attrs, cursor_pos, show):
|
||||
self.update_preedit (text, attrs, cursor_pos, show)
|
||||
def _update_preedit_cb (self, engine, text, attrs, cursor_pos, visible):
|
||||
self.update_preedit (text, attrs, cursor_pos, visible)
|
||||
|
||||
def _update_aux_string_cb (self, engine, text, attrs, show):
|
||||
def _update_aux_string_cb (self, engine, text, attrs, visible):
|
||||
self._aux_string = text
|
||||
self._aux_attrs = attrs
|
||||
self.emit ("update-aux-string", text, attrs, show)
|
||||
self.emit ("update-aux-string", text, attrs, visible)
|
||||
|
||||
def _update_lookup_table_cb (self, engine, lookup_table, show):
|
||||
def _update_lookup_table_cb (self, engine, lookup_table, visible):
|
||||
self._lookup_table = lookup_table
|
||||
self.emit ("update-lookup-table", lookup_table, show)
|
||||
self.emit ("update-lookup-table", lookup_table, visible)
|
||||
|
||||
def _update_properties_cb (self, props):
|
||||
self.emit ("update-properties", props)
|
||||
|
||||
def _remove_engine_handlers (self):
|
||||
assert self._engine != None
|
||||
|
@ -170,4 +177,9 @@ class Client (ibus.Object):
|
|||
self._engine_handler_ids.append (id)
|
||||
id = self._engine.connect ("update-lookup-table", self._update_lookup_table_cb)
|
||||
self._engine_handler_ids.append (id)
|
||||
# id = self._engine.connect ("register-properties", self._register_properties_cb)
|
||||
# self._engine_handler_ids.append (id)
|
||||
id = self._engine.connect ("update-properties", self._update_properties_cb)
|
||||
self._engine_handler_ids.append (id)
|
||||
|
||||
gobject.type_register (Client)
|
||||
|
|
|
@ -24,6 +24,14 @@ class Engine (ibus.Object):
|
|||
gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT, gobject.TYPE_BOOLEAN)),
|
||||
"register-properties" : (
|
||||
gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT, )),
|
||||
"update-properties" : (
|
||||
gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE,
|
||||
(gobject.TYPE_PYOBJECT, )),
|
||||
}
|
||||
|
||||
def __init__ (self, factory, ibusconn, object_path):
|
||||
|
@ -59,6 +67,14 @@ class Engine (ibus.Object):
|
|||
args = message.get_args_list ()
|
||||
self.emit ("update-lookup-table", args[0], args[1])
|
||||
return True
|
||||
elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "RegisterProperties"):
|
||||
args = message.get_args_list ()
|
||||
self.emit ("register-properties", args[0])
|
||||
return True
|
||||
elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "UpdateProperties"):
|
||||
args = message.get_args_list ()
|
||||
self.emit ("update-properties", args[0])
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
|
@ -34,32 +34,17 @@ class Panel (ibus.Object):
|
|||
def set_cursor_location (self, x, y, w, h):
|
||||
self._panel.SetCursorLocation (x, y, w, h)
|
||||
|
||||
def update_preedit (self, text, attrs, cursor_pos, show):
|
||||
self._panel.UpdatePreedit (text, attrs, cursor_pos, show)
|
||||
def update_preedit (self, text, attrs, cursor_pos, visible):
|
||||
self._panel.UpdatePreedit (text, attrs, cursor_pos, visible)
|
||||
|
||||
def show_preedit_string (self):
|
||||
self._panel.ShowPreeditString ()
|
||||
def update_aux_string (self, text, attrs, visible):
|
||||
self._panel.UpdateAuxString (text, attrs, visible)
|
||||
|
||||
def hide_preedit_string (self):
|
||||
slef._panel.HidePreeditString ()
|
||||
def update_lookup_table (self, lookup_table, visible):
|
||||
self._panel.UpdateLookupTable (lookup_table, visible)
|
||||
|
||||
def update_aux_string (self, text, attrs, show):
|
||||
self._panel.UpdateAuxString (text, attrs, show)
|
||||
|
||||
def show_aux_string (self):
|
||||
self._panel.ShowAuxString ()
|
||||
|
||||
def hide_aux_string (self):
|
||||
slef._panel.HideAuxString ()
|
||||
|
||||
def update_lookup_table (self, lookup_table, show):
|
||||
self._panel.UpdateLookupTable (lookup_table, show)
|
||||
|
||||
def show_candidate_window (self):
|
||||
self._panel.ShowCandidateWindow ()
|
||||
|
||||
def hide_candidate_window (self):
|
||||
self._panel.HideCandidateWindow ()
|
||||
def update_properties (self, props):
|
||||
self._panel.UpdateProperties (props)
|
||||
|
||||
def show_language_bar (self):
|
||||
self._panel.ShowLanguageBar ()
|
||||
|
@ -131,31 +116,16 @@ class DummyPanel (ibus.Object):
|
|||
def set_cursor_location (self, x, y, w, h):
|
||||
pass
|
||||
|
||||
def update_preedit (self, text, attrs, cursor_pos, show):
|
||||
def update_preedit (self, text, attrs, cursor_pos, visible):
|
||||
pass
|
||||
|
||||
def show_preedit_string (self):
|
||||
def update_aux_string (self, text, attrs, visible):
|
||||
pass
|
||||
|
||||
def hide_preedit_string (self):
|
||||
def update_lookup_table (self, lookup_table, visible):
|
||||
pass
|
||||
|
||||
def update_aux_string (self, text, attrs, show):
|
||||
pass
|
||||
|
||||
def show_aux_string (self):
|
||||
pass
|
||||
|
||||
def hide_aux_string (self):
|
||||
pass
|
||||
|
||||
def update_lookup_table (self, lookup_table, show):
|
||||
pass
|
||||
|
||||
def show_candidate_window (self):
|
||||
pass
|
||||
|
||||
def hide_candidate_window (self):
|
||||
def update_properties (self, props):
|
||||
pass
|
||||
|
||||
def show_language_bar (self):
|
||||
|
|
|
@ -4,24 +4,31 @@ import gobject
|
|||
from image import Image
|
||||
from handle import Handle
|
||||
|
||||
ICON_SIZE = gtk.ICON_SIZE_LARGE_TOOLBAR
|
||||
|
||||
class LanguageBar (gtk.Toolbar):
|
||||
def __init__ (self):
|
||||
gtk.Toolbar.__init__ (self)
|
||||
self.set_property ("icon-size", gtk.ICON_SIZE_MENU)
|
||||
self.set_property ("icon-size", ICON_SIZE)
|
||||
icon_theme = gtk.icon_theme_get_default ()
|
||||
icon_theme.prepend_search_path ("/home/phuang/sources/ibus/icons")
|
||||
# self.set_orientation (gtk.ORIENTATION_VERTICAL)
|
||||
self._create_items ()
|
||||
|
||||
def _add_items (self):
|
||||
img = gtk.image_new_from_icon_name ("engine-default", gtk.ICON_SIZE_MENU)
|
||||
img = gtk.image_new_from_icon_name ("engine-default", ICON_SIZE)
|
||||
btn = gtk.ToolButton (img, "engine")
|
||||
btn.connect ("clicked", lambda x: self._add_items ())
|
||||
self.insert (btn, -1)
|
||||
|
||||
img = gtk.image_new_from_icon_name ("ibus-keyboard", gtk.ICON_SIZE_MENU)
|
||||
img = gtk.image_new_from_icon_name ("ibus-keyboard", ICON_SIZE)
|
||||
btn = gtk.ToolButton (img, "keyboard")
|
||||
self.insert (btn, -1)
|
||||
|
||||
img = gtk.image_new_from_icon_name ("ibus-zh", ICON_SIZE)
|
||||
btn = gtk.ToolButton (img, "keyboard")
|
||||
self.insert (btn, -1)
|
||||
|
||||
self.insert (gtk.SeparatorToolItem (), -1)
|
||||
self.show_all ()
|
||||
self.check_resize ()
|
||||
|
|
Загрузка…
Ссылка в новой задаче