summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-06-14 09:48:40 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-06-14 09:48:40 +0800
commit1549532ea1b838c2ef3be63005aa699ced883cfb (patch)
treea84441c802cb5096f14dc63501fb6d902b77e04c
parentd60756e7cd6bfb3b3db892114ba9c77b66d07f8b (diff)
downloadibus-1549532ea1b838c2ef3be63005aa699ced883cfb.tar.gz
ibus-1549532ea1b838c2ef3be63005aa699ced883cfb.tar.xz
ibus-1549532ea1b838c2ef3be63005aa699ced883cfb.zip
Make one connection can create many inputcontext.
-rw-r--r--gtk2/gikimclient.c51
-rw-r--r--ibus/interface/iibus.py46
-rw-r--r--ibusdaemon/bus.py215
-rw-r--r--ibusdaemon/clientmanager.py21
-rw-r--r--ibusdaemon/contextmanager.py19
-rw-r--r--ibusdaemon/inputcontext.py (renamed from ibusdaemon/client.py)22
-rw-r--r--panel/panel.py2
7 files changed, 212 insertions, 164 deletions
diff --git a/gtk2/gikimclient.c b/gtk2/gikimclient.c
index 3f49279..ea18d5a 100644
--- a/gtk2/gikimclient.c
+++ b/gtk2/gikimclient.c
@@ -58,6 +58,7 @@ struct _GikIMClientPrivate {
gboolean enable;
GtkIMContext *context;
+ gchar *ic;
/* preedit status */
gchar *preedit_string;
@@ -287,10 +288,13 @@ _gik_im_client_ibus_open (GikIMClient *client)
}
dbus_connection_setup_with_g_main (priv->ibus, NULL);
const gchar *app_name = g_get_application_name ();
- _ibus_call_with_reply_and_block (priv->ibus, "RegisterClient",
+ gchar *ic = NULL;
+ _ibus_call_with_reply_and_block (priv->ibus, "CreateInputContext",
DBUS_TYPE_STRING, &app_name,
DBUS_TYPE_INVALID,
+ DBUS_TYPE_STRING, &ic,
DBUS_TYPE_INVALID);
+ priv->ic = g_strdup (ic);
}
@@ -561,15 +565,23 @@ static void
_gik_signal_commit_string_handler (DBusConnection *connection, DBusMessage *message, GikIMClient *client)
{
/* Handle CommitString signal */
+ GikIMClientPrivate *priv = client->priv;
DBusError error = {0};
+ gchar *ic = NULL;
gchar *string = NULL;
if (!dbus_message_get_args (message, &error,
- DBUS_TYPE_STRING, &string, DBUS_TYPE_INVALID)) {
+ DBUS_TYPE_STRING, &ic,
+ DBUS_TYPE_STRING, &string,
+ DBUS_TYPE_INVALID)) {
g_warning ("%s", error.message);
dbus_error_free (&error);
}
else {
+ if (g_strcmp0 (priv->ic, ic) != 0) {
+ g_warning ("ic is wrong!");
+ return;
+ }
gik_im_client_commit_string (client, string);
}
}
@@ -578,10 +590,12 @@ static void
_gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *message, GikIMClient *client)
{
/* Handle UpdatePreedit signal */
+ GikIMClientPrivate *priv = client->priv;
DBusError error = {0};
DBusMessageIter iter, sub_iter;
gint type, sub_type;
+ gchar *ic = NULL;
gchar *string = NULL;
PangoAttrList *attrs = NULL;
gint cursor = 0;
@@ -594,7 +608,20 @@ _gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *mes
type = dbus_message_iter_get_arg_type (&iter);
if (type != DBUS_TYPE_STRING) {
- g_warning ("The frist argument of UpdatePreedit signal must be a String");
+ g_warning ("The 1st argument of UpdatePreedit signal must be a String");
+ return;
+ }
+ dbus_message_iter_get_basic (&iter, &ic);
+ dbus_message_iter_next (&iter);
+
+ if (g_strcmp0 (priv->ic, ic) != 0) {
+ g_warning ("ic is wrong!");
+ return;
+ }
+
+ type = dbus_message_iter_get_arg_type (&iter);
+ if (type != DBUS_TYPE_STRING) {
+ g_warning ("The 2nd argument of UpdatePreedit signal must be a String");
return;
}
dbus_message_iter_get_basic (&iter, &string);
@@ -603,7 +630,7 @@ _gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *mes
type = dbus_message_iter_get_arg_type (&iter);
if (type != DBUS_TYPE_ARRAY) {
- g_warning ("The secode argument of UpdatePreedit signal must be a Struct Array");
+ g_warning ("The 3rd argument of UpdatePreedit signal must be a Struct Array");
return;
}
@@ -612,7 +639,7 @@ _gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *mes
if (dbus_message_iter_get_arg_type (&sub_iter) != DBUS_TYPE_INVALID) {
if (dbus_message_iter_get_arg_type (&sub_iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type (&sub_iter) != DBUS_TYPE_UINT32 ) {
- g_warning ("The secode argument of UpdatePreedit signal must be a Struct Array");
+ g_warning ("The 3rd argument of UpdatePreedit signal must be a Struct Array");
return;
}
@@ -627,7 +654,7 @@ _gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *mes
dbus_message_iter_get_fixed_array (&sub_sub_iter, &values, &length);
if (length <= 0) {
- g_warning ("The element of the second argument of UpdatePreedit should not be a empty array");
+ g_warning ("The element of the 3rd argument of UpdatePreedit should not be a empty array");
continue;
}
@@ -672,7 +699,7 @@ _gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *mes
type = dbus_message_iter_get_arg_type (&iter);
if (type != DBUS_TYPE_INT32) {
- g_warning ("The third argument of UpdatePreedit signal must be an Int32 %c", type);
+ g_warning ("The 4th argument of UpdatePreedit signal must be an Int32 %c", type);
pango_attr_list_unref (attrs);
return;
}
@@ -681,7 +708,7 @@ _gik_signal_update_preedit_handler (DBusConnection *connection, DBusMessage *mes
type = dbus_message_iter_get_arg_type (&iter);
if (type != DBUS_TYPE_BOOLEAN) {
- g_warning ("The third argument of UpdatePreedit signal must be an Int32 %c", type);
+ g_warning ("The 4th argument of UpdatePreedit signal must be an Int32 %c", type);
pango_attr_list_unref (attrs);
return;
}
@@ -1033,6 +1060,7 @@ gik_im_client_filter_keypress (GikIMClient *client, GdkEventKey *event)
_gik_filter_keypress_reply_cb,
gdk_event_copy ((GdkEvent *)event),
(DBusFreeFunction)gdk_event_free,
+ DBUS_TYPE_STRING, &priv->ic,
DBUS_TYPE_UINT32, &event->keyval,
DBUS_TYPE_BOOLEAN, &is_press,
DBUS_TYPE_UINT32, &state,
@@ -1046,9 +1074,11 @@ gik_im_client_filter_keypress (GikIMClient *client, GdkEventKey *event)
void
gik_im_client_focus_in (GikIMClient *client)
{
+ GikIMClientPrivate *priv = client->priv;
/* Call IBus FocusIn method */
_ibus_call_with_reply_and_block (client->priv->ibus,
"FocusIn",
+ DBUS_TYPE_STRING, &priv->ic,
DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID);
}
@@ -1056,9 +1086,11 @@ gik_im_client_focus_in (GikIMClient *client)
void
gik_im_client_focus_out (GikIMClient *client)
{
+ GikIMClientPrivate *priv = client->priv;
/* Call IBus FocusOut method */
_ibus_call_with_reply_and_block (client->priv->ibus,
"FocusOut",
+ DBUS_TYPE_STRING, &priv->ic,
DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID);
@@ -1067,9 +1099,11 @@ gik_im_client_focus_out (GikIMClient *client)
void
gik_im_client_reset (GikIMClient *client)
{
+ GikIMClientPrivate *priv = client->priv;
/* Call IBus Reset method */
_ibus_call_with_reply_and_block (client->priv->ibus,
"Reset",
+ DBUS_TYPE_STRING, &priv->ic,
DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID);
@@ -1127,6 +1161,7 @@ gik_im_client_set_cursor_location (GikIMClient *client, GdkRectangle *area)
_ibus_call_with_reply_and_block (client->priv->ibus,
"SetCursorLocation",
+ DBUS_TYPE_STRING, &priv->ic,
DBUS_TYPE_INT32, &area->x,
DBUS_TYPE_INT32, &area->y,
DBUS_TYPE_INT32, &area->width,
diff --git a/ibus/interface/iibus.py b/ibus/interface/iibus.py
index d6a2f7b..9b33e1d 100644
--- a/ibus/interface/iibus.py
+++ b/ibus/interface/iibus.py
@@ -19,39 +19,43 @@ class IIBus (dbus.service.Object):
@method (out_signature = "s")
def GetIBusAddress (self, dbusconn): pass
+ # methods for ibus clients
+ @method (in_signature = "s", out_signature = "s")
+ def CreateInputContext (self, client_name, dbusconn): pass
+
+ @method (in_signature = "s")
+ def ReleaseInputContext (self, ic, dbusconn): pass
+
+ @async_method (in_signature = "subu", out_signature = "b")
+ def ProcessKeyEvent (self, ic, keyval, is_press, state, dbusconn, reply_cb, error_cb): pass
+
+ @method (in_signature = "siiii")
+ def SetCursorLocation (self, ic, x, y, w, h, dbusconn): pass
+
+ @method (in_signature = "s")
+ def FocusIn (self, ic, dbusconn): pass
+
@method (in_signature = "s")
- def RegisterClient (self, client_name, dbusconn): pass
+ def FocusOut (self, ic, dbusconn): pass
- @method ()
- def UnregisterClient (self, dbusconn): pass
+ @method (in_signature = "s")
+ def Reset (self, ic, dbusconn): pass
+ @method (in_signature = "s", out_signature = "b")
+ def IsEnabled (self, ic, dbusconn): pass
+
+ # methods for ibus engine provide
@method (in_signature = "ao")
def RegisterFactories (self, object_paths, dbusconn): pass
@method (in_signature = "ao")
def UnregisterFactories (self, object_paths, dbusconn): pass
+ # methods for ibus panel
@method (in_signature = "ob")
def RegisterPanel (self, object_path, replace, dbusconn): pass
- @async_method (in_signature = "ubu", out_signature = "b")
- def ProcessKeyEvent (self, keyval, is_press, state, dbusconn, reply_cb, error_cb): pass
-
- @method (in_signature = "iiii")
- def SetCursorLocation (self, x, y, w, h, dbusconn): pass
-
- @method ()
- def FocusIn (self, dbusconn): pass
-
- @method ()
- def FocusOut (self, dbusconn): pass
-
- @method ()
- def Reset (self, dbusconn): pass
-
- @method (out_signature = "b")
- def IsEnabled (self, dbusconn): pass
-
+ # general methods
@method (out_signature = "av")
def GetFactories (self, dbusconn): pass
diff --git a/ibusdaemon/bus.py b/ibusdaemon/bus.py
index e5f61ce..1df2cc4 100644
--- a/ibusdaemon/bus.py
+++ b/ibusdaemon/bus.py
@@ -3,7 +3,7 @@ import weakref
import dbus
import ibus
from ibus import keysyms
-from clientmanager import ClientManager
+from contextmanager import ContextManager
from factorymanager import FactoryManager
from connection import Connection
from panel import Panel, DummyPanel
@@ -12,13 +12,13 @@ class IBus (ibus.Object):
def __init__ (self):
ibus.Object.__init__ (self)
self._connections = {}
- self._client_manager = ClientManager ()
+ self._context_manager = ContextManager ()
self._factory_manager = FactoryManager ()
self._panel = DummyPanel ()
- self._focused_client = None
- self._last_focused_client = None
- self._client_handlers = []
+ self._focused_context = None
+ self._last_focused_context = None
+ self._context_handlers = []
self._last_key = None
@@ -39,132 +39,134 @@ class IBus (ibus.Object):
return self._connections[dbusconn]
##########################################################
- # methods for im client
+ # methods for im context
##########################################################
- def register_client (self, name, dbusconn):
+ def create_input_context (self, name, dbusconn):
ibusconn = self._lookup_ibus_connection (dbusconn)
- client = self._client_manager.register_client (name, ibusconn)
+ context = self._context_manager.create_input_context (name, ibusconn)
factory = self._factory_manager.get_default_factory ()
if factory:
engine = factory.create_engine ()
- client.set_engine (engine)
+ context.set_engine (engine)
+ return context.get_id ()
- def focus_in (self, dbusconn):
- client = self._lookup_client (dbusconn)
+ def release_input_context (self, ic, dbusconn):
+ ibusconn = self._lookup_ibus_connection (dbusconn)
+ self._context_manager.release_input_context (ic, ibusconn)
+
+ def focus_in (self, ic, dbusconn):
+ context = self._lookup_context (ic, dbusconn)
- if self._focused_client != client and self._focused_client != None:
- map (self._focused_client.disconnect, self._client_handlers)
- self._client_handlers = []
- self._focused_client.focus_out ()
+ if self._focused_context != context and self._focused_context != None:
+ map (self._focused_context.disconnect, self._context_handlers)
+ self._context_handlers = []
+ self._focused_context.focus_out ()
# Install all callback functions
- id = client.connect ("update-preedit", self._update_preedit_cb)
- self._client_handlers.append (id)
- id = client.connect ("update-aux-string", self._update_aux_string_cb)
- self._client_handlers.append (id)
- id = client.connect ("update-lookup-table", self._update_lookup_table_cb)
- self._client_handlers.append (id)
- id = client.connect ("register-properties", self._register_properties_cb)
- self._client_handlers.append (id)
- id = client.connect ("update-property", self._update_property_cb)
- self._client_handlers.append (id)
- id = client.connect ("engine-lost", self._engine_lost_cb)
- self._client_handlers.append (id)
- id = client.connect ("destroy", self._client_destroy_cb)
- self._client_handlers.append (id)
+ id = context.connect ("update-preedit", self._update_preedit_cb)
+ self._context_handlers.append (id)
+ id = context.connect ("update-aux-string", self._update_aux_string_cb)
+ self._context_handlers.append (id)
+ id = context.connect ("update-lookup-table", self._update_lookup_table_cb)
+ self._context_handlers.append (id)
+ id = context.connect ("register-properties", self._register_properties_cb)
+ self._context_handlers.append (id)
+ id = context.connect ("update-property", self._update_property_cb)
+ self._context_handlers.append (id)
+ id = context.connect ("engine-lost", self._engine_lost_cb)
+ self._context_handlers.append (id)
+ id = context.connect ("destroy", self._context_destroy_cb)
+ self._context_handlers.append (id)
self._panel.reset ()
- self._focused_client = client
- self._last_focused_client = client
- client.focus_in ()
-
- def focus_out (self, dbusconn):
- client = self._lookup_client (dbusconn)
- if client == self._focused_client:
- map (self._focused_client.disconnect, self._client_handlers)
- self._client_handlers = []
- self._focused_client = None
- client.focus_out ()
+ self._focused_context = context
+ self._last_focused_context = context
+ context.focus_in ()
+
+ def focus_out (self, ic, dbusconn):
+ context = self._lookup_context (ic, dbusconn)
+ if context == self._focused_context:
+ map (self._focused_context.disconnect, self._context_handlers)
+ self._context_handlers = []
+ self._focused_context = None
+ context.focus_out ()
self._panel.reset ()
- def reset (self, dbusconn):
- client = self._lookup_client (dbusconn)
- client.reset ()
+ def reset (self, ic, dbusconn):
+ context = self._lookup_context (ic, dbusconn)
+ context.reset ()
- def is_enabled (self, dbusconn):
- client = self._lookup_client (dbusconn)
- return client.is_enabled ()
+ def is_enabled (self, ic, dbusconn):
+ context = self._lookup_context (ic, dbusconn)
+ return context.is_enabled ()
- def process_key_event (self, keyval, is_press, state,
+ def process_key_event (self, ic, keyval, is_press, state,
dbusconn, reply_cb, error_cb):
- client = self._lookup_client (dbusconn)
+ context = self._lookup_context (ic, dbusconn)
- if self._filter_hotkeys (client, keyval, is_press, state):
+ if self._filter_hotkeys (context, keyval, is_press, state):
reply_cb (True)
return
else:
- client.process_key_event (keyval, is_press, state, reply_cb, error_cb)
+ context.process_key_event (keyval, is_press, state, reply_cb, error_cb)
- def set_cursor_location (self, x, y, w, h, dbusconn):
- client = self._lookup_client (dbusconn)
- client.set_cursor_location (x, y, w, h)
+ def set_cursor_location (self, ic, x, y, w, h, dbusconn):
+ context = self._lookup_context (ic, dbusconn)
+ context.set_cursor_location (x, y, w, h)
self._panel.set_cursor_location (x, y, w, h)
- def _filter_hotkeys (self, client, keyval, is_press, state):
+ def _filter_hotkeys (self, context, keyval, is_press, state):
if is_press and keyval == keysyms.space \
and state == keysyms.CONTROL_MASK:
- enable = not client.is_enabled ()
- client.set_enable (enable)
- if client.get_engine () == None and enable:
+ enable = not context.is_enabled ()
+ context.set_enable (enable)
+ if context.get_engine () == None and enable:
factory = self._factory_manager.get_default_factory ()
if factory:
engine = factory.create_engine ()
- client.set_engine (engine)
+ context.set_engine (engine)
return True
return False
- def _lookup_client (self, dbusconn):
+ def _lookup_context (self, ic, dbusconn):
ibusconn = self._lookup_ibus_connection (dbusconn)
- return self._client_manager.lookup_client (ibusconn)
- if dbusconn not in self._clients:
- raise ibus.IBusException ("not register the client")
- return self._clients[dbusconn]
+ return self._context_manager.lookup_context (ic, ibusconn)
- def _update_preedit_cb (self, client, text, attrs, cursor_pos, visible):
- assert self._focused_client == client
+ def _update_preedit_cb (self, context, text, attrs, cursor_pos, visible):
+ assert self._focused_context == context
self._panel.update_preedit_string (text, attrs, cursor_pos, visible)
- def _update_aux_string_cb (self, client, text, attrs, visible):
- assert self._focused_client == client
+ def _update_aux_string_cb (self, context, text, attrs, visible):
+ assert self._focused_context == context
self._panel.update_aux_string (text, attrs, visible)
- def _update_lookup_table_cb (self, client, lookup_table, visible):
- assert self._focused_client == client
+ def _update_lookup_table_cb (self, context, lookup_table, visible):
+ assert self._focused_context == context
self._panel.update_lookup_table (lookup_table, visible)
- def _register_properties_cb (self, client, props):
- assert self._focused_client == client
+ def _register_properties_cb (self, context, props):
+ assert self._focused_context == context
self._panel.register_properties (props)
- def _update_property_cb (self, client, prop):
- assert self._focused_client == client
+ def _update_property_cb (self, context, prop):
+ assert self._focused_context == context
self._panel.update_property (prop)
- def _engine_lost_cb (self, client):
- assert self._focused_client == client
+ def _engine_lost_cb (self, context):
+ assert self._focused_context == context
self._panel.reset ()
- def _client_destroy_cb (self, client):
- assert client == self._focused_client
- self._client_handlers = []
- self._focused_client = None
+ def _context_destroy_cb (self, context):
+ assert context == self._focused_context
+ self._context_handlers = []
+ self._focused_context = None
##########################################################
# methods for im engines
@@ -201,28 +203,28 @@ class IBus (ibus.Object):
def _panel_page_up_cb (self, panel):
assert panel == self._panel
- if self._focused_client:
- self._focused_client.page_up ()
+ if self._focused_context:
+ self._focused_context.page_up ()
def _panel_page_down_cb (self, panel):
assert panel == self._panel
- if self._focused_client:
- self._focused_client.page_down ()
+ if self._focused_context:
+ self._focused_context.page_down ()
def _panel_cursor_up_cb (self, panel):
assert panel == self._panel
- if self._focused_client:
- self._focused_client.cursor_up ()
+ if self._focused_context:
+ self._focused_context.cursor_up ()
def _panel_cursor_down_cb (self, panel):
assert panel == self._panel
- if self._focused_client:
- self._focused_client.cursor_down ()
+ if self._focused_context:
+ self._focused_context.cursor_down ()
def _panel_property_active_cb (self, panel, prop_name):
assert panel == self._panel
- if self._focused_client:
- self._focused_client.property_activate (prop_name)
+ if self._focused_context:
+ self._focused_context.property_activate (prop_name)
def _panel_destroy_cb (self, panel):
if panel == self._panel:
@@ -238,12 +240,12 @@ class IBus (ibus.Object):
return self._factory_manager.get_factory_info (factory_path)
def set_factory (self, factory_path):
- if self._focused_client == None:
+ if self._focused_context == None:
return
self._panel.reset ()
factory = self._factory_manager.get_factory (factory_path)
engine = factory.create_engine ()
- self._focused_client.set_engine (engine)
+ self._focused_context.set_engine (engine)
class IBusProxy (ibus.IIBus):
SUPPORTS_MULTIPLE_CONNECTIONS = True
@@ -264,8 +266,11 @@ class IBusProxy (ibus.IIBus):
def GetIBusAddress (self, dbusconn):
return self._ibus_addr
- def RegisterClient (self, client_name, dbusconn):
- self._ibus.register_client (client_name, dbusconn)
+ def CreateInputContext (self, context_name, dbusconn):
+ return self._ibus.create_input_context (context_name, dbusconn)
+
+ def ReleaseInputContext (self, ic, dbusconn):
+ self._ibus.release_input_context (ic, dbusconn)
def RegisterFactories (self, object_paths, dbusconn):
self._ibus.register_factories (object_paths, dbusconn)
@@ -276,28 +281,28 @@ class IBusProxy (ibus.IIBus):
def RegisterPanel (self, object_path, replace, dbusconn):
self._ibus.register_panel (object_path, replace, dbusconn)
- def ProcessKeyEvent (self, keyval, is_press, state, \
+ def ProcessKeyEvent (self, ic, keyval, is_press, state, \
dbusconn, reply_cb, error_cb):
try:
- self._ibus.process_key_event (keyval, is_press, state,
+ self._ibus.process_key_event (ic, keyval, is_press, state,
dbusconn, reply_cb, error_cb)
except Exception, e:
error_cb (e)
- def SetCursorLocation (self, x, y, w, h, dbusconn):
- self._ibus.set_cursor_location (x, y, w, h, dbusconn)
+ def SetCursorLocation (self, ic, x, y, w, h, dbusconn):
+ self._ibus.set_cursor_location (ic, x, y, w, h, dbusconn)
- def FocusIn (self, dbusconn):
- self._ibus.focus_in (dbusconn)
+ def FocusIn (self, ic, dbusconn):
+ self._ibus.focus_in (ic, dbusconn)
- def FocusOut (self, dbusconn):
- self._ibus.focus_out (dbusconn)
+ def FocusOut (self, ic, dbusconn):
+ self._ibus.focus_out (ic, dbusconn)
- def Reset (self, dbusconn):
- self._ibus.reset (dbusconn)
+ def Reset (self, ic, dbusconn):
+ self._ibus.reset (ic, dbusconn)
- def IsEnabled (self, dbusconn):
- return self._ibus.is_enabled (dbusconn)
+ def IsEnabled (self, ic, dbusconn):
+ return self._ibus.is_enabled (ic, dbusconn)
def GetFactories (self, dbusconn):
return self._ibus.get_factories ()
diff --git a/ibusdaemon/clientmanager.py b/ibusdaemon/clientmanager.py
deleted file mode 100644
index 0c59b14..0000000
--- a/ibusdaemon/clientmanager.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import ibus
-from client import Client
-
-class ClientManager (ibus.Object):
- def __init__ (self):
- self._clients = {}
-
- def register_client (self, name, ibusconn):
- if ibusconn in self._clients:
- raise ibus.IBusException ("client has been registered")
- client = Client (name, ibusconn)
- self._clients[ibusconn] = client
- ibusconn.connect ("destroy", self._ibusconn_destroy_cb)
- return client
-
- def lookup_client (self, ibusconn):
- return self._clients[ibusconn]
-
- def _ibusconn_destroy_cb (self, ibusconn):
- del self._clients[ibusconn]
-
diff --git a/ibusdaemon/contextmanager.py b/ibusdaemon/contextmanager.py
new file mode 100644
index 0000000..8ac3f98
--- /dev/null
+++ b/ibusdaemon/contextmanager.py
@@ -0,0 +1,19 @@
+import ibus
+from inputcontext import InputContext
+
+class ContextManager (ibus.Object):
+ def __init__ (self):
+ self._contexts = {}
+
+ def create_input_context (self, name, ibusconn):
+ context = InputContext (name, ibusconn)
+ self._contexts[context.get_id ()] = context
+ context.connect ("destroy", self._context_destroy_cb)
+ return context
+
+ def lookup_context (self, ic, ibusconn):
+ return self._contexts[ic]
+
+ def _context_destroy_cb (self, context):
+ del self._clients[context.get_id ()]
+
diff --git a/ibusdaemon/client.py b/ibusdaemon/inputcontext.py
index 400b11b..4d5a7d6 100644
--- a/ibusdaemon/client.py
+++ b/ibusdaemon/inputcontext.py
@@ -1,7 +1,8 @@
import gobject
import ibus
-class Client (ibus.Object):
+class InputContext (ibus.Object):
+ id = 1
__gsignals__ = {
"update-preedit" : (
gobject.SIGNAL_RUN_FIRST,
@@ -31,7 +32,8 @@ class Client (ibus.Object):
def __init__ (self, name, ibusconn):
ibus.Object.__init__ (self)
-
+ self._id = "%d" % InputContext.id
+ InputContext.id += 1
self._ibusconn = ibusconn
self._ibusconn.connect ("destroy", self._ibusconn_destroy_cb)
@@ -52,6 +54,9 @@ class Client (ibus.Object):
self._lookup_table = None
self._show_lookup_table = False
+ def get_id (self):
+ return self._id;
+
def get_preedit_string (self):
return self._preedit_string, self._preedit_attrs, self._cursor_pos
@@ -112,18 +117,18 @@ class Client (ibus.Object):
if self._enable != enable:
self._enable = enable
if self._enable:
- self._ibusconn.emit_dbus_signal ("Enabled")
+ self._ibusconn.emit_dbus_signal ("Enabled", self._id)
else:
- self._ibusconn.emit_dbus_signal ("Disabled")
+ self._ibusconn.emit_dbus_signal ("Disabled", self._id)
if self._engine:
self._engine.set_enable (self._enable)
def commit_string (self, text):
- self._ibusconn.emit_dbus_signal ("CommitString", text)
+ self._ibusconn.emit_dbus_signal ("CommitString", self._id, text)
def update_preedit (self, text, attrs, cursor_pos, visible):
if self._use_preedit:
- self._ibusconn.emit_dbus_signal ("UpdatePreedit", text, attrs, cursor_pos, visible)
+ self._ibusconn.emit_dbus_signal ("UpdatePreedit", self._id, text, attrs, cursor_pos, visible)
else:
# show preedit on panel
self.emit ("update-preedit", text, attrs, cursor_pos, visible)
@@ -150,11 +155,12 @@ class Client (ibus.Object):
self._enable = False
if self._use_preedit:
self._ibusconn.emit_dbus_signal ("UpdatePreedit",
+ self._id,
u"",
ibus.AttrList ().to_dbus_value (),
0,
False)
- self._ibusconn.emit_dbus_signal ("Disabled")
+ self._ibusconn.emit_dbus_signal ("Disabled", self._id)
self.emit ("engine-lost")
def _ibusconn_destroy_cb (self, ibusconn):
@@ -206,4 +212,4 @@ class Client (ibus.Object):
id = self._engine.connect ("update-property", self._update_property_cb)
self._engine_handler_ids.append (id)
-gobject.type_register (Client)
+gobject.type_register (InputContext)
diff --git a/panel/panel.py b/panel/panel.py
index dde3a64..e8a076d 100644
--- a/panel/panel.py
+++ b/panel/panel.py
@@ -30,7 +30,7 @@ class Panel (ibus.Object):
self._status_icon.connect ("popup-menu", self._status_icon_popup_menu_cb)
self._status_icon.connect ("activate", self._status_icon_activate_cb)
self._status_icon.set_from_icon_name ("engine-default")
- self._status_icon.set_tooltip ("ibus - running")
+ self._status_icon.set_tooltip ("iBus - Running")
self._status_icon.set_visible (True)
def set_cursor_location (self, x, y, w, h):