~ubuntu-branches/ubuntu/quantal/ibus/quantal

« back to all changes in this revision

Viewing changes to ibus/inputcontext.py

  • Committer: Bazaar Package Importer
  • Author(s): Barry Warsaw
  • Date: 2011-08-11 17:00:57 UTC
  • mfrom: (6.2.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110811170057-6dmbfs4s3cchzl7x
Tags: 1.3.99.20110419-1ubuntu1
* Merge with Debian unstable.  Remaining Ubuntu changes:
  - Indicator support:
    + Add 05_appindicator.patch: Use an indicator rather than a notification
      icon.
    + debian/control: Recommend python-appindicator.
  - debian/control: Install im-switch instead of im-config by default.
  - debian/README.source: Removed, it was outdated and no longer correct
  - debian/patches/01_ubuntu_desktop: Fix "Desktop entry needs the
    X-Ubuntu-Gettext-Domain key"  (LP: #457632)
  - debian/patches/02_title_update.patch: Rename "IBus Preferences" to
    "Keyboard Input Methods"
  - debian/patches/06_locale_parser.patch: Cherry-picked from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import object
32
32
import common
33
33
import serializable
 
34
from text import Text
34
35
 
35
36
class InputContext(object.Object):
36
37
    __gtype_name__ = "PYIBusInputContext"
124
125
        _context = bus.get_dbusconn().get_object(common.IBUS_SERVICE_IBUS, path)
125
126
        self.__context = dbus.Interface(_context, dbus_interface="org.freedesktop.IBus.InputContext")
126
127
        self.__signal_matches = []
 
128
        self.__needs_surrounding_text = False
 
129
        self.__surrounding_text = Text()
 
130
        self.__surrounding_cursor_pos = 0
127
131
 
128
132
        if not watch_signals:
129
133
            return
136
140
        self.__signal_matches.append(m)
137
141
        m = self.__context.connect_to_signal("UpdateLookupTable", self.__update_lookup_table_cb)
138
142
        self.__signal_matches.append(m)
 
143
        m = self.__context.connect_to_signal("RequireSurroundingText", self.__require_surrounding_text_cb)
 
144
        self.__signal_matches.append(m)
139
145
 
140
146
        m = self.__context.connect_to_signal("Enabled",             lambda *args: self.emit("enabled"))
141
147
        self.__signal_matches.append(m)
182
188
        visible = args[1]
183
189
        self.emit("update-lookup-table", table, visible)
184
190
 
 
191
    def __require_surrounding_text_cb(self, *args):
 
192
        self.__needs_surrounding_text = True
 
193
 
 
194
    def needs_surrounding_text(self):
 
195
        return self.__needs_surrounding_text
 
196
 
 
197
    def set_surrounding_text(self, text, cursor_pos):
 
198
        if self.__surrounding_text.get_text() != text or \
 
199
                self.__surrounding_cursor_pos != cursor_pos:
 
200
            self.__surrounding_text = Text(text)
 
201
            self.__surrounding_cursor_pos = cursor_pos
 
202
            text = serializable.serialize_object(self.__surrounding_text)
 
203
            cursor_pos = dbus.UInt32(self.__surrounding_cursor_pos)
 
204
            self.__context.SetSurroundingText(text, cursor_pos)
 
205
 
185
206
    def process_key_event(self, keyval, keycode, modifiers):
186
207
        keyval = dbus.UInt32(keyval)
187
208
        keycode = dbus.UInt32(keycode)
224
245
 
225
246
    def destroy(self):
226
247
        self.detach_signals()
227
 
        self.__context.Destroy()
228
248
        super(InputContext, self).destroy()
229
249
 
230
250
    def get_engine(self):