1 | from gi.repository import Gtk |
---|
2 | from gi.repository import Gdk |
---|
3 | from gi.repository import SugarGestures |
---|
4 | from gi.repository import SugarExt |
---|
5 | |
---|
6 | def _destroy_cb(widget, data=None): |
---|
7 | Gtk.main_quit() |
---|
8 | |
---|
9 | def _swipe_ended_cb(controller, direction): |
---|
10 | print '===> Swept in direction: ', direction |
---|
11 | |
---|
12 | RECT_WIDTH = 400 |
---|
13 | RECT_HEIGHT = 400 |
---|
14 | |
---|
15 | grabber = SugarExt.GestureGrabber() |
---|
16 | screen = Gdk.Screen.get_default() |
---|
17 | |
---|
18 | rect = Gdk.Rectangle() |
---|
19 | rect.x = (Gdk.Screen.width() - RECT_WIDTH) / 2 |
---|
20 | rect.y = 0 |
---|
21 | rect.width = RECT_WIDTH |
---|
22 | rect.height = RECT_HEIGHT |
---|
23 | |
---|
24 | swipe = SugarGestures.SwipeController() |
---|
25 | swipe.connect('swipe-ended', _swipe_ended_cb) |
---|
26 | grabber.add(swipe, rect) |
---|
27 | |
---|
28 | window = Gtk.Window() |
---|
29 | window.set_default_size(800, 640) |
---|
30 | window.connect("destroy", _destroy_cb) |
---|
31 | |
---|
32 | window.show() |
---|
33 | Gtk.main() |
---|