summaryrefslogtreecommitdiffstats
path: root/ibus/panel.py
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2009-02-05 10:39:56 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2009-02-05 10:39:56 +0800
commitaedad1ea0a7fef604aa27f4b58433fd8f2ece29e (patch)
treeffcb531d8474bde18b90341bcd4eb639edd74525 /ibus/panel.py
parent41ad46305a88637dd99f00a2d2a3f455505d357b (diff)
downloadibus-aedad1ea0a7fef604aa27f4b58433fd8f2ece29e.tar.gz
ibus-aedad1ea0a7fef604aa27f4b58433fd8f2ece29e.tar.xz
ibus-aedad1ea0a7fef604aa27f4b58433fd8f2ece29e.zip
re-implement ibus in c language.
Diffstat (limited to 'ibus/panel.py')
-rw-r--r--ibus/panel.py124
1 files changed, 85 insertions, 39 deletions
diff --git a/ibus/panel.py b/ibus/panel.py
index 74b220d..9a34109 100644
--- a/ibus/panel.py
+++ b/ibus/panel.py
@@ -25,15 +25,17 @@ __all__ = (
"PanelButton",
"PanelToggleButton",
"PanelMenu",
- "IBUS_PANEL_NAME",
- "IBUS_PANEL_PATH"
+ "IBUS_SERVICE_PANEL",
+ "IBUS_PATH_PANEL"
)
-IBUS_PANEL_NAME = "org.freedesktop.ibus.Panel"
-IBUS_PANEL_PATH = "/org/freedesktop/ibus/Panel"
+IBUS_SERVICE_PANEL = "org.freedesktop.IBus.Panel"
+IBUS_PATH_PANEL = "/org/freedesktop/IBus/Panel"
-import ibus
-from ibus import interface
+from serializable import *
+from object import Object
+import interface
+import dbus
class PanelItem:
pass
@@ -47,30 +49,31 @@ class PanelToggleButton(PanelButton):
class PanelMenu(PanelItem):
pass
-class PanelBase(ibus.Object):
+class PanelBase(Object):
def __init__(self, bus):
super(PanelBase, self).__init__()
- self.__proxy = PanelProxy(self, bus.get_dbusconn())
+ self.__bus = bus
+ self.__proxy = PanelProxy(self, bus)
def set_cursor_location(self, x, y, w, h):
pass
- def update_preedit(self, text, attrs, cursor_pos, visible):
+ def update_preedit_text(self, text, cursor_pos, visible):
pass
- def show_preedit(self):
+ def show_preedit_text(self):
pass
- def hide_preedit(self):
+ def hide_preedit_text(self):
pass
- def update_aux_string(self, text, attrs, visible):
+ def update_auxiliary_text(self, text, visible):
pass
- def show_aux_string(self):
+ def show_auxiliary_text(self):
pass
- def hide_aux_string(self):
+ def hide_auxiliary_text(self):
pass
def update_lookup_table(self, lookup_table, visible):
@@ -118,7 +121,7 @@ class PanelBase(ibus.Object):
def focus_out(self, ic):
pass
- def states_changed(self):
+ def state_changed(self):
pass
def reset(self):
@@ -140,47 +143,52 @@ class PanelBase(ibus.Object):
self.__proxy.CursorDown()
def property_activate(self, prop_name, prop_state):
+ prop_name = dbus.String(prop_name)
+ prop_state = dbus.Int32(prop_state)
self.__proxy.PropertyActivate(prop_name, prop_state)
def property_show(self, prop_name):
+ prop_name = dbus.String(prop_name)
self.__proxy.PropertyShow(prop_name)
def property_hide(self, prop_name):
+ prop_name = dbus.String(prop_name)
self.__proxy.PropertyHide(prop_name)
class PanelProxy(interface.IPanel):
- def __init__ (self, panel, dbusconn):
- super(PanelProxy, self).__init__(dbusconn, IBUS_PANEL_PATH)
- self.__dbusconn = dbusconn
+ def __init__ (self, panel, bus):
+ super(PanelProxy, self).__init__(bus.get_dbusconn(), IBUS_PATH_PANEL)
+ self.__bus = bus
self.__panel = panel
+ self.__focus_ic = None
def SetCursorLocation(self, x, y, w, h):
self.__panel.set_cursor_location(x, y, w, h)
- def UpdatePreedit(self, text, attrs, cursor_pos, show):
- attrs = ibus.attr_list_from_dbus_value(attrs)
- self.__panel.update_preedit(text, attrs, cursor_pos, show)
+ def UpdatePreeditText(self, text, cursor_pos, visible):
+ text = deserialize_object(text)
+ self.__panel.update_preedit_text(text, cursor_pos, visible)
- def ShowPreedit(self):
- self.__panel.show_preedit()
+ def ShowPreeditText(self):
+ self.__panel.show_preedit_text()
- def HidePreedit(self):
- self.__panel.hide_preedit()
+ def HidePreeditText(self):
+ self.__panel.hide_preedit_text()
- def UpdateAuxString(self, text, attrs, show):
- attrs = ibus.attr_list_from_dbus_value(attrs)
- self.__panel.update_aux_string(text, attrs, show)
+ def UpdateAuxiliaryText(self, text, visible):
+ text = deserialize_object(text)
+ self.__panel.update_auxiliary_text(text, visible)
- def ShowAuxString(self):
- self.__panel.show_aux_string()
+ def ShowAuxiliaryText(self):
+ self.__panel.show_auxiliary_text()
- def HideAuxString(self):
- self.__panel.hide_aux_string()
+ def HideAuxiliaryText(self):
+ self.__panel.hide_auxiliary_text()
- def UpdateLookupTable(self, lookup_table, show):
- lookup_table = ibus.lookup_table_from_dbus_value(lookup_table)
- self.__panel.update_lookup_table(lookup_table, show)
+ def UpdateLookupTable(self, lookup_table, visible):
+ lookup_table = deserialize_object(lookup_table)
+ self.__panel.update_lookup_table(lookup_table, visible)
def ShowLookupTable(self):
self.__panel.show_lookup_table()
@@ -213,11 +221,11 @@ class PanelProxy(interface.IPanel):
self.__panel.hide_language_bar()
def RegisterProperties(self, props):
- props = ibus.prop_list_from_dbus_value(props)
+ props = deserialize_object(props)
self.__panel.register_properties(props)
def UpdateProperty(self, prop):
- prop = ibus.property_from_dbus_value(prop)
+ prop = deserialize_object(prop)
self.__panel.update_property(prop)
def FocusIn(self, ic):
@@ -226,8 +234,8 @@ class PanelProxy(interface.IPanel):
def FocusOut(self, ic):
self.__panel.focus_out(ic)
- def StatesChanged(self):
- self.__panel.states_changed()
+ def StateChanged(self):
+ self.__panel.state_changed()
def Reset(self):
self.__panel.reset()
@@ -238,3 +246,41 @@ class PanelProxy(interface.IPanel):
def Destroy(self):
self.__panel.destroy()
+def test():
+ import gtk
+ from bus import Bus
+ from inputcontext import InputContext
+ import factory
+ import attribute
+ import property
+ import text
+ import lookuptable
+
+ class TestPanel(PanelBase):
+ def __init__(self):
+ self.__bus = Bus()
+ self.__bus.connect("disconnected", gtk.main_quit)
+ super(TestPanel, self).__init__(self.__bus)
+ self.__bus.request_name(IBUS_SERVICE_PANEL, 0)
+
+ def focus_in(self, ic):
+ print "focus-in:", ic
+ context = InputContext(self.__bus, ic)
+ info = context.get_factory_info()
+ print "factory:", info.name
+
+ def focus_out(self, ic):
+ print "focus-out:", ic
+
+ def update_auxiliary_text(self, text, visible):
+ print "update-auxiliary-text:", text.text
+
+ def update_lookup_table(self, table, visible):
+ print "update-lookup-table", table
+
+ panel = TestPanel()
+ gtk.main()
+
+
+if __name__ == "__main__":
+ test()