This commit is contained in:
Huang Peng 2008-07-31 13:02:08 +08:00
Родитель 67bb63aa51
Коммит 708442bf30
7 изменённых файлов: 57 добавлений и 57 удалений

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

@ -31,13 +31,13 @@ CONFIG_PATH = "/org/freedesktop/IBus/GConf"
class GconfApplication:
def __init__(self):
self.__mainloop = gobject.MainLoop()
self.__ibus = ibus.IBus()
self.__ibus.connect("destroy", self.__ibus_destroy_cb)
self.__bus = ibus.Bus()
self.__bus.connect("destroy", self.__bus_destroy_cb)
self.__config = config.Config(self.__ibus, CONFIG_PATH)
self.__config = config.Config(self.__bus, CONFIG_PATH)
self.__config.connect("destroy", self.__config_destroy_cb)
self.__ibus.register_config(CONFIG_PATH, True)
self.__bus.register_config(CONFIG_PATH, True)
def run(self):
self.__mainloop.run()
@ -45,7 +45,7 @@ class GconfApplication:
def __config_destroy_cb(self, config):
self.__mainloop.quit()
def __ibus_destroy_cb(self, _ibus):
def __bus_destroy_cb(self, _ibus):
print "disconnected"
self.__mainloop.quit()

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

@ -20,7 +20,7 @@
# Boston, MA 02111-1307 USA
__all__ = (
"IBus",
"Bus",
)
import gobject
@ -31,7 +31,7 @@ import ibus
dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
class IBus(ibus.Object):
class Bus(ibus.Object):
__gsignals__ = {
"config-value-changed" : (
gobject.SIGNAL_RUN_FIRST,
@ -46,9 +46,9 @@ class IBus(ibus.Object):
}
def __init__(self):
super(IBus, self).__init__()
super(Bus, self).__init__()
self.__conn = dbus.connection.Connection(ibus.IBUS_ADDR)
self.__ibus = self.__conn.get_object(ibus.IBUS_NAME, ibus.IBUS_PATH)
self.__bus = 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):
@ -75,71 +75,71 @@ class IBus(ibus.Object):
return ibus.IBUS_ADDR
def create_input_context(self, client_name):
return self.__ibus.CreateInputContext(client_name)
return self.__bus.CreateInputContext(client_name)
def release_input_context(self, ic):
return self.__ibus.ReleaseInputContext(ic)
return self.__bus.ReleaseInputContext(ic)
def process_key_event(self, ic, keyval, is_press, state):
return self.__ibus.ProcessKeyEvent(ic, keyval, is_press, state)
return self.__bus.ProcessKeyEvent(ic, keyval, is_press, state)
def set_cursor_location(self, ic, x, y, w, h):
return self.__ibus.SetCursorLocation(ic, x, y, w, h)
return self.__bus.SetCursorLocation(ic, x, y, w, h)
def foucs_in(self, ic):
return self.__ibus.FocusIn(ic)
return self.__bus.FocusIn(ic)
def foucs_out(self, ic):
return self.__ibus.FocusOut(ic)
return self.__bus.FocusOut(ic)
def reset(self, ic):
return self.__ibus.Reset(ic)
return self.__bus.Reset(ic)
def is_enabled(self, ic):
return self.__ibus.IsEnabled(ic)
return self.__bus.IsEnabled(ic)
def set_capabilities(self, ic, caps):
return self.__ibus.set_capabilities(ic, caps)
return self.__bus.set_capabilities(ic, caps)
def register_factories(self, object_paths):
return self.__ibus.RegisterFactories(object_paths, **ibus.DEFAULT_ASYNC_HANDLERS)
return self.__bus.RegisterFactories(object_paths, **ibus.DEFAULT_ASYNC_HANDLERS)
def unregister_factories(self, object_paths):
return self.__ibus.UnregisterFactories(object_paths)
return self.__bus.UnregisterFactories(object_paths)
def register_panel(self, object_path, replace = False):
return self.__ibus.RegisterPanel(object_path, replace)
return self.__bus.RegisterPanel(object_path, replace)
def register_config(self, object_path, replace = False):
return self.__ibus.RegisterConfig(object_path, replace)
return self.__bus.RegisterConfig(object_path, replace)
def get_factories(self):
return self.__ibus.GetFactories()
return self.__bus.GetFactories()
def get_factory_info(self, factory_path):
return self.__ibus.GetFactoryInfo(factory_path)
return self.__bus.GetFactoryInfo(factory_path)
def set_factory(self, factory_path):
return self.__ibus.SetFactory(factory_path)
return self.__bus.SetFactory(factory_path)
def get_input_context_states(self, ic):
return self.__ibus.GetInputContextStates(ic)
return self.__bus.GetInputContextStates(ic)
def config_set_value(self, key, value):
return self.__ibus.ConfigSetValue(key, value)
return self.__bus.ConfigSetValue(key, value)
def config_get_value(self, key):
return self.__ibus.ConfigGetValue(key)
return self.__bus.ConfigGetValue(key)
def register_list_engines(self):
return self.__ibus.RegisterListEngines()
return self.__bus.RegisterListEngines()
def register_start_engine(self, lang, name):
return self.__ibus.RegisterStartEngine(lang, name)
return self.__bus.RegisterStartEngine(lang, name)
def register_restart_engine(self, lang, name):
return self.__ibus.RegisterRestartEngine(lang, name)
return self.__bus.RegisterRestartEngine(lang, name)
def register_stop_engine(self, lang, name):
return self.__ibus.RegisterStopEngine(lang, name)
return self.__bus.RegisterStopEngine(lang, name)

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

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

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

@ -27,11 +27,11 @@ import ibus
from ibus import interface
class EngineFactoryBase(ibus.Object):
def __init__(self, info, engine_class, engine_path, _ibus, object_path):
def __init__(self, info, engine_class, engine_path, bus, object_path):
super(EngineFactoryBase, self).__init__()
self.__proxy = EngineFactoryProxy (self, _ibus.get_conn(), object_path)
self.__proxy = EngineFactoryProxy (self, bus.get_conn(), object_path)
self.__info = info
self.__ibus = _ibus
self.__bus = bus
self.__engine_class = engine_class
self.__engine_path = engine_path
self.__engine_id = 1
@ -47,16 +47,16 @@ class EngineFactoryBase(ibus.Object):
pass
def register(self):
self.__ibus.register_factories([self.__object_path])
self.__bus.register_factories([self.__object_path])
def create_engine(self):
engine = self.__engine_class(self.__ibus, self.__engine_path + str(self.__engine_id))
engine = self.__engine_class(self.__bus, self.__engine_path + str(self.__engine_id))
self.__engine_id += 1
return engine.get_dbus_object()
def do_destroy(self):
self.__proxy = None
self.__ibus = None
self.__bus = None
self.__info = None
self.__engine_class = None
self.__engine_path = None

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

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

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

@ -30,17 +30,17 @@ PANEL_PATH = "/org/freedesktop/IBus/Panel"
class PanelApplication:
def __init__ (self):
self.__ibus = ibus.IBus()
self.__ibus.connect("destroy", self.__ibus_destroy_cb)
self.__bus = ibus.Bus()
self.__bus.connect("destroy", self.__bus_destroy_cb)
self.__panel = panel.Panel(self.__ibus, PANEL_PATH)
self.__panel = panel.Panel(self.__bus, PANEL_PATH)
self.__ibus.register_panel(PANEL_PATH, True)
self.__bus.register_panel(PANEL_PATH, True)
def run(self):
gtk.main()
def __ibus_destroy_cb(self, _ibus):
def __bus_destroy_cb(self, _ibus):
gtk.main_quit()

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

@ -31,9 +31,9 @@ from languagebar import LanguageBar
from candidatepanel import CandidatePanel
class Panel(ibus.PanelBase):
def __init__ (self, _ibus, object_path):
super(Panel, self).__init__(_ibus, object_path)
self.__ibus = _ibus
def __init__ (self, bus, object_path):
super(Panel, self).__init__(bus, object_path)
self.__bus = bus
self.__focus_ic = None
# add icon search path
@ -134,12 +134,12 @@ class Panel(ibus.PanelBase):
self.reset()
self.__focus_ic = ic
factory, enabled = self.__ibus.get_input_context_states(ic)
factory, enabled = self.__bus.get_input_context_states(ic)
if factory == "" or not enabled:
self.__set_im_icon("engine-default")
else:
name, lang, icon, authors, credits = self.__ibus.get_factory_info(factory)
name, lang, icon, authors, credits = self.__bus.get_factory_info(factory)
self.__set_im_icon(icon)
self.__language_bar.focus_in()
@ -153,11 +153,11 @@ class Panel(ibus.PanelBase):
def states_changed(self):
if not self.__focus_ic:
return
factory, enabled = self.__ibus.get_input_context_states(self.__focus_ic)
factory, enabled = self.__bus.get_input_context_states(self.__focus_ic)
if enabled == False or not factory:
self.__set_im_icon("engine-default")
else:
name, lang, icon, authors, credits = self.__ibus.get_factory_info(factory)
name, lang, icon, authors, credits = self.__bus.get_factory_info(factory)
self.__set_im_icon(icon)
def reset(self):
@ -169,7 +169,7 @@ class Panel(ibus.PanelBase):
def __create_im_menu(self):
menu = gtk.Menu()
factories = self.__ibus.get_factories()
factories = self.__bus.get_factories()
if not factories:
item = gtk.MenuItem(label = "no engine")
@ -178,7 +178,7 @@ class Panel(ibus.PanelBase):
else:
tmp = {}
for factory in factories:
name, lang, icon, authors, credits = self.__ibus.get_factory_info(factory)
name, lang, icon, authors, credits = self.__bus.get_factory_info(factory)
lang = LANGUAGES.get(lang, "other")
if not icon:
icon = "engine-default"
@ -238,6 +238,6 @@ class Panel(ibus.PanelBase):
self.__status_icon)
def __menu_item_activate_cb(self, item, factory):
self.__ibus.set_factory(factory)
self.__bus.set_factory(factory)
gobject.type_register(Panel, "IBusPanel")