Merge lp:~ken-vandine/libgrip/python_gi_override into lp:~bratsche/libgrip/python-fixage-wip

Proposed by Ken VanDine
Status: Merged
Merged at revision: 24
Proposed branch: lp:~ken-vandine/libgrip/python_gi_override
Merge into: lp:~bratsche/libgrip/python-fixage-wip
Diff against target: 165 lines (+73/-6)
7 files modified
Makefile.am (+1/-1)
bindings/Makefile.am (+1/-0)
bindings/python/Grip.py (+52/-0)
bindings/python/Makefile.am (+9/-0)
configure.ac (+4/-0)
examples/pygrip/pygrip.py (+3/-4)
src/Makefile.am (+3/-1)
To merge this branch: bzr merge lp:~ken-vandine/libgrip/python_gi_override
Reviewer Review Type Date Requested Status
Cody Russell Approve
Review via email: mp+47294@code.launchpad.net

Description of the change

* Added python overrides for gi
* Fixed pygrip example

To post a comment you must log in.
Revision history for this message
Cody Russell (bratsche) wrote :

Awesome, thanks for the fix!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2010-11-22 14:49:44 +0000
3+++ Makefile.am 2011-01-24 19:13:59 +0000
4@@ -4,7 +4,7 @@
5 Q = $(V:1=)
6 QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
7
8-SUBDIRS = build src examples/rectangle-mover
9+SUBDIRS = build src bindings examples/rectangle-mover
10
11 libgrip-0.1.pc: libgrip.pc
12 $(QUIET_GEN) cp -f libgrip.pc libgrip-0.1.pc
13
14=== added directory 'bindings'
15=== added file 'bindings/Makefile.am'
16--- bindings/Makefile.am 1970-01-01 00:00:00 +0000
17+++ bindings/Makefile.am 2011-01-24 19:13:59 +0000
18@@ -0,0 +1,1 @@
19+SUBDIRS = python
20
21=== added directory 'bindings/python'
22=== added file 'bindings/python/Grip.py'
23--- bindings/python/Grip.py 1970-01-01 00:00:00 +0000
24+++ bindings/python/Grip.py 2011-01-24 19:13:59 +0000
25@@ -0,0 +1,52 @@
26+#
27+# Copyright 2010 Canonical, Ltd.
28+#
29+# This program is free software: you can redistribute it and/or modify it
30+# under the terms of either or both of the following licenses:
31+#
32+# 1) the GNU Lesser General Public License version 3, as published by the
33+# Free Software Foundation; and/or
34+# 2) the GNU Lesser General Public License version 2.1, as published by
35+# the Free Software Foundation.
36+#
37+# This program is distributed in the hope that it will be useful, but
38+# WITHOUT ANY WARRANTY; without even the implied warranties of
39+# MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
40+# PURPOSE. See the applicable version of the GNU Lesser General Public
41+# License for more details.
42+#
43+# You should have received a copy of both the GNU Lesser General Public
44+# License version 3 and version 2.1 along with this program. If not, see
45+# <http://www.gnu.org/licenses/>
46+#
47+# Authors:
48+# Cody Russell <crussell@canonical.com>
49+#
50+
51+from ..overrides import override
52+from ..importer import modules
53+
54+Grip = modules['Grip'].introspection_module
55+
56+__all__ = []
57+
58+class GestureEvent(Grip.GestureEvent):
59+ _UNION_MEMBERS = {
60+ Grip.GestureType.DRAG: 'drag',
61+ Grip.GestureType.PINCH: 'pinch',
62+ Grip.GestureType.ROTATE: 'rotate',
63+ Grip.GestureType.TAP: 'tap'
64+ }
65+
66+ def __new__(cls, *args, **kwargs):
67+ return Grip.GestureEvent.__new__(cls)
68+
69+ def __getattr__(self, name):
70+ real_event = getattr(self, '_UNION_MEMBERS').get(self.type)
71+ if real_event:
72+ return getattr(getattr(self, real_event), name)
73+ else:
74+ return getattr(self, name)
75+
76+GestureEvent = override(GestureEvent)
77+__all__.append('GestureEvent')
78
79=== added file 'bindings/python/Makefile.am'
80--- bindings/python/Makefile.am 1970-01-01 00:00:00 +0000
81+++ bindings/python/Makefile.am 2011-01-24 19:13:59 +0000
82@@ -0,0 +1,9 @@
83+PLATFORM_VERSION = 2.0
84+
85+pkgpyexecdir = $(pyexecdir)/gi
86+
87+pygioverridesdir = $(pkgpyexecdir)/overrides
88+pygioverrides_PYTHON = \
89+ Grip.py
90+
91+EXTRA_DIST = Grip.py
92
93=== modified file 'configure.ac'
94--- configure.ac 2011-01-03 19:12:52 +0000
95+++ configure.ac 2011-01-24 19:13:59 +0000
96@@ -27,6 +27,8 @@
97 AM_INIT_AUTOMAKE([1.9])
98 AM_MAINTAINER_MODE
99
100+AM_PATH_PYTHON
101+
102 GRIP_MAJOR_VERSION=grip_major_version
103 GRIP_MINOR_VERSION=grip_minor_version
104 GRIP_MICRO_VERSION=grip_micro_version
105@@ -119,6 +121,8 @@
106 build/autotools/shave-libtool
107 build/autotools/shave
108 src/Makefile
109+ bindings/python/Makefile
110+ bindings/Makefile
111 examples/rectangle-mover/Makefile
112 libgrip.pc
113 ])
114
115=== modified file 'examples/pygrip/pygrip.py' (properties changed: -x to +x)
116--- examples/pygrip/pygrip.py 2011-01-21 17:19:26 +0000
117+++ examples/pygrip/pygrip.py 2011-01-24 19:13:59 +0000
118@@ -1,3 +1,4 @@
119+#!/usr/bin/python
120 from gi.repository import Gtk
121 Gtk.require_version('2.0')
122 from gi.repository import Grip
123@@ -16,20 +17,18 @@
124 builder.add_from_file("pygrip-gestures.xml")
125 builder.connect_signals(self)
126 self.window = builder.get_object("window1")
127+ self.gesture_manager = Grip.GestureManager()
128 self.window.show()
129
130 def window_mapped(self, widget, data=None):
131 # The gesture manager is only going to be needed for GTK2, since GTK3
132 # will have the gesture API natively. Conversely, pygrip will only be
133 # for GTK2, since PyGTK3 will having the bindings.
134- gesture_manager = Grip.GestureManager()
135
136 finger_count = 2
137-# import epdb; epdb.st();
138- gesture_manager.register_window(self.window, Grip.GestureType.PINCH, finger_count, self.callback, None)
139+ self.gesture_manager.register_window(widget, Grip.GestureType.PINCH, finger_count, self.callback, None)
140
141 def callback(self, window, time_type, gesture_event, data):
142-# import epdb; epdb.st();
143 print "received gesture"
144
145 def quit(self, widget, data=None):
146
147=== modified file 'src/Makefile.am'
148--- src/Makefile.am 2010-11-22 14:49:44 +0000
149+++ src/Makefile.am 2011-01-24 19:13:59 +0000
150@@ -38,6 +38,7 @@
151 $(INTROSPECTION_SCANNER) \
152 -v --namespace Grip \
153 --nsversion=0.1 \
154+ --warn-all \
155 --add-include-path=$(srcdir) $(GTK_CFLAGS) \
156 --include=GObject-2.0 \
157 --include=GLib-2.0 \
158@@ -104,4 +105,5 @@
159 DISTCLEANFILES = \
160 stamp-griptypebuiltins.h \
161 griptypebuiltins.h \
162- griptypebuiltins.c
163\ No newline at end of file
164+ griptypebuiltins.c
165+

Subscribers

People subscribed via source and target branches

to all changes: