[caribou/keyboard_position: 4/19] some bigger changes
- From: Eitan Isaacson <eitani src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [caribou/keyboard_position: 4/19] some bigger changes
- Date: Wed, 2 Dec 2009 21:48:45 +0000 (UTC)
commit 0d88cdf8b3c0ce0d2f711cd0a11255dc16eb7ef4
Author: Eitan Isaacson <eitan monotonous org>
Date: Mon Nov 30 16:37:36 2009 -0800
some bigger changes
src/caribou.py | 8 +++---
src/keyboard.py | 77 ++++++++++++++++++++++++++++++++-----------------------
2 files changed, 49 insertions(+), 36 deletions(-)
---
diff --git a/src/caribou.py b/src/caribou.py
index e03018f..6ee1944 100644
--- a/src/caribou.py
+++ b/src/caribou.py
@@ -41,7 +41,7 @@ class Test:
def __set_text_location(self, acc):
text = acc.queryText()
[x, y, width, height] = text.getCharacterExtents(text.caretOffset, pyatspi.DESKTOP_COORDS)
- cp.set_cursor_location(x, y, width, height)
+ cp.cursor_location = gtk.gdk.Rectangle(x, y, width, height)
cp.show_all()
def __set_entry_location(self, acc):
@@ -50,9 +50,9 @@ class Test:
if x == 0 and y == 0 and width == 0 and height == 0:
component = acc.queryComponent()
bb = component.getExtents(pyatspi.DESKTOP_COORDS)
- cp.set_cursor_location(bb.x, bb.y, bb.width, bb.height)
+ cp.cursor_location = gtk.gdk.Rectangle(bb.x, bb.y, bb.width, bb.height)
else:
- cp.set_cursor_location(x, y, width, height)
+ cp.cursor_location = gtk.gdk.Rectangle(x, y, width, height)
cp.show_all()
def on_state_changed_focused(self, event):
@@ -160,7 +160,7 @@ if __name__ == "__main__":
pyatspi.Registry.registerKeystrokeListener(test.on_key_down, mask = None, kind = (pyatspi.KEY_PRESSED_EVENT,))
# TODO: move text entry detection to its own file
- cp = keyboard.CaribouWindow()
+ cp = keyboard.CaribouHoverWindow()
cp.hide_all()
gtk.main()
diff --git a/src/keyboard.py b/src/keyboard.py
index c9455ee..d7d290f 100644
--- a/src/keyboard.py
+++ b/src/keyboard.py
@@ -1,4 +1,4 @@
-# -*- coding: UTF-8 -*-
+# -*- coding: utf-8 -*-
#
# Carbou - On-screen Keyboard and UI navigation application
#
@@ -100,62 +100,75 @@ class CaribouKeyboard(gtk.Frame):
gobject.type_register(CaribouKeyboard)
-class CaribouWindow(gtk.VBox):
+class CaribouWindow(gtk.Window):
__gtype_name__ = "CaribouWindow"
def __init__(self):
- super(CaribouWindow, self).__init__()
+ super(CaribouWindow, self).__init__(gtk.WINDOW_POPUP)
self.set_name("CaribouWindow")
- self.__toplevel = gtk.Window(gtk.WINDOW_POPUP)
- self.__toplevel.add(self)
- self.__toplevel.connect("size-allocate", lambda w, a: self.__check_position())
- self.__cursor_location = (0, 0)
- self.pack_start(CaribouKeyboard(qwerty))
+ self._vbox = gtk.VBox()
+ self.add(self._vbox)
- #print "----> SET CURSOR LOCATION"
- def set_cursor_location(self, x, y, width, height):
- self.__cursor_location = (x, y, width, height)
- self.__check_position()
+ self.connect("size-allocate", lambda w, a: self._update_position())
- def do_size_request(self, requisition):
- #print "---->> DO SIZE REQUEST"
- gtk.VBox.do_size_request(self, requisition)
- self.__toplevel.resize(1, 1)
+ self._vbox.pack_start(CaribouKeyboard(qwerty))
- def __check_position(self):
+class CaribouHoverWindow(CaribouWindow):
+ __gtype_name__ = "CaribouHoverWindow"
+ def __init__(self):
+ super(CaribouHoverWindow, self).__init__()
+ self._cursor_location = gtk.gdk.Rectangle()
+
+ def _set_cursor_location(self, val):
+ self._cursor_location = val
+ self._update_position()
+
+ def _get_cursor_location(self):
+ return self._cursor_location
+
+ cursor_location = gobject.property(type=object,
+ setter=_set_cursor_location,
+ getter=_get_cursor_location)
+
+ def _update_position(self):
#print "---->>> CHECK POSITION"
- bx = self.__cursor_location[0] + self.__toplevel.allocation.width
- by = self.__cursor_location[1] + self.__toplevel.allocation.height
+ bx = self.cursor_location.x + self.allocation.width
+ by = self.cursor_location.y + self.allocation.height
root_window = gdk.get_default_root_window()
sx, sy = root_window.get_size()
if bx > sx:
- x = sx - self.__toplevel.allocation.width
+ x = sx - self.allocation.width
else:
- x = self.__cursor_location[0]
+ x = self.cursor_location.x
if by > sy:
- y = self.__cursor_location[1] - self.__toplevel.allocation.height
+ y = self.cursor_location.y - self.allocation.height
else:
- y = self.__cursor_location[1] + self.__cursor_location[3]
+ y = self.cursor_location.y + self.cursor_location.height
self.move(x, y)
- def show_all(self):
- gtk.VBox.show_all(self)
- self.__toplevel.show_all()
+class CaribouKeyboardPlacement:
+ LEFT = 0
+ RIGHT = 1
+ TOP = 0
+ BOTTOM = 1
+ CENTER = 2
+
+ SCREEN = 0
+ ENTRY = 1
+ CURSOR = 2
- def hide_all(self):
- gtk.VBox.hide_all(self)
- self.__toplevel.hide_all()
+ INSIDE = 0
+ OUTSIDE = 1
- def move(self, x, y):
- self.__toplevel.move(x, y)
+
if __name__ == "__main__":
- ckbd = CaribouWindow()
+ ckbd = CaribouHoverWindow()
ckbd.show_all()
gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]