Ticket #3981: global_gesture.py

File global_gesture.py, 759 bytes (added by erikos, 12 years ago)

python test program

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