[caribou] Allow the window class to host other text entry widgets



commit f4c7aabaa458e5de53c174af3bacc3786e6ac834
Author: Ben Konrath <ben bagu org>
Date:   Wed Mar 24 10:37:12 2010 -0700

    Allow the window class to host other text entry widgets

 src/caribou.py        |   15 ++++++++-------
 src/caribou/window.py |   17 +++++++----------
 2 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/src/caribou.py b/src/caribou.py
index 41cb621..04ff034 100755
--- a/src/caribou.py
+++ b/src/caribou.py
@@ -22,14 +22,16 @@
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-import pyatspi
+import getopt
+import gettext
 import gtk
 import gtk.gdk as gdk
-import caribou.window as window
-import gettext
-import getopt
+import pyatspi
 import sys
 
+import caribou.window as window
+import caribou.keyboard as keyboard
+
 _ = gettext.gettext
 
 debug = False
@@ -188,9 +190,8 @@ if __name__ == "__main__":
     pyatspi.Registry.registerEventListener(caribou.on_text_caret_moved, "object:text-caret-moved")
     pyatspi.Registry.registerKeystrokeListener(caribou.on_key_down, mask=None, kind=(pyatspi.KEY_PRESSED_EVENT,))
 
-    # TODO: move text entry detection to its own file
-
-    caribouwindow = window.CaribouWindowEntry()
+    osk = keyboard.CaribouKeyboard()
+    caribouwindow = window.CaribouWindowEntry(osk)
     caribouwindow.hide_all()
  
     gtk.main()
diff --git a/src/caribou/window.py b/src/caribou/window.py
index f6cd5e7..bed83c4 100644
--- a/src/caribou/window.py
+++ b/src/caribou/window.py
@@ -22,22 +22,19 @@ import animation
 import gconf
 import gtk
 import gtk.gdk as gdk
-import keyboard
 import opacity
 
 class CaribouWindow(gtk.Window):
     __gtype_name__ = "CaribouWindow"
 
-    def __init__(self, default_placement=None, 
+    def __init__(self, text_entry_mech, default_placement=None,
                  min_alpha=1.0, max_alpha=1.0, max_distance=100):
         super(CaribouWindow, self).__init__(gtk.WINDOW_POPUP)
         self.set_name("CaribouWindow")
 
         self._vbox = gtk.VBox()
         self.add(self._vbox)
-
-        # we only have a keyboard widget right now
-        self._vbox.pack_start(keyboard.CaribouKeyboard())
+        self._vbox.pack_start(text_entry_mech)
 
         self.connect("size-allocate", lambda w, a: self._update_position())
         self._gconf_client = gconf.client_get_default()
@@ -132,7 +129,7 @@ class CaribouWindowDocked(CaribouWindow,
                           opacity.ProximityWindowBase):
     __gtype_name__ = "CaribouWindowDocked"
     
-    def __init__(self):
+    def __init__(self, text_entry_mech):
         placement = CaribouWindowPlacement(
             xalign=CaribouWindowPlacement.END,
             yalign=CaribouWindowPlacement.START,
@@ -140,7 +137,7 @@ class CaribouWindowDocked(CaribouWindow,
             ystickto=CaribouWindowPlacement.SCREEN,
             xgravitate=CaribouWindowPlacement.INSIDE)
 
-        CaribouWindow.__init__(self, placement)
+        CaribouWindow.__init__(self, text_entry_mech, placement)
         animation.AnimatedWindowBase.__init__(self)
         opacity.ProximityWindowBase.__init__(
             self, min_alpha=0.5, max_alpha=0.8)
@@ -170,7 +167,7 @@ class CaribouWindowDocked(CaribouWindow,
 class CaribouWindowEntry(CaribouWindow):
     __gtype_name__ = "CaribouWindowEntry"
 
-    def __init__(self):
+    def __init__(self, text_entry_mech):
         placement = CaribouWindowPlacement(
             xalign=CaribouWindowPlacement.START,
             xstickto=CaribouWindowPlacement.ENTRY,
@@ -178,8 +175,8 @@ class CaribouWindowEntry(CaribouWindow):
             xgravitate=CaribouWindowPlacement.INSIDE,
             ygravitate=CaribouWindowPlacement.OUTSIDE)
 
-        CaribouWindow.__init__(
-            self, placement, min_alpha=0.075, max_alpha=0.8)
+        CaribouWindow.__init__(self, text_entry_mech, placement, min_alpha=0.075,
+                               max_alpha=0.8)
 
     def _calculate_axis(self, axis_placement, root_bbox):
         offset = CaribouWindow._calculate_axis(self, axis_placement, root_bbox)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]