summaryrefslogtreecommitdiff
path: root/ibus
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@chromium.org>2011-08-11 20:53:13 -0400
committerPeng Huang <shawn.p.huang@gmail.com>2011-08-11 20:53:13 -0400
commit2ed0adc7a238d5a19f8b01cdcd165a34608bf9f3 (patch)
treebd6f2bb17c19ea11cc5fca4dfd32dada858f3a0c /ibus
parent6ec33ea8cdf16c6225896351a59ac9a01d5e36ca (diff)
downloadibus-2ed0adc7a238d5a19f8b01cdcd165a34608bf9f3.tar.gz
Support selection text retrival.
This patch enable us to get selection text on client application. Currently only GtkTextView widget can get them in gtk application. BUG=None TEST=manually done.(By gedit text editor) Review URL: http://codereview.appspot.com/4844041 Patch from Seigo Nonaka <nona@chromium.org>.
Diffstat (limited to 'ibus')
-rw-r--r--ibus/engine.py9
-rw-r--r--ibus/inputcontext.py11
-rw-r--r--ibus/interface/iengine.py4
-rw-r--r--ibus/interface/iinputcontext.py6
4 files changed, 16 insertions, 14 deletions
diff --git a/ibus/engine.py b/ibus/engine.py
index fe5dd98b..d6282063 100644
--- a/ibus/engine.py
+++ b/ibus/engine.py
@@ -36,6 +36,7 @@ class EngineBase(object.Object):
self.__proxy = EngineProxy (self, bus.get_dbusconn(), object_path)
self.__surrounding_text = Text()
self.__surrounding_cursor_pos = 0
+ self.__selection_anchor_pos = 0
def process_key_event(self, keyval, keycode, state):
return False
@@ -49,10 +50,11 @@ class EngineBase(object.Object):
def set_cursor_location(self, x, y, w, h):
pass
- def set_surrounding_text(self, text, cursor_pos):
+ def set_surrounding_text(self, text, cursor_pos, anchor_pos):
text = serializable.deserialize_object(text)
self.__surrounding_text = text
self.__surrounding_cursor_pos = cursor_pos
+ self.__selection_anchor_pos = anchor_pos
def get_surrounding_text(self):
# Tell the client that this engine will utilize surrounding-text
@@ -194,8 +196,8 @@ class EngineProxy(interface.IEngine):
def SetCursorLocation(self, x, y, w, h):
return self.__engine.set_cursor_location(x, y, w, h)
- def SetSurroundingText(self, text, cursor_pos):
- return self.__engine.set_surrounding_text(text, cursor_pos)
+ def SetSurroundingText(self, text, cursor_pos, anchor_pos):
+ return self.__engine.set_surrounding_text(text, cursor_pos, anchor_pos)
def SetCapabilities(self, caps):
return self.__engine.set_capabilities(caps)
@@ -237,4 +239,3 @@ class EngineProxy(interface.IEngine):
self.__engine.destroy()
self.__engine = None
self.remove_from_connection ()
-
diff --git a/ibus/inputcontext.py b/ibus/inputcontext.py
index ceeb56d1..64a6ba23 100644
--- a/ibus/inputcontext.py
+++ b/ibus/inputcontext.py
@@ -138,6 +138,7 @@ class InputContext(object.Object):
self.__needs_surrounding_text = False
self.__surrounding_text = Text()
self.__surrounding_cursor_pos = 0
+ self.__selection_anchor_pos = 0
if not watch_signals:
return
@@ -218,14 +219,17 @@ class InputContext(object.Object):
def needs_surrounding_text(self):
return self.__needs_surrounding_text
- def set_surrounding_text(self, text, cursor_pos):
+ def set_surrounding_text(self, text, cursor_pos, anchor_pos):
if self.__surrounding_text.get_text() != text or \
- self.__surrounding_cursor_pos != cursor_pos:
+ self.__surrounding_cursor_pos != cursor_pos or \
+ self.__selection_anchor_pos != anchor_pos:
self.__surrounding_text = Text(text)
self.__surrounding_cursor_pos = cursor_pos
+ self.__selection_anchor_pos = anchor_pos
text = serializable.serialize_object(self.__surrounding_text)
cursor_pos = dbus.UInt32(self.__surrounding_cursor_pos)
- self.__context.SetSurroundingText(text, cursor_pos)
+ anchor_pos = dbus.UInt32(self.__selection_anchor_pos)
+ self.__context.SetSurroundingText(text, cursor_pos, anchor_pos)
def process_key_event(self, keyval, keycode, modifiers):
keyval = dbus.UInt32(keyval)
@@ -365,4 +369,3 @@ def test():
if __name__ == "__main__":
test()
-
diff --git a/ibus/interface/iengine.py b/ibus/interface/iengine.py
index 9e0d9816..d04e70a2 100644
--- a/ibus/interface/iengine.py
+++ b/ibus/interface/iengine.py
@@ -50,8 +50,8 @@ class IEngine(dbus.service.Object):
@method(in_signature="iiii")
def SetCursorLocation(self, x, y, w, h): pass
- @method(in_signature="vu")
- def SetSurroundingText(self, text, cursor_index): pass
+ @method(in_signature="vuu")
+ def SetSurroundingText(self, text, cursor_index, anchor_pos): pass
@method(in_signature="u")
def SetCapabilities(self, cap): pass
diff --git a/ibus/interface/iinputcontext.py b/ibus/interface/iinputcontext.py
index 1d3cd2a6..06ce519b 100644
--- a/ibus/interface/iinputcontext.py
+++ b/ibus/interface/iinputcontext.py
@@ -49,8 +49,8 @@ class IInputContext(dbus.service.Object):
@method(in_signature="iiii")
def SetCursorLocation(self, x, y, w, h): pass
- @method(in_signature="vu")
- def SetSurroundingText(self, text, cursor_index): pass
+ @method(in_signature="vuu")
+ def SetSurroundingText(self, text, cursor_index, anchor_pos): pass
@method()
def FocusIn(self): pass
@@ -142,5 +142,3 @@ class IInputContext(dbus.service.Object):
@signal(signature="v")
def UpdateProperty(self, prop): pass
-
-