Make ibus inherit from ibus.Object.

This commit is contained in:
Huang Peng 2008-07-31 12:09:04 +08:00
Родитель 211e3f2a79
Коммит 67bb63aa51
7 изменённых файлов: 54 добавлений и 17 удалений

Просмотреть файл

@ -38,8 +38,9 @@ class Config(ibus.Object):
(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)),
}
def __init__ (self, conn = None, path = None):
def __init__ (self, _ibus = None, path = None):
super(Config, self).__init__()
conn = _ibus.get_conn() if _ibus != None else None
self.__proxy = ConfigProxy(self, conn, path)
self.__client = gconf.Client()
self.__handler_id = self.__client.connect("value-changed", self.__value_changed_cb)

Просмотреть файл

@ -32,7 +32,7 @@ class GconfApplication:
def __init__(self):
self.__mainloop = gobject.MainLoop()
self.__ibus = ibus.IBus()
self.__ibus.call_on_disconnection(self.__disconnected_cb)
self.__ibus.connect("destroy", self.__ibus_destroy_cb)
self.__config = config.Config(self.__ibus, CONFIG_PATH)
self.__config.connect("destroy", self.__config_destroy_cb)
@ -45,7 +45,7 @@ class GconfApplication:
def __config_destroy_cb(self, config):
self.__mainloop.quit()
def __disconnected_cb(self, conn):
def __ibus_destroy_cb(self, _ibus):
print "disconnected"
self.__mainloop.quit()

Просмотреть файл

@ -22,17 +22,54 @@
__all__ = (
"IBus",
)
import gobject
import dbus.lowlevel
import dbus.connection
import ibus
import dbus.mainloop.glib
import ibus
dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
class IBus(dbus.connection.Connection):
def __new__(cls):
self = super(IBus, cls).__new__(cls, ibus.IBUS_ADDR)
self.__ibus = self.get_object(ibus.IBUS_NAME, ibus.IBUS_PATH)
return self
class IBus(ibus.Object):
__gsignals__ = {
"config-value-changed" : (
gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
),
"config-relaoded" : (
gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
()
),
}
def __init__(self):
super(IBus, self).__init__()
self.__conn = dbus.connection.Connection(ibus.IBUS_ADDR)
self.__ibus = self.__conn.get_object(ibus.IBUS_NAME, ibus.IBUS_PATH)
self.__conn.add_message_filter(self.__dbus_message_cb)
def __dbus_message_cb(self, conn, message):
if message.is_signal(ibus.IBUS_IFACE, "ConfigValueChanged"):
args = message.get_args_list()
key, value = args[0], args[1]
self.emit("config-value-changed", key, value)
retval = dbus.lowlevel.HANDLER_RESULT_HANDLED
elif message.is_signal(ibus.IBUS_IFACE, "ConfigReloaded"):
self.emit("config-reloaded", key, value)
retval = dbus.lowlevel.HANDLER_RESULT_HANDLED
elif message.is_signal(dbus.LOCAL_IFACE, "Disconnected"):
self.destroy()
retval = dbus.lowlevel.HANDLER_RESULT_HANDLED
else:
retval = dbus.lowlevel.HANDLER_RESULT_NOT_YET_HANDLED
return retval
def get_conn(self):
return self.__conn
def get_address(self):
return ibus.IBUS_ADDR

Просмотреть файл

@ -27,9 +27,9 @@ import ibus
from ibus import interface
class EngineBase(ibus.Object):
def __init__(self, conn, object_path):
def __init__(self, _ibus, object_path):
super(EngineBase, self).__init__()
self.__proxy = EngineProxy (self, conn, object_path)
self.__proxy = EngineProxy (self, _ibus.get_conn(), object_path)
def process_key_event(self, keyval, is_press, state):
return False

Просмотреть файл

@ -29,7 +29,7 @@ from ibus import interface
class EngineFactoryBase(ibus.Object):
def __init__(self, info, engine_class, engine_path, _ibus, object_path):
super(EngineFactoryBase, self).__init__()
self.__proxy = EngineFactoryProxy (self, _ibus, object_path)
self.__proxy = EngineFactoryProxy (self, _ibus.get_conn(), object_path)
self.__info = info
self.__ibus = _ibus
self.__engine_class = engine_class

Просмотреть файл

@ -43,9 +43,9 @@ class PanelMenu(PanelItem):
pass
class PanelBase(ibus.Object):
def __init__(self, dbusconn, object_path):
def __init__(self, _ibus, object_path):
super(PanelBase, self).__init__()
self.__proxy = PanelProxy(self, dbusconn, object_path)
self.__proxy = PanelProxy(self, _ibus.get_conn(), object_path)
def set_cursor_location(self, x, y, w, h):
pass

Просмотреть файл

@ -31,7 +31,7 @@ PANEL_PATH = "/org/freedesktop/IBus/Panel"
class PanelApplication:
def __init__ (self):
self.__ibus = ibus.IBus()
self.__ibus.call_on_disconnection(self.__disconnected_cb)
self.__ibus.connect("destroy", self.__ibus_destroy_cb)
self.__panel = panel.Panel(self.__ibus, PANEL_PATH)
@ -40,8 +40,7 @@ class PanelApplication:
def run(self):
gtk.main()
def __disconnected_cb(self, conn):
print "disconnected"
def __ibus_destroy_cb(self, _ibus):
gtk.main_quit()