if self._enable:
self.RegisterProperties (self._prop_list.to_dbus_value ())
-
def PropertyActivate (self, prop_name):
print "PropertyActivate (%s)" % prop_name
def HideLanguageBar (self): pass
@method ()
- def Reste (self): pass
+ def Reset (self): pass
@method ()
def Destroy (self): pass
def register_client (self, name, dbusconn):
ibusconn = self._lookup_ibus_connection (dbusconn)
client = self._client_manager.register_client (name, ibusconn)
- client.connect ("destroy", self._client_destroy_cb)
factory = self._factory_manager.get_default_factory ()
if factory:
engine = factory.create_engine ()
if self._focused_client != client and self._focused_client != None:
map (self._focused_client.disconnect, self._client_handlers)
- del self._client_handlers[:]
+ self._client_handlers = []
self._focused_client.focus_out ()
# Install all callback functions
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)
self._panel.reset ()
self._focused_client = client
client = self._lookup_client (dbusconn)
if client == self._focused_client:
map (self._focused_client.disconnect, self._client_handlers)
- del self._client_handlers[:]
+ self._client_handlers = []
self._focused_client = None
client.focus_out ()
self._panel.reset ()
def reset (self, dbusconn):
client = self._lookup_client (dbusconn)
- self._panel.reset ()
client.reset ()
def is_enabled (self, dbusconn):
self._panel.update_property (prop)
+ def _engine_lost_cb (self, client):
+ assert self._focused_client == client
+
+ self._panel.reset ()
+
def _client_destroy_cb (self, client):
- if client == self._focused_client:
- del self._client_handlers[:]
- self._focused_client = None
+ assert client == self._focused_client
+ self._client_handlers = []
+ self._focused_client = None
##########################################################
# methods for im engines
gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT, )),
+ "engine-lost" : (
+ gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ()),
}
def __init__ (self, name, ibusconn):
if self._engine == engine:
self._remove_engine_handlers ()
self._engine = None
+ self._enable = False
+ self._ibusconn.emit_dbus_signal ("Disabled")
+ self.emit ("engine-lost")
def _ibusconn_destroy_cb (self, ibusconn):
if self._engine != None:
self._panel.HideLanguageBar ()
def reset (self):
- self._panel.Reste ()
+ self._panel.Reset ()
def destroy (self):
if self._ibusconn != None:
import gtk.gdk as gdk
import gobject
import pango
+import ibus
from ibus.gtk import PangoAttrList
class HSeparator (gtk.HBox):
self.hide_preedit_string ()
self.hide_aux_string ()
self.hide_lookup_table ()
- self.set_preedit_string ("", None, 0)
- self.set_aux_string ("", None)
- self.set_lookup_table (None)
+ self.update_preedit ("", None, 0, False)
+ self.update_aux_string ("", None, False)
+ self.update_lookup_table (None, False)
def set_orientation (self, orientation):
if self._orientation == orientation:
self.set_size_request (width + 4, -1)
def reset (self):
- pass
+ self._remove_properties ()
def register_properties (self, props):
- # reset all properties
- for name, prop in self._properties.items ():
- prop[1].destroy ()
- self._properties = {}
-
+ self._remove_properties ()
# create new properties
for prop in props:
if prop._type == ibus.PROP_TYPE_NORMAL:
else:
widget.set_no_show_all (True)
widget.hide ()
-
- self._properties [prop._name] = (prop, widget)
+ if not self._properties.has_key (prop._name):
+ self._properties [prop._name] = []
+ self._properties [prop._name].append ((prop, widget))
self.insert (widget, -1)
self.check_resize ()
def update_properties (self, props):
pass
+ def _remove_properties (self):
+ # reset all properties
+ for name, props in self._properties.items ():
+ for prop, widget in props:
+ widget.hide ()
+ widget.destroy ()
+ self._properties = {}
+ self.check_resize ()
+
gobject.type_register (LanguageBar, "IBusLanguageBar")
class LanguageBarWindow (gtk.Window):
def __init__ (self):
gtk.Window.__init__ (self, gtk.WINDOW_POPUP)
self._language_bar = LanguageBar ()
+ self._language_bar.connect ("size-request", self._size_request_cb)
self._language_bar.connect ("property-activate",
lambda widget, prop_name: self.emit ("property-activate", prop_name))
self.add (self._language_bar)
def update_property (self, prop):
self._labguage_bar.update_property (prop)
+ def _size_request_cb (self, widget, requisition):
+ self.resize (1, 1)
+
gobject.type_register (LanguageBarWindow, "IBusLanguageBarWindow")