self._focused_context = context
self._install_focused_context_handlers ()
- self._panel.reset ()
+ self._panel.focus_in (context.get_id ())
self._last_focused_context = context
context.focus_in ()
self._focused_context = None
context.focus_out ()
- self._panel.reset ()
+ self._panel.focus_out (context.get_id ())
def reset (self, ic, dbusconn):
context = self._lookup_context (ic, dbusconn)
if factory:
engine = factory.create_engine ()
context.set_engine (engine)
+ self._panel.states_changed ()
return True
return False
engine = factory.create_engine ()
self._focused_context.set_engine (engine)
+ def get_input_context_states (self, ic, dbusconn):
+ context = self._lookup_context (ic, dbusconn)
+ factory_path = "" if context.get_factory () == None else context.get_factory ().get_object_path ()
+ return factory_path, context.is_enabled ()
+
+
class IBusProxy (ibus.IIBus):
SUPPORTS_MULTIPLE_CONNECTIONS = True
def SetFactory (self, factory_path, dbusconn):
return self._ibus.set_factory (factory_path)
+ def GetInputContextStates (self, ic, dbusconn):
+ return self._ibus.get_input_context_states (ic, dbusconn)
+
def get_factory (self):
return self._factory
+ def get_object_path (self):
+ return self._object_path
+
def handle_dbus_signal (self, message):
if message.is_signal (ibus.IBUS_ENGINE_IFACE, "CommitString"):
args = message.get_args_list ()
def get_engine (self):
return self._engine
+ def get_factory (self):
+ if self._engine:
+ return self._engine.get_factory ()
+ return None
+
def _engine_destroy_cb (self, engine):
if self._engine == engine:
self._remove_engine_handlers ()
def hide_language_bar (self):
self._panel.HideLanguageBar (**ibus.DEFAULT_ASYNC_HANDLERS)
+ def focus_in (self, ic):
+ self._panel.FocusIn (ic, **ibus.DEFAULT_ASYNC_HANDLERS)
+
+ def focus_out (self, ic):
+ self._panel.FocusOut (ic, **ibus.DEFAULT_ASYNC_HANDLERS)
+
+ def states_changed (self):
+ self._panel.StatesChanged (**ibus.DEFAULT_ASYNC_HANDLERS)
+
def reset (self):
self._panel.Reset (**ibus.DEFAULT_ASYNC_HANDLERS)
def hide_language_bar (self):
pass
+ def focus_in (self, ic):
+ pass
+
+ def focus_out (self, ic):
+ pass
+
+ def states_changed (self):
+ pass
+
def reset (self):
pass
@method (in_signature = "o")
def SetFactory (self, factory_path, dbusconn): pass
+ @method (in_signature = "s", out_signature = "ob")
+ def GetInputContextStates (self, ic, dbusconn): pass
+
#sigals
def CommitString (self, ic, text): pass
dbus.service.method (dbus_interface = IBUS_PANE_IFACE, \
async_callbacks = ("reply_cb", "error_cb"), \
**args)
- @method (in_signature="iiii")
+ @method (in_signature = "iiii")
def SetCursorLocation (self, x, y, w, h): pass
- @method (in_signature="svub")
+ @method (in_signature = "svub")
def UpdatePreedit (self, text, attrs, cursor_pos, visible): pass
- @method (in_signature="svb")
+ @method (in_signature = "svb")
def UpdateAuxString (self, text, attrs, visible): pass
- @method (in_signature="vb")
+ @method (in_signature = "vb")
def UpdateLookupTable (self, lookup_table, visible): pass
- @method (in_signature="v")
+ @method (in_signature = "v")
def RegisterProperties (self, props): pass
- @method (in_signature="v")
+ @method (in_signature = "v")
def UpdateProperty (self, prop): pass
@method ()
@method ()
def HideLanguageBar (self): pass
+ @method (in_signature = "s")
+ def FocusIn (self, ic): pass
+
+ @method (in_signature = "s")
+ def FocusOut (self, ic): pass
+
+ @method ()
+ def StatesChanged (self): pass
+
@method ()
def Reset (self): pass
gtk.Toolbar.do_size_request (self, requisition)
self._toplevel.resize (1, 1)
+ def set_im_icon (self, icon_name):
+ self._im_menu.set_icon_name (icon_name)
+
def reset (self):
self._remove_properties ()
gobject.GObject.__init__ (self)
self._proxy = proxy
self._ibus = _ibus
+ self._focus_ic = None
# add icon search path
icon_theme = gtk.icon_theme_get_default ()
lambda widget, prop_name, prop_state: self._proxy.PropertyActivate (prop_name, prop_state))
self._language_bar.connect ("get-im-menu",
self._get_im_menu_cb)
- self._language_bar.show_all ()
self._candidate_panel = CandidatePanel ()
self._candidate_panel.connect ("cursor-up",
def update_property (self, prop):
self._language_bar.update_property (self, prop)
+ def _set_im_icon (self, icon_name):
+ self._language_bar.set_im_icon (icon_name)
+ self._status_icon.set_from_icon_name (icon_name)
+
+ def focus_in (self, ic):
+ self.reset ()
+ self._focus_ic = ic
+ factory, enabled = self._ibus.GetInputContextStates (ic)
+ if not enabled:
+ self._set_im_icon ("engine-default")
+ else:
+ name, lang, icon, authors, credits = self._ibus.GetFactoryInfo (factory)
+ self._set_im_icon (icon)
+ self._language_bar.show_all ()
+
+ def focus_out (self, ic):
+ self.reset ()
+ if self._focus_ic == ic:
+ self._focus_ic = None
+ self._language_bar.hide_all ()
+ self._set_im_icon ("engine-default")
+
+ def states_changed (self):
+ if not self._focus_ic:
+ return
+ factory, enabled = self._ibus.GetInputContextStates (self._focus_ic)
+ if not enabled:
+ self._set_im_icon ("engine-default")
+ else:
+ name, lang, icon, authors, credits = self._ibus.GetFactoryInfo (factory)
+ self._set_im_icon (icon)
+
def reset (self):
self._candidate_panel.reset ()
self._language_bar.reset ()
prop = ibus.property_from_dbus_value (props)
self._panel.update_property (prop)
+ def FocusIn (self, ic):
+ self._panel.focus_in (ic)
+
+ def FocusOut (self, ic):
+ self._panel.focus_out (ic)
+
+ def StatesChanged (self):
+ self._panel.states_changed ()
+
def Reset (self):
self._panel.reset ()