[caribou] New animation for docked keyboard
- From: Eitan Isaacson <eitani src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [caribou] New animation for docked keyboard
- Date: Tue, 8 Dec 2009 07:14:40 +0000 (UTC)
commit 558ada16a292cb1569f012e017d2abe655767ad6
Author: Eitan Isaacson <eitan monotonous org>
Date: Mon Dec 7 22:45:24 2009 -0800
New animation for docked keyboard
src/caribou/animation.py | 35 ++++++++++++++++++++++++++
src/caribou/window.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/src/caribou/animation.py b/src/caribou/animation.py
new file mode 100644
index 0000000..a5b7278
--- /dev/null
+++ b/src/caribou/animation.py
@@ -0,0 +1,35 @@
+import clutter, gtk
+
+class AnimatedWindowBase(object):
+ def __init__(self, ease=clutter.EASE_IN_QUAD):
+ self._actor = clutter.Rectangle()
+ self.ease = ease
+
+ def _on_new_frame(self, timeline, timing):
+ x, y = self._actor.get_position()
+ self.move(int(x), int(y))
+
+ def animated_move(self, x, y):
+ orig_x, orig_y = self.get_position()
+ self._actor.set_position(orig_x, orig_y)
+ self._actor.set_size(self.allocation.width, self.allocation.height)
+ animation = self._actor.animate(
+ self.ease, 250, "x", x, "y", y)
+ timeline = animation.get_timeline()
+ timeline.connect('new-frame', self._on_new_frame)
+
+ return animation
+
+if __name__ == "__main__":
+ class AnimatedWindow(gtk.Window, AnimatedWindowBase):
+ def __init__(self):
+ gtk.Window.__init__(self)
+ AnimatedWindowBase.__init__(self)
+
+ aw = AnimatedWindow()
+ aw.show_all()
+ aw.move(100, 100)
+ aw.animated_move(200, 200)
+ gtk.main()
+
+
diff --git a/src/caribou/window.py b/src/caribou/window.py
index 20caad3..35a5650 100644
--- a/src/caribou/window.py
+++ b/src/caribou/window.py
@@ -24,6 +24,8 @@ import glib
from math import sqrt
import keyboard
from keyboards import qwerty
+import gconf
+import animation
class CaribouWindow(gtk.Window):
__gtype_name__ = "CaribouWindow"
@@ -171,6 +173,66 @@ class CaribouWindow(gtk.Window):
y2 = bbox.y if y_distance > 0 else bbox.y + bbox.height
return sqrt((x - x2)**2 + (y - y2)**2)
+class CaribouWindowDocked(CaribouWindow, animation.AnimatedWindowBase):
+ __gtype_name__ = "CaribouWindowDocked"
+
+ def __init__(self):
+ placement = CaribouWindowPlacement(
+ xalign=CaribouWindowPlacement.END,
+ yalign=CaribouWindowPlacement.START,
+ xstickto=CaribouWindowPlacement.SCREEN,
+ ystickto=CaribouWindowPlacement.SCREEN,
+ xgravitate=CaribouWindowPlacement.INSIDE)
+
+ CaribouWindow.__init__(
+ self, placement, min_alpha=0.8, max_alpha=0.8)
+
+ animation.AnimatedWindowBase.__init__(self)
+ self._gconf_client = gconf.client_get_default()
+
+ def _get_root_bbox(self):
+ root_bbox = CaribouWindow._get_root_bbox(self)
+ current_screen = gtk.gdk.screen_get_default().get_number()
+ for panel in self._gconf_client.all_dirs('/apps/panel/toplevels'):
+ orientation = self._gconf_client.get_string(panel+'/orientation')
+ size = self._gconf_client.get_int(panel+'/size')
+ screen = self._gconf_client.get_int(panel+'/screen')
+ if screen != current_screen:
+ continue
+ if orientation == 'top':
+ root_bbox.y += size
+ root_bbox.height -= size
+ elif orientation == 'bottom':
+ root_bbox.height -= size
+ elif orientation == 'right':
+ root_bbox.x += size
+ root_bbox.width -= size
+ elif orientation == 'left':
+ root_bbox.x -= size
+
+ return root_bbox
+
+ def _onmapped(self, obj, event):
+ CaribouWindow._onmapped(self, obj, event)
+ self._roll_in()
+
+ def _roll_in(self):
+ x, y = self.get_position()
+ self.move(x + self.allocation.width, y)
+ return self.animated_move(x, y)
+
+ def _roll_out(self):
+ x, y = self.get_position()
+ return self.animated_move(x + self.allocation.width, y)
+
+ def hide_all(self):
+ animation = self._roll_out()
+ animation.connect('completed', lambda x: CaribouWindow.hide_all(self))
+
+ def hide(self):
+ animation = self._roll_out()
+ animation.connect('completed', lambda x: CaribouWindow.hide(self))
+
class CaribouWindowEntry(CaribouWindow):
__gtype_name__ = "CaribouWindowEntry"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]