libgrip: multitouch gesture library for GTK

Merge lp:~ken-vandine/libgrip/packaging-with-gir-and-python into lp:~oif-team/libgrip/packaging

Proposed by Ken VanDine on 2011-01-24
Status: Merged
Merged at revision: 26
Proposed branch: lp:~ken-vandine/libgrip/packaging-with-gir-and-python
Merge into: lp:~oif-team/libgrip/packaging
Diff against target: 977 lines (+401/-166) 18 files modified
To merge this branch: bzr merge lp:~ken-vandine/libgrip/packaging-with-gir-and-python
Reviewer Review Type Date Requested Status
Cody Russell (community) 2011-01-24 Approve on 2011-02-04
Review via email: mp+47309@code.launchpad.net
To post a comment you must log in.
Cody Russell (bratsche) :
review: Approve

Preview Diff

1=== modified file 'Makefile.am'
2--- Makefile.am 2010-11-22 14:49:44 +0000
3+++ Makefile.am 2011-01-24 20:08:35 +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 20:08:35 +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 20:08:35 +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 20:08:35 +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 20:08:35 +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 'debian/changelog'
116--- debian/changelog 2011-01-03 19:18:45 +0000
117+++ debian/changelog 2011-01-24 20:08:35 +0000
118@@ -1,3 +1,21 @@
119+libgrip (0.1.1-0ubuntu2) UNRELEASED; urgency=low
120+
121+ * Merged lp:~bratsche/libgrip/python-fixage-wip branch
122+ * debian/{control,gir1.2-grip-0.1.install,libgrip-0.1-dev.install}
123+ - Install the gir and typelib
124+ - Added build depends for packages needed to build the GIR
125+ - Added build depends for dh-autoreconf
126+ * debian/{control,python-grip.install}
127+ - Added new package for the python bindings (just a gi.overrides)
128+ * debian/rules
129+ - added dh_girepository for gir:Depends
130+ - include autoreconf.mk
131+ * +debian/source/format
132+ * debian/libgrip-0.1-0.symbols
133+ - Added new symbols
134+
135+ -- Ken VanDine <ken.vandine@canonical.com> Mon, 24 Jan 2011 14:32:30 -0500
136+
137 libgrip (0.1.1-0ubuntu1) natty; urgency=low
138
139 * Bump version and release for Natty.
140
141=== modified file 'debian/control'
142--- debian/control 2010-11-29 22:07:57 +0000
143+++ debian/control 2011-01-24 20:08:35 +0000
144@@ -1,14 +1,23 @@
145 Source: libgrip
146 Section: libs
147 Priority: optional
148+XS-Python-Version: all
149 Maintainer: Cody Russell <cody.russell@ubuntu.com>
150 Build-Depends: debhelper (>= 5.0),
151 cdbs (>= 0.4.41),
152 libglib2.0-dev (>=2.14.0),
153 libgtk2.0-dev (>= 2.21.5-1ubuntu3),
154 gtk-doc-tools,
155- libutouch-geis-dev
156-Standards-Version: 3.8.4
157+ libutouch-geis-dev,
158+ gobject-introspection,
159+ libgirepository1.0-dev,
160+ gir1.2-glib-2.0,
161+ gir1.2-gtk-2.0,
162+ gir1.2-pango-1.0,
163+ gir1.2-gdkpixbuf-2.0,
164+ gir1.2-freedesktop,
165+ dh-autoreconf
166+Standards-Version: 3.9.1
167 Homepage: https://launchpad.net/libgrip
168
169 Package: libgrip-0.1-0
170@@ -32,3 +41,23 @@
171 Description: Shared library providing multitouch gestures to gtk apps.
172 .
173 This package contains files that are needed to build applications.
174+
175+Package: gir1.2-grip-0.1
176+Section: libs
177+Architecture: any
178+Depends: ${misc:Depends},
179+ ${gir:Depends}
180+Description: typelib file for libgrip
181+ .
182+ This package can be used by other packages using the GIRepository format to
183+ generate dynamic bindings for libgrip
184+
185+Package: python-grip
186+Section: python
187+Architecture: all
188+Depends: ${misc:Depends},
189+ ${python:Depends}
190+Description: python bindings for libgrip
191+ .
192+ This package provides Python bindings so that you can use libgrip from
193+ a Python program.
194
195=== added file 'debian/gir1.2-grip-0.1.install'
196--- debian/gir1.2-grip-0.1.install 1970-01-01 00:00:00 +0000
197+++ debian/gir1.2-grip-0.1.install 2011-01-24 20:08:35 +0000
198@@ -0,0 +1,1 @@
199+debian/tmp/usr/lib/girepository-1.0/Grip-0.1.typelib
200
201=== modified file 'debian/libgrip-0.1-0.symbols'
202--- debian/libgrip-0.1-0.symbols 2010-11-24 17:06:51 +0000
203+++ debian/libgrip-0.1-0.symbols 2011-01-24 20:08:35 +0000
204@@ -1,4 +1,8 @@
205 libgrip-0.1.so.0 libgrip-0.1-0 #MINVER#
206+ grip_gesture_event_copy@Base 0.1.1
207+ grip_gesture_event_free@Base 0.1.1
208+ grip_gesture_event_get_type@Base 0.1.1
209+ grip_gesture_event_new@Base 0.1.1
210 grip_gesture_manager_get@Base 0.1.0
211 grip_gesture_manager_get_type@Base 0.1.0
212 grip_gesture_manager_register_window@Base 0.1.0
213
214=== modified file 'debian/libgrip-0.1-dev.install'
215--- debian/libgrip-0.1-dev.install 2010-11-24 17:06:51 +0000
216+++ debian/libgrip-0.1-dev.install 2011-01-24 20:08:35 +0000
217@@ -1,3 +1,4 @@
218 debian/tmp/usr/include/
219 debian/tmp/usr/lib/pkgconfig
220 debian/tmp/usr/lib/*.so
221+debian/tmp/usr/share/gir-1.0/Grip-0.1.gir
222
223=== added file 'debian/python-grip.install'
224--- debian/python-grip.install 1970-01-01 00:00:00 +0000
225+++ debian/python-grip.install 2011-01-24 20:08:35 +0000
226@@ -0,0 +1,1 @@
227+debian/tmp/usr/*/*python*
228
229=== modified file 'debian/rules'
230--- debian/rules 2010-11-24 17:06:51 +0000
231+++ debian/rules 2011-01-24 20:08:35 +0000
232@@ -2,8 +2,10 @@
233
234 include /usr/share/cdbs/1/rules/debhelper.mk
235 include /usr/share/cdbs/1/class/autotools.mk
236-include /usr/share/cdbs/1/rules/simple-patchsys.mk
237 include /usr/share/cdbs/1/rules/utils.mk
238+include /usr/share/cdbs/1/rules/autoreconf.mk
239+
240+DEB_PYTHON_SYSTEM=dh_python2
241
242 DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS="-Wl,-O1 -Wl,--as-needed"
243 DEB_COMPRESS_EXCLUDE = .c
244@@ -14,4 +16,10 @@
245 find debian/tmp/usr/lib -name \*.la -exec rm {} \;
246 find debian/tmp/usr/lib -name \*.a -exec rm {} \;
247
248+binary-predeb/gir%::
249+ dh_girepository -p$(cdbs_curpkg)
250+
251+binary-predeb/python-grip::
252+ dh_python2 -ppython-grip
253+
254 common-binary-predeb-arch:: list-missing
255
256=== added directory 'debian/source'
257=== added file 'debian/source/format'
258--- debian/source/format 1970-01-01 00:00:00 +0000
259+++ debian/source/format 2011-01-24 20:08:35 +0000
260@@ -0,0 +1,1 @@
261+3.0 (quilt)
262
263=== modified file 'examples/pygrip/pygrip-gestures.xml'
264--- examples/pygrip/pygrip-gestures.xml 2010-11-22 15:07:31 +0000
265+++ examples/pygrip/pygrip-gestures.xml 2011-01-24 20:08:35 +0000
266@@ -5,8 +5,8 @@
267 <object class="GtkWindow" id="window1">
268 <property name="width_request">0</property>
269 <property name="height_request">0</property>
270- <property name="default_width">1400</property>
271- <property name="default_height">800</property>
272+ <property name="default_width">800</property>
273+ <property name="default_height">600</property>
274 <signal name="map_event" handler="window_mapped"/>
275 <signal name="delete_event" handler="quit"/>
276 <child>
277
278=== modified file 'examples/pygrip/pygrip.py' (properties changed: -x to +x)
279--- examples/pygrip/pygrip.py 2010-11-22 15:07:31 +0000
280+++ examples/pygrip/pygrip.py 2011-01-24 20:08:35 +0000
281@@ -1,5 +1,6 @@
282-import pygtk
283+#!/usr/bin/python
284 from gi.repository import Gtk
285+Gtk.require_version('2.0')
286 from gi.repository import Grip
287
288
289@@ -16,26 +17,18 @@
290 builder.add_from_file("pygrip-gestures.xml")
291 builder.connect_signals(self)
292 self.window = builder.get_object("window1")
293+ self.gesture_manager = Grip.GestureManager()
294 self.window.show()
295
296 def window_mapped(self, widget, data=None):
297 # The gesture manager is only going to be needed for GTK2, since GTK3
298 # will have the gesture API natively. Conversely, pygrip will only be
299 # for GTK2, since PyGTK3 will having the bindings.
300- gesture_manager = Grip.GestureManager()
301- # For the purpose of this example, we are registering all gestures; we
302- # could limit this by choosing a different pygrip.GRIP_GESTURE_*
303- # mask. Similarly, we're using one set of callbacks for all the
304- # gestures; we could have different callbacks for different registered
305- # gestures.
306- # XXX the comment above is for the new API; the example below has been
307- # reverted to the older API until the new one is merged to trunk.
308+
309 finger_count = 2
310- gesture_manager.register_window(
311- self.window, Grip.GestureType.PINCH, finger_count,self.callback,
312- None, None)
313+ self.gesture_manager.register_window(widget, Grip.GestureType.PINCH, finger_count, self.callback, None)
314
315- def callback(self, window, time_type, gesture_type, gesture_event):
316+ def callback(self, window, time_type, gesture_event, data):
317 print "received gesture"
318
319 def quit(self, widget, data=None):
320
321=== modified file 'src/Makefile.am'
322--- src/Makefile.am 2010-11-22 14:49:44 +0000
323+++ src/Makefile.am 2011-01-24 20:08:35 +0000
324@@ -38,6 +38,7 @@
325 $(INTROSPECTION_SCANNER) \
326 -v --namespace Grip \
327 --nsversion=0.1 \
328+ --warn-all \
329 --add-include-path=$(srcdir) $(GTK_CFLAGS) \
330 --include=GObject-2.0 \
331 --include=GLib-2.0 \
332@@ -104,4 +105,5 @@
333 DISTCLEANFILES = \
334 stamp-griptypebuiltins.h \
335 griptypebuiltins.h \
336- griptypebuiltins.c
337\ No newline at end of file
338+ griptypebuiltins.c
339+
340
341=== modified file 'src/gripgesturemanager.c'
342--- src/gripgesturemanager.c 2011-01-18 15:32:31 +0000
343+++ src/gripgesturemanager.c 2011-01-24 20:08:35 +0000
344@@ -485,102 +485,106 @@
345
346 if (binding->type == type)
347 {
348+ GripGestureEvent *event = grip_gesture_event_new (type);
349+
350 if (type == GRIP_GESTURE_DRAG)
351 {
352- GripEventGestureDrag drag;
353-
354- drag.type = type;
355- drag.id = id;
356- drag.fingers = drag_gesture_handle_properties (&drag,
357- attr_count,
358- attrs);
359-
360- if (drag.fingers == binding->touches)
361+ GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
362+
363+ drag->type = type;
364+ drag->id = id;
365+ drag->fingers = drag_gesture_handle_properties (drag,
366+ attr_count,
367+ attrs);
368+
369+ if (drag->fingers == binding->touches)
370 {
371 if (matches_widget (binding->widget,
372 GTK_WIDGET (reg->window)->window,
373- (gint)drag.focus_x,
374- (gint)drag.focus_y))
375+ (gint)drag->focus_x,
376+ (gint)drag->focus_y))
377 {
378 binding->callback (binding->widget,
379 GRIP_TIME_START,
380- ((GripGestureEvent*)&drag),
381+ event,
382 binding->data);
383 }
384 }
385 }
386 else if (type == GRIP_GESTURE_PINCH)
387 {
388- GripEventGesturePinch pinch;
389-
390- pinch.type = type;
391- pinch.id = id;
392- pinch.fingers = pinch_gesture_handle_properties (&pinch,
393- attr_count,
394- attrs);
395-
396- if (pinch.fingers == binding->touches)
397+ GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
398+
399+ pinch->type = type;
400+ pinch->id = id;
401+ pinch->fingers = pinch_gesture_handle_properties (pinch,
402+ attr_count,
403+ attrs);
404+
405+ if (pinch->fingers == binding->touches)
406 {
407 if (matches_widget (binding->widget,
408 GTK_WIDGET (reg->window)->window,
409- (gint)pinch.focus_x,
410- (gint)pinch.focus_y))
411+ (gint)pinch->focus_x,
412+ (gint)pinch->focus_y))
413 {
414 binding->callback (binding->widget,
415 GRIP_TIME_START,
416- ((GripGestureEvent*)&pinch),
417+ event,
418 binding->data);
419 }
420 }
421 }
422 else if (type == GRIP_GESTURE_ROTATE)
423 {
424- GripEventGestureRotate rotate;
425-
426- rotate.type = type;
427- rotate.id = id;
428- rotate.fingers = rotate_gesture_handle_properties (&rotate,
429- attr_count,
430- attrs);
431-
432- if (rotate.fingers == binding->touches)
433+ GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
434+
435+ rotate->type = type;
436+ rotate->id = id;
437+ rotate->fingers = rotate_gesture_handle_properties (rotate,
438+ attr_count,
439+ attrs);
440+
441+ if (rotate->fingers == binding->touches)
442 {
443 if (matches_widget (binding->widget,
444 GTK_WIDGET (reg->window)->window,
445- (gint)rotate.focus_x,
446- (gint)rotate.focus_y))
447+ (gint)rotate->focus_x,
448+ (gint)rotate->focus_y))
449 {
450 binding->callback (binding->widget,
451 GRIP_TIME_START,
452- ((GripGestureEvent*)&rotate),
453+ event,
454 binding->data);
455 }
456 }
457 }
458 else if (type == GRIP_GESTURE_TAP)
459 {
460- GripEventGestureTap tap;
461-
462- tap.type = type;
463- tap.id = id;
464- tap.fingers = tap_gesture_handle_properties (&tap,
465- attr_count,
466- attrs);
467-
468- if (tap.fingers == binding->touches)
469+ GripEventGestureTap *tap = (GripEventGestureTap *)event;
470+
471+ tap->type = type;
472+ tap->id = id;
473+ tap->fingers = tap_gesture_handle_properties (tap,
474+ attr_count,
475+ attrs);
476+
477+ if (tap->fingers == binding->touches)
478 {
479 if (matches_widget (binding->widget,
480 GTK_WIDGET (reg->window)->window,
481- (gint)tap.focus_x,
482- (gint)tap.focus_y))
483+ (gint)tap->focus_x,
484+ (gint)tap->focus_y))
485 {
486 binding->callback (binding->widget,
487 GRIP_TIME_START,
488- ((GripGestureEvent*)&tap),
489+ event,
490 binding->data);
491 }
492 }
493 }
494+
495+ grip_gesture_event_free (event);
496 }
497 }
498 }
499@@ -601,102 +605,106 @@
500
501 if (binding->type == type)
502 {
503+ GripGestureEvent *event = grip_gesture_event_new (type);
504+
505 if (type == GRIP_GESTURE_DRAG)
506 {
507- GripEventGestureDrag drag;
508-
509- drag.type = type;
510- drag.id = id;
511- drag.fingers = drag_gesture_handle_properties (&drag,
512- attr_count,
513- attrs);
514-
515- if (drag.fingers == binding->touches)
516+ GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
517+
518+ drag->type = type;
519+ drag->id = id;
520+ drag->fingers = drag_gesture_handle_properties (drag,
521+ attr_count,
522+ attrs);
523+
524+ if (drag->fingers == binding->touches)
525 {
526 if (matches_widget (binding->widget,
527 GTK_WIDGET (reg->window)->window,
528- (gint)drag.focus_x,
529- (gint)drag.focus_y))
530+ (gint)drag->focus_x,
531+ (gint)drag->focus_y))
532 {
533 binding->callback (binding->widget,
534 GRIP_TIME_UPDATE,
535- ((GripGestureEvent*)&drag),
536+ event,
537 binding->data);
538 }
539 }
540 }
541 else if (type == GRIP_GESTURE_PINCH)
542 {
543- GripEventGesturePinch pinch;
544-
545- pinch.type = type;
546- pinch.id = id;
547- pinch.fingers = pinch_gesture_handle_properties (&pinch,
548- attr_count,
549- attrs);
550-
551- if (pinch.fingers == binding->touches)
552+ GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
553+
554+ pinch->type = type;
555+ pinch->id = id;
556+ pinch->fingers = pinch_gesture_handle_properties (pinch,
557+ attr_count,
558+ attrs);
559+
560+ if (pinch->fingers == binding->touches)
561 {
562 if (matches_widget (binding->widget,
563 GTK_WIDGET (reg->window)->window,
564- (gint)pinch.focus_x,
565- (gint)pinch.focus_y))
566+ (gint)pinch->focus_x,
567+ (gint)pinch->focus_y))
568 {
569 binding->callback (binding->widget,
570 GRIP_TIME_UPDATE,
571- ((GripGestureEvent*)&pinch),
572+ event,
573 binding->data);
574 }
575 }
576 }
577 else if (type == GRIP_GESTURE_ROTATE)
578 {
579- GripEventGestureRotate rotate;
580-
581- rotate.type = type;
582- rotate.id = id;
583- rotate.fingers = rotate_gesture_handle_properties (&rotate,
584- attr_count,
585- attrs);
586-
587- if (rotate.fingers == binding->touches)
588+ GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
589+
590+ rotate->type = type;
591+ rotate->id = id;
592+ rotate->fingers = rotate_gesture_handle_properties (rotate,
593+ attr_count,
594+ attrs);
595+
596+ if (rotate->fingers == binding->touches)
597 {
598 if (matches_widget (binding->widget,
599 GTK_WIDGET (reg->window)->window,
600- (gint)rotate.focus_x,
601- (gint)rotate.focus_y))
602+ (gint)rotate->focus_x,
603+ (gint)rotate->focus_y))
604 {
605 binding->callback (binding->widget,
606 GRIP_TIME_UPDATE,
607- ((GripGestureEvent*)&rotate),
608+ event,
609 binding->data);
610 }
611 }
612 }
613 else if (type == GRIP_GESTURE_TAP)
614 {
615- GripEventGestureTap tap;
616-
617- tap.type = type;
618- tap.id = id;
619- tap.fingers = tap_gesture_handle_properties (&tap,
620- attr_count,
621- attrs);
622-
623- if (tap.fingers == binding->touches)
624+ GripEventGestureTap *tap = (GripEventGestureTap *)event;
625+
626+ tap->type = type;
627+ tap->id = id;
628+ tap->fingers = tap_gesture_handle_properties (tap,
629+ attr_count,
630+ attrs);
631+
632+ if (tap->fingers == binding->touches)
633 {
634 if (matches_widget (binding->widget,
635 GTK_WIDGET (reg->window)->window,
636- (gint)tap.focus_x,
637- (gint)tap.focus_y))
638+ (gint)tap->focus_x,
639+ (gint)tap->focus_y))
640 {
641 binding->callback (binding->widget,
642 GRIP_TIME_UPDATE,
643- ((GripGestureEvent*)&tap),
644+ event,
645 binding->data);
646 }
647 }
648 }
649+
650+ grip_gesture_event_free (event);
651 }
652 }
653 }
654@@ -717,102 +725,106 @@
655
656 if (binding->type == type)
657 {
658+ GripGestureEvent *event = grip_gesture_event_new (type);
659+
660 if (type == GRIP_GESTURE_DRAG)
661 {
662- GripEventGestureDrag drag;
663-
664- drag.type = type;
665- drag.id = id;
666- drag.fingers = drag_gesture_handle_properties (&drag,
667- attr_count,
668- attrs);
669-
670- if (drag.fingers == binding->touches)
671+ GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
672+
673+ drag->type = type;
674+ drag->id = id;
675+ drag->fingers = drag_gesture_handle_properties (drag,
676+ attr_count,
677+ attrs);
678+
679+ if (drag->fingers == binding->touches)
680 {
681 if (matches_widget (binding->widget,
682 GTK_WIDGET (reg->window)->window,
683- (gint)drag.focus_x,
684- (gint)drag.focus_y))
685+ (gint)drag->focus_x,
686+ (gint)drag->focus_y))
687 {
688 binding->callback (binding->widget,
689 GRIP_TIME_END,
690- ((GripGestureEvent*)&drag),
691+ event,
692 binding->data);
693 }
694 }
695 }
696 else if (type == GRIP_GESTURE_PINCH)
697 {
698- GripEventGesturePinch pinch;
699-
700- pinch.type = type;
701- pinch.id = id;
702- pinch.fingers = pinch_gesture_handle_properties (&pinch,
703- attr_count,
704- attrs);
705-
706- if (pinch.fingers == binding->touches)
707+ GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
708+
709+ pinch->type = type;
710+ pinch->id = id;
711+ pinch->fingers = pinch_gesture_handle_properties (pinch,
712+ attr_count,
713+ attrs);
714+
715+ if (pinch->fingers == binding->touches)
716 {
717 if (matches_widget (binding->widget,
718 GTK_WIDGET (reg->window)->window,
719- (gint)pinch.focus_x,
720- (gint)pinch.focus_y))
721+ (gint)pinch->focus_x,
722+ (gint)pinch->focus_y))
723 {
724 binding->callback (binding->widget,
725 GRIP_TIME_END,
726- ((GripGestureEvent*)&pinch),
727+ event,
728 binding->data);
729 }
730 }
731 }
732 else if (type == GRIP_GESTURE_ROTATE)
733 {
734- GripEventGestureRotate rotate;
735-
736- rotate.type = type;
737- rotate.id = id;
738- rotate.fingers = rotate_gesture_handle_properties (&rotate,
739- attr_count,
740- attrs);
741-
742- if (rotate.fingers == binding->touches)
743+ GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
744+
745+ rotate->type = type;
746+ rotate->id = id;
747+ rotate->fingers = rotate_gesture_handle_properties (rotate,
748+ attr_count,
749+ attrs);
750+
751+ if (rotate->fingers == binding->touches)
752 {
753 if (matches_widget (binding->widget,
754 GTK_WIDGET (reg->window)->window,
755- (gint)rotate.focus_x,
756- (gint)rotate.focus_y))
757+ (gint)rotate->focus_x,
758+ (gint)rotate->focus_y))
759 {
760 binding->callback (binding->widget,
761 GRIP_TIME_END,
762- ((GripGestureEvent*)&rotate),
763+ event,
764 binding->data);
765 }
766 }
767 }
768 else if (type == GRIP_GESTURE_TAP)
769 {
770- GripEventGestureTap tap;
771-
772- tap.type = type;
773- tap.id = id;
774- tap.fingers = tap_gesture_handle_properties (&tap,
775- attr_count,
776- attrs);
777-
778- if (tap.fingers == binding->touches)
779+ GripEventGestureTap *tap = (GripEventGestureTap *)event;
780+
781+ tap->type = type;
782+ tap->id = id;
783+ tap->fingers = tap_gesture_handle_properties (tap,
784+ attr_count,
785+ attrs);
786+
787+ if (tap->fingers == binding->touches)
788 {
789 if (matches_widget (binding->widget,
790 GTK_WIDGET (reg->window)->window,
791- (gint)tap.focus_x,
792- (gint)tap.focus_y))
793+ (gint)tap->focus_x,
794+ (gint)tap->focus_y))
795 {
796 binding->callback (binding->widget,
797 GRIP_TIME_END,
798- ((GripGestureEvent*)&tap),
799+ event,
800 binding->data);
801 }
802 }
803 }
804+
805+ grip_gesture_event_free (event);
806 }
807 }
808 }
809@@ -908,6 +920,9 @@
810 g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager));
811 g_return_if_fail (GTK_IS_WIDGET (widget));
812
813+ g_print ("register internal (gesture_type == %d, touch_points == %d)\n",
814+ gesture_type, touch_points);
815+
816 toplevel = gtk_widget_get_toplevel (widget);
817
818 g_return_if_fail (GTK_IS_WINDOW (toplevel));
819@@ -1212,3 +1227,59 @@
820 req);
821 }
822 }
823+
824+GType
825+grip_gesture_event_get_type (void)
826+{
827+ static GType type = 0;
828+
829+ if (type == 0)
830+ {
831+ type = g_boxed_type_register_static (g_intern_static_string ("GripGestureEvent"),
832+ (GBoxedCopyFunc)grip_gesture_event_copy,
833+ (GBoxedFreeFunc)grip_gesture_event_free);
834+ }
835+
836+ return type;
837+}
838+
839+GripGestureEvent *
840+grip_gesture_event_new (GripGestureType type)
841+{
842+ GripGestureEvent *event = g_slice_new0 (GripGestureEvent);
843+
844+ event->any.type = type;
845+ if (event->any.window)
846+ g_print ("WINDOW!!\n");
847+
848+ return event;
849+}
850+
851+GripGestureEvent *
852+grip_gesture_event_copy (const GripGestureEvent *event)
853+{
854+ GripGestureEvent *new_event;
855+
856+ g_return_val_if_fail (event != NULL, NULL);
857+
858+ new_event = grip_gesture_event_new (event->type);
859+ *new_event = *event;
860+
861+ g_print ("COPY!\n");
862+
863+ // if (new_event->any.window)
864+ // g_object_ref (new_event->any.window);
865+
866+ return new_event;
867+}
868+
869+void
870+grip_gesture_event_free (GripGestureEvent *event)
871+{
872+ g_return_if_fail (event != NULL);
873+
874+ // if (event->any.window)
875+ // g_object_unref (event->any.window);
876+
877+ g_slice_free (GripGestureEvent, event);
878+}
879
880=== modified file 'src/gripgesturemanager.h'
881--- src/gripgesturemanager.h 2010-12-10 17:56:56 +0000
882+++ src/gripgesturemanager.h 2011-01-24 20:08:35 +0000
883@@ -42,6 +42,7 @@
884 typedef struct _GripGestureManagerPrivate GripGestureManagerPrivate;
885
886 typedef union _GripGestureEvent GripGestureEvent;
887+typedef struct _GripEventGestureAny GripEventGestureAny;
888 typedef struct _GripEventGestureDrag GripEventGestureDrag;
889 typedef struct _GripEventGesturePinch GripEventGesturePinch;
890 typedef struct _GripEventGestureRotate GripEventGestureRotate;
891@@ -60,9 +61,15 @@
892 GRIP_TIME_END
893 } GripTimeType;
894
895+struct _GripEventGestureAny
896+{
897+ GdkEventType type;
898+ GdkWindow *window;
899+};
900+
901 struct _GripEventGestureDrag
902 {
903- GripGestureType type;
904+ GripGestureType type;
905 guint id;
906 GdkWindow *window;
907 GdkWindow *root;
908@@ -81,7 +88,7 @@
909
910 struct _GripEventGesturePinch
911 {
912- GripGestureType type;
913+ GripGestureType type;
914 guint id;
915 GdkWindow *window;
916 GdkWindow *root;
917@@ -131,6 +138,7 @@
918 union _GripGestureEvent
919 {
920 GripGestureType type;
921+ GripEventGestureAny any;
922 GripEventGestureDrag drag;
923 GripEventGesturePinch pinch;
924 GripEventGestureRotate rotate;
925@@ -161,13 +169,39 @@
926 GObjectClass parent_class;
927 };
928
929+/**
930+ * GripGestureCallback:
931+ * @widget: (in): A #GtkWidget pointer
932+ * @time: A #GripTimeType
933+ * @gesture: (in): A #GripGestureEvent pointer
934+ * @user_data: (transfer none): user data
935+ **/
936 typedef void (* GripGestureCallback) (GtkWidget *widget,
937 GripTimeType time,
938 GripGestureEvent *gesture,
939 gpointer user_data);
940
941 GType grip_gesture_manager_get_type (void) G_GNUC_CONST;
942+
943+/**
944+ * grip_gesture_manager_get:
945+ *
946+ * Retrieves a #GripGestureManager pointer.
947+ *
948+ * Return value: (transfer none): A #GripGestureManager
949+ **/
950 GripGestureManager *grip_gesture_manager_get (void);
951+
952+/**
953+ * grip_gesture_manager_register_window:
954+ * @manager: self
955+ * @widget: A #GtkWidget on which to register the gesture
956+ * @gesture_type: Gesture type
957+ * @touch_points: Number of touch points
958+ * @callback: Callback
959+ * @user_data: (transfer none): User data
960+ * @destroy: (transfer none) (scope async): Destroy
961+ */
962 void grip_gesture_manager_register_window (GripGestureManager *manager,
963 GtkWidget *widget,
964 GripGestureType gesture_type,
965@@ -176,6 +210,12 @@
966 gpointer user_data,
967 GDestroyNotify destroy);
968
969+GType grip_gesture_event_get_type (void) G_GNUC_CONST;
970+GripGestureEvent *grip_gesture_event_new (GripGestureType gesture_type);
971+void grip_gesture_event_free (GripGestureEvent *event);
972+GripGestureEvent *grip_gesture_event_copy (const GripGestureEvent *event);
973+
974+
975 G_END_DECLS
976
977 #endif /* __GRIP_GESTURE_MANAGER_H__ */

Subscribers

People subscribed via source and target branches