~bratsche/libgrip/python-fixage-wip

7.1.8 by bratsche
Changes from Cody Russell include the following:
1
from gi.repository import Gtk
20 by Cody Russell
Fix gtk importing.
2
Gtk.require_version('2.0')
10.1.1 by Cody Russell
Rename to libgrip
3
from gi.repository import Grip
4
5
6
# XXX For now, we'll use Grip directly. Once we have a good sense of what's
7
# going to be needed in general for general Python code using Grip, we might
8
# want to put that stuff in a wrapper grip module, and import everything from
7.1.7 by Duncan McGreggor
* Fixed up import statements.
9
# there instead.
1.2.2 by Duncan McGreggor
Added basic pygtk python app for loading the glade file.
10
11
12
class GestureTester(object):
13
14
    def __init__(self):
7.1.8 by bratsche
Changes from Cody Russell include the following:
15
        builder = Gtk.Builder()
10.1.1 by Cody Russell
Rename to libgrip
16
        builder.add_from_file("pygrip-gestures.xml")
1.2.2 by Duncan McGreggor
Added basic pygtk python app for loading the glade file.
17
        builder.connect_signals(self)
18
        self.window = builder.get_object("window1")
19
        self.window.show()
20
1.2.5 by Duncan McGreggor
Added an implementation for non-existent Python bindings.
21
    def window_mapped(self, widget, data=None):
7.1.7 by Duncan McGreggor
* Fixed up import statements.
22
        # The gesture manager is only going to be needed for GTK2, since GTK3
10.1.1 by Cody Russell
Rename to libgrip
23
        # will have the gesture API natively. Conversely, pygrip will only be
7.1.7 by Duncan McGreggor
* Fixed up import statements.
24
        # for GTK2, since PyGTK3 will having the bindings.
10.1.1 by Cody Russell
Rename to libgrip
25
        gesture_manager = Grip.GestureManager()
1.2.5 by Duncan McGreggor
Added an implementation for non-existent Python bindings.
26
        # For the purpose of this example, we are registering all gestures; we
10.1.1 by Cody Russell
Rename to libgrip
27
        # could limit this by choosing a different pygrip.GRIP_GESTURE_*
1.2.5 by Duncan McGreggor
Added an implementation for non-existent Python bindings.
28
        # mask. Similarly, we're using one set of callbacks for all the
29
        # gestures; we could have different callbacks for different registered
30
        # gestures.
7.1.7 by Duncan McGreggor
* Fixed up import statements.
31
        # XXX the comment above is for the new API; the example below has been
32
        # reverted to the older API until the new one is merged to trunk.
33
        finger_count = 2
7.1.9 by Duncan McGreggor
Formatting cleanups.
34
        gesture_manager.register_window(
21 by Cody Russell
Fix register_window() parameters.
35
            self.window, Grip.GestureType.PINCH, finger_count, self.callback, None)
7.1.8 by bratsche
Changes from Cody Russell include the following:
36
37
    def callback(self, window, time_type, gesture_type, gesture_event):
38
        print "received gesture"
1.2.3 by Duncan McGreggor
Added initial comments from Cody about how to use a python API for grope.
39
1.2.2 by Duncan McGreggor
Added basic pygtk python app for loading the glade file.
40
    def quit(self, widget, data=None):
7.1.8 by bratsche
Changes from Cody Russell include the following:
41
        Gtk.main_quit()
1.2.2 by Duncan McGreggor
Added basic pygtk python app for loading the glade file.
42
43
44
if __name__ == "__main__":
45
    app = GestureTester()
7.1.8 by bratsche
Changes from Cody Russell include the following:
46
    Gtk.main()