diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-07-15 11:36:07 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-07-15 11:36:07 +0800 |
| commit | 86834bb4e912c2021de561412d0077bcb5ee7239 (patch) | |
| tree | 4292609ea4fe2ee0507b27787b469a2f4da8129a /daemon/inputcontext.py | |
| parent | 7bf8b4112a5d180d30dcb998012ea58b48392be2 (diff) | |
| download | ibus-86834bb4e912c2021de561412d0077bcb5ee7239.tar.gz ibus-86834bb4e912c2021de561412d0077bcb5ee7239.tar.xz ibus-86834bb4e912c2021de561412d0077bcb5ee7239.zip | |
Refine coding style of inputcontext.py
Diffstat (limited to 'daemon/inputcontext.py')
| -rw-r--r-- | daemon/inputcontext.py | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/daemon/inputcontext.py b/daemon/inputcontext.py index 3a4c339..3056687 100644 --- a/daemon/inputcontext.py +++ b/daemon/inputcontext.py @@ -22,7 +22,7 @@ import gobject import ibus -class InputContext (ibus.Object): +class InputContext(ibus.Object): id = 1 __gsignals__ = { "update-preedit" : ( @@ -51,12 +51,12 @@ class InputContext (ibus.Object): ()), } - def __init__ (self, name, ibusconn): - ibus.Object.__init__ (self) + def __init__(self, name, ibusconn): + super(InputContext, self).__init__() self._id = "%d" % InputContext.id InputContext.id += 1 self._ibusconn = ibusconn - self._ibusconn.connect ("destroy", self._ibusconn_destroy_cb) + self._ibusconn.connect("destroy", self._ibusconn_destroy_cb) # init default values self._enable = False @@ -75,163 +75,163 @@ class InputContext (ibus.Object): self._lookup_table = None self._show_lookup_table = False - def get_id (self): + def get_id(self): return self._id; - def get_preedit_string (self): + def get_preedit_string(self): return self._preedit_string, self._preedit_attrs, self._cursor_pos - def get_use_preedit (self): + def get_use_preedit(self): return self._use_preedit - def get_aux_string (self): + def get_aux_string(self): return self._aux_string, self._aux_attrs - def process_key_event (self, keyval, is_press, state, + def process_key_event(self, keyval, is_press, state, reply_cb, error_cb): if self._engine != None and self._enable: - self._engine.process_key_event (keyval, is_press, state, + self._engine.process_key_event(keyval, is_press, state, reply_cb, error_cb) else: - reply_cb (False) + reply_cb(False) - def set_cursor_location (self, x, y, w, h): + def set_cursor_location(self, x, y, w, h): if self._engine: - self._engine.set_cursor_location (x, y, w, h) + self._engine.set_cursor_location(x, y, w, h) - def focus_in (self): + def focus_in(self): if self._engine: - self._engine.focus_in () + self._engine.focus_in() - def focus_out (self): + def focus_out(self): if self._engine: - self._engine.focus_out () + self._engine.focus_out() - def reset (self): + def reset(self): if self._engine: - self._engine.reset () + self._engine.reset() - def page_up (self): + def page_up(self): if self._engine: - self._engine.page_up () + self._engine.page_up() - def page_down (self): + def page_down(self): if self._engine: - self._engine.page_down () + self._engine.page_down() - def cursor_up (self): + def cursor_up(self): if self._engine: - self._engine.cursor_up () + self._engine.cursor_up() - def cursor_down (self): + def cursor_down(self): if self._engine: - self._engine.cursor_down () + self._engine.cursor_down() - def property_activate (self, prop_name, prop_state): + def property_activate(self, prop_name, prop_state): if self._engine: - self._engine.property_activate (prop_name, prop_state) + self._engine.property_activate(prop_name, prop_state) - def property_show (self, prop_name): + def property_show(self, prop_name): if self._engine: - self._engine.property_show (prop_name) + self._engine.property_show(prop_name) - def property_hide (self, prop_name): + def property_hide(self, prop_name): if self._engine: - self._engine.property_hide (prop_name) + self._engine.property_hide(prop_name) - def is_enabled (self): + def is_enabled(self): return self._enable - def set_enable (self, enable): + def set_enable(self, enable): if self._enable != enable: self._enable = enable if self._enable: - self._ibusconn.emit_dbus_signal ("Enabled", self._id) + self._ibusconn.emit_dbus_signal("Enabled", self._id) else: - self._ibusconn.emit_dbus_signal ("Disabled", self._id) + self._ibusconn.emit_dbus_signal("Disabled", self._id) if self._engine: - self._engine.set_enable (self._enable) + self._engine.set_enable(self._enable) - def commit_string (self, text): - self._ibusconn.emit_dbus_signal ("CommitString", self._id, text) + def commit_string(self, text): + self._ibusconn.emit_dbus_signal("CommitString", self._id, text) - def update_preedit (self, text, attrs, cursor_pos, visible): + def update_preedit(self, text, attrs, cursor_pos, visible): if self._use_preedit: - self._ibusconn.emit_dbus_signal ("UpdatePreedit", self._id, 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) + self.emit("update-preedit", text, attrs, cursor_pos, visible) - def set_engine (self, engine): + def set_engine(self, engine): if self._engine == engine: return if self._engine != None: - self._remove_engine_handlers () - self._engine.destroy () + self._remove_engine_handlers() + self._engine.destroy() self._engine = None self._engine = engine - self._install_engine_handlers () + self._install_engine_handlers() - def get_engine (self): + def get_engine(self): return self._engine - def get_factory (self): + def get_factory(self): if self._engine: - return self._engine.get_factory () + return self._engine.get_factory() return None - def _engine_destroy_cb (self, engine): + def _engine_destroy_cb(self, engine): if self._engine == engine: - self._remove_engine_handlers () + self._remove_engine_handlers() self._engine = None self._enable = False if self._use_preedit: - self._ibusconn.emit_dbus_signal ("UpdatePreedit", + self._ibusconn.emit_dbus_signal("UpdatePreedit", self._id, u"", - ibus.AttrList ().to_dbus_value (), + ibus.AttrList().to_dbus_value(), 0, False) - self._ibusconn.emit_dbus_signal ("Disabled", self._id) - self.emit ("engine-lost") + self._ibusconn.emit_dbus_signal("Disabled", self._id) + self.emit("engine-lost") - def _ibusconn_destroy_cb (self, ibusconn): + def _ibusconn_destroy_cb(self, ibusconn): if self._engine != None: - self._remove_engine_handlers () - self._engine.destroy () + self._remove_engine_handlers() + self._engine.destroy() self._engine = None - self.destroy () + self.destroy() - def _commit_string_cb (self, engine, text): - self.commit_string (text) + def _commit_string_cb(self, engine, text): + self.commit_string(text) - def _update_preedit_cb (self, engine, text, attrs, cursor_pos, visible): - self.update_preedit (text, attrs, cursor_pos, visible) + def _update_preedit_cb(self, engine, text, attrs, cursor_pos, visible): + self.update_preedit(text, attrs, cursor_pos, visible) - def _update_aux_string_cb (self, engine, text, attrs, visible): + def _update_aux_string_cb(self, engine, text, attrs, visible): self._aux_string = text self._aux_attrs = attrs - self.emit ("update-aux-string", text, attrs, visible) + self.emit("update-aux-string", text, attrs, visible) - def _update_lookup_table_cb (self, engine, lookup_table, visible): + def _update_lookup_table_cb(self, engine, lookup_table, visible): self._lookup_table = lookup_table - self.emit ("update-lookup-table", lookup_table, visible) + self.emit("update-lookup-table", lookup_table, visible) - def _register_properties_cb (self, engine, props): - self.emit ("register-properties", props) + def _register_properties_cb(self, engine, props): + self.emit("register-properties", props) - def _update_property_cb (self, engine, prop): - self.emit ("update-property", prop) + def _update_property_cb(self, engine, prop): + self.emit("update-property", prop) - def _remove_engine_handlers (self): + def _remove_engine_handlers(self): assert self._engine != None - map (self._engine.disconnect, self._engine_handlers) + map(self._engine.disconnect, self._engine_handlers) del self._engine_handlers[:] - def _install_engine_handlers (self): + def _install_engine_handlers(self): signals = ( ("destroy", self._engine_destroy_cb), ("commit-string", self._commit_string_cb), @@ -243,7 +243,7 @@ class InputContext (ibus.Object): ) for signal, handler in signals: - id = self._engine.connect (signal, handler) - self._engine_handlers.append (id) + id = self._engine.connect(signal, handler) + self._engine_handlers.append(id) -gobject.type_register (InputContext) +gobject.type_register(InputContext) |
