diff options
author | Eitan Isaacson <eitan@monotonous.org> | 2011-06-15 16:20:03 -0700 |
---|---|---|
committer | Eitan Isaacson <eitan@monotonous.org> | 2011-06-22 11:23:21 -0700 |
commit | dffb9374b4cae0266c0e3c1a4e1a03e7a77383b0 (patch) | |
tree | d547d34bf7b3d6c70a9516e1247f5ac96f126940 /caribou/antler/window.py | |
parent | 20ee8c51feee3cbdd4ce39576035db60a8ecdf0f (diff) | |
download | caribou-dffb9374b4cae0266c0e3c1a4e1a03e7a77383b0.tar.gz |
Antler: Have keyboard resize correctly when type changes.
Diffstat (limited to 'caribou/antler/window.py')
-rw-r--r-- | caribou/antler/window.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/caribou/antler/window.py b/caribou/antler/window.py index e24330d..a72203e 100644 --- a/caribou/antler/window.py +++ b/caribou/antler/window.py @@ -195,7 +195,7 @@ class ProximityWindowBase(AnimatedWindowBase): return sqrt((px - x2)**2 + (py - y2)**2) class AntlerWindow(ProximityWindowBase): - def __init__(self, text_entry_mech, placement=None, + def __init__(self, keyboard_view_factory, placement=None, min_alpha=1.0, max_alpha=1.0, max_distance=100): ProximityWindowBase.__init__(self) @@ -204,10 +204,16 @@ class AntlerWindow(ProximityWindowBase): ctx = self.get_style_context() ctx.add_class("antler-keyboard-window") + settings = AntlerSettings() + settings.keyboard_type.connect('value-changed', self.on_kb_type_changed) + self._vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self._vbox) - self.keyboard = text_entry_mech - self._vbox.pack_start(text_entry_mech, True, True, 0) + + self.keyboard_view_factory = keyboard_view_factory + self.keyboard_view = keyboard_view_factory (settings.keyboard_type.value) + + self._vbox.pack_start(self.keyboard_view, True, True, 0) self.connect("size-allocate", self.on_size_allocate) @@ -216,6 +222,13 @@ class AntlerWindow(ProximityWindowBase): self.placement = placement or \ AntlerWindowPlacement() + def on_kb_type_changed(self, setting, value): + self._vbox.remove(self.keyboard_view) + self.resize(1, 1) + self.keyboard_view = self.keyboard_view_factory (value) + self._vbox.pack_start(self.keyboard_view, True, True, 0) + self.keyboard_view.show_all() + def on_size_allocate(self, widget, allocation): self._update_position() @@ -299,7 +312,7 @@ class AntlerWindow(ProximityWindowBase): return offset class AntlerWindowDocked(AntlerWindow): - def __init__(self, text_entry_mech, horizontal_roll=False): + def __init__(self, keyboard_view_factory, horizontal_roll=False): placement = AntlerWindowPlacement( xalign=AntlerWindowPlacement.START, yalign=AntlerWindowPlacement.END, @@ -307,7 +320,7 @@ class AntlerWindowDocked(AntlerWindow): ystickto=AntlerWindowPlacement.SCREEN, xgravitate=AntlerWindowPlacement.INSIDE) - AntlerWindow.__init__(self, text_entry_mech, placement) + AntlerWindow.__init__(self, keyboard_view_factory, placement) self.horizontal_roll = horizontal_roll self._rolled_in = False @@ -378,7 +391,7 @@ class AntlerWindowDocked(AntlerWindow): animation.connect('completed', lambda x: AntlerWindow.hide(self)) class AntlerWindowEntry(AntlerWindow): - def __init__(self, text_entry_mech): + def __init__(self, keyboard_view_factory): placement = AntlerWindowPlacement( xalign=AntlerWindowPlacement.START, xstickto=AntlerWindowPlacement.ENTRY, @@ -386,7 +399,7 @@ class AntlerWindowEntry(AntlerWindow): xgravitate=AntlerWindowPlacement.INSIDE, ygravitate=AntlerWindowPlacement.OUTSIDE) - AntlerWindow.__init__(self, text_entry_mech, placement) + AntlerWindow.__init__(self, keyboard_view_factory, placement) def _calculate_axis(self, axis_placement, root_bbox): @@ -471,7 +484,7 @@ if __name__ == "__main__": import signal signal.signal(signal.SIGINT, signal.SIG_DFL) - w = AntlerWindowDocked(keyboard_view.AntlerKeyboardView()) + w = AntlerWindowDocked(keyboard_view.AntlerKeyboardView) w.show_all() try: |