Merge lp:~bratsche/libgrope/callback-user-data into lp:libgrope

Proposed by Cody Russell
Status: Merged
Merged at revision: 3
Proposed branch: lp:~bratsche/libgrope/callback-user-data
Merge into: lp:libgrope
Diff against target: 274 lines (+62/-31)
4 files modified
example/gesture.c (+16/-8)
src/grope.h (+1/-3)
src/gropegesturemanager.c (+37/-15)
src/gropegesturemanager.h (+8/-5)
To merge this branch: bzr merge lp:~bratsche/libgrope/callback-user-data
Reviewer Review Type Date Requested Status
Duncan McGreggor (community) Approve
Open Input Framework Team Pending
Review via email: mp+40479@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Duncan McGreggor (oubiwann) wrote :

I'm +1 for this change, as long as I understand it :-) Can you explain (briefly; no need for a disertation) the reason you're adding the gpointer?

review: Needs Information
3. By Cody Russell

Add data to binding.

Revision history for this message
Cody Russell (bratsche) wrote :

Oops, I put that up for review earlier than intended. The next revision finishes off what I wanted to do.

When you register a window to receive gesture events, you can pass some arbitrary data that will be stored in the registration and sent to the callback functions.

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Cool, thanks for the extra info :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'example/gesture.c'
2--- example/gesture.c 2010-10-12 15:42:04 +0000
3+++ example/gesture.c 2010-11-09 22:01:46 +0000
4@@ -62,7 +62,8 @@
5
6 static void
7 gesture_start (GtkWindow *window,
8- GropeGestureEvent *event)
9+ GropeGestureEvent *event,
10+ gpointer user_data)
11 {
12 in_touch++;
13
14@@ -71,7 +72,8 @@
15
16 static void
17 gesture_end (GtkWindow *window,
18- GropeGestureEvent *event)
19+ GropeGestureEvent *event,
20+ gpointer user_data)
21 {
22 in_touch--;
23
24@@ -80,7 +82,8 @@
25
26 static void
27 rotate_update (GtkWindow *window,
28- GropeGestureEvent *event)
29+ GropeGestureEvent *event,
30+ gpointer user_data)
31 {
32 GropeEventGestureRotate *e = (GropeEventGestureRotate *)event;
33
34@@ -91,7 +94,8 @@
35
36 static void
37 pinch_update (GtkWindow *window,
38- GropeGestureEvent *event)
39+ GropeGestureEvent *event,
40+ gpointer user_data)
41 {
42 GropeEventGesturePinch *e = (GropeEventGesturePinch *)event;
43
44@@ -102,7 +106,8 @@
45
46 static void
47 drag_update (GtkWindow *window,
48- GropeGestureEvent *event)
49+ GropeGestureEvent *event,
50+ gpointer user_data)
51 {
52 GropeEventGestureDrag *e = (GropeEventGestureDrag *)event;
53
54@@ -124,7 +129,8 @@
55 2,
56 gesture_start,
57 pinch_update,
58- gesture_end);
59+ gesture_end,
60+ NULL, NULL);
61
62 grope_gesture_manager_register_window (manager,
63 window,
64@@ -132,7 +138,8 @@
65 2,
66 gesture_start,
67 rotate_update,
68- gesture_end);
69+ gesture_end,
70+ NULL, NULL);
71
72 grope_gesture_manager_register_window (manager,
73 window,
74@@ -140,7 +147,8 @@
75 2,
76 gesture_start,
77 drag_update,
78- gesture_end);
79+ gesture_end,
80+ NULL, NULL);
81 }
82
83 static void
84
85=== modified file 'src/grope.h'
86--- src/grope.h 2010-10-12 15:42:04 +0000
87+++ src/grope.h 2010-11-09 22:01:46 +0000
88@@ -26,8 +26,6 @@
89 #ifndef __GROPE_H__
90 #define __GROPE_H__
91
92-#include <libgrope/gropescalemenuitem.h>
93-#include <libgrope/gropeentrymenuitem.h>
94-#include <libgrope/gropemessagedialog.h>
95+#include <libgrope/gropegesturemanager.h>
96
97 #endif /* __GROPE_H__ */
98
99=== modified file 'src/gropegesturemanager.c'
100--- src/gropegesturemanager.c 2010-10-12 15:42:04 +0000
101+++ src/gropegesturemanager.c 2010-11-09 22:01:46 +0000
102@@ -38,11 +38,13 @@
103
104 struct _GropeGestureBinding
105 {
106- GropeGestureType type;
107- gint touches;
108- GropeGestureCallback start;
109- GropeGestureCallback update;
110- GropeGestureCallback end;
111+ GropeGestureType type;
112+ gint touches;
113+ GropeGestureCallback start;
114+ GropeGestureCallback update;
115+ GropeGestureCallback end;
116+ gpointer data;
117+ GDestroyNotify destroy;
118 };
119
120 struct _GropeGestureRegistration
121@@ -366,7 +368,8 @@
122 if (drag.fingers == binding->touches)
123 {
124 binding->start (reg->window,
125- ((GropeGestureEvent*)&drag));
126+ ((GropeGestureEvent*)&drag),
127+ binding->data);
128 }
129 }
130 else if (type == GROPE_GESTURE_PINCH)
131@@ -382,7 +385,8 @@
132 if (pinch.fingers == binding->touches)
133 {
134 binding->start (reg->window,
135- ((GropeGestureEvent*)&pinch));
136+ ((GropeGestureEvent*)&pinch),
137+ binding->data);
138 }
139 }
140 else if (type == GROPE_GESTURE_ROTATE)
141@@ -398,7 +402,8 @@
142 if (rotate.fingers == binding->touches)
143 {
144 binding->start (reg->window,
145- ((GropeGestureEvent*)&rotate));
146+ ((GropeGestureEvent*)&rotate),
147+ binding->data);
148 }
149 }
150
151@@ -436,7 +441,8 @@
152 if (drag.fingers == binding->touches)
153 {
154 binding->update (reg->window,
155- ((GropeGestureEvent*)&drag));
156+ ((GropeGestureEvent*)&drag),
157+ binding->data);
158 }
159 }
160 else if (type == GROPE_GESTURE_PINCH)
161@@ -452,7 +458,8 @@
162 if (pinch.fingers == binding->touches)
163 {
164 binding->update (reg->window,
165- ((GropeGestureEvent*)&pinch));
166+ ((GropeGestureEvent*)&pinch),
167+ binding->data);
168 }
169 }
170 else if (type == GROPE_GESTURE_ROTATE)
171@@ -468,7 +475,8 @@
172 if (rotate.fingers == binding->touches)
173 {
174 binding->update (reg->window,
175- ((GropeGestureEvent*)&rotate));
176+ ((GropeGestureEvent*)&rotate),
177+ binding->data);
178 }
179 }
180 }
181@@ -504,7 +512,8 @@
182 if (drag.fingers == binding->touches)
183 {
184 binding->end (reg->window,
185- ((GropeGestureEvent*)&drag));
186+ ((GropeGestureEvent*)&drag),
187+ binding->data);
188 }
189 }
190 else if (type == GROPE_GESTURE_PINCH)
191@@ -520,7 +529,8 @@
192 if (pinch.fingers == binding->touches)
193 {
194 binding->end (reg->window,
195- ((GropeGestureEvent*)&pinch));
196+ ((GropeGestureEvent*)&pinch),
197+ binding->data);
198 }
199 }
200 else if (type == GROPE_GESTURE_ROTATE)
201@@ -536,7 +546,8 @@
202 if (rotate.fingers == binding->touches)
203 {
204 binding->end (reg->window,
205- ((GropeGestureEvent*)&rotate));
206+ ((GropeGestureEvent*)&rotate),
207+ binding->data);
208 }
209 }
210 }
211@@ -578,6 +589,13 @@
212 {
213 GropeGestureBinding *binding = (GropeGestureBinding *)list->data;
214
215+ if (binding->destroy)
216+ {
217+ GDestroyNotify d = binding->destroy;
218+
219+ d (binding->data);
220+ }
221+
222 g_free (binding);
223 }
224
225@@ -620,7 +638,9 @@
226 gint touch_points,
227 GropeGestureCallback start,
228 GropeGestureCallback update,
229- GropeGestureCallback end)
230+ GropeGestureCallback end,
231+ gpointer user_data,
232+ GDestroyNotify destroy)
233 {
234 GropeGestureManagerPrivate *priv;
235 GropeGestureRegistration *reg;
236@@ -701,6 +721,8 @@
237 binding->start = start;
238 binding->update = update;
239 binding->end = end;
240+ binding->data = user_data;
241+ binding->destroy = destroy;
242
243 reg->bindings = g_list_append (reg->bindings, binding);
244
245
246=== modified file 'src/gropegesturemanager.h'
247--- src/gropegesturemanager.h 2010-10-12 15:42:04 +0000
248+++ src/gropegesturemanager.h 2010-11-09 22:01:46 +0000
249@@ -123,18 +123,21 @@
250 GObjectClass parent_class;
251 };
252
253-typedef void (* GropeGestureCallback) (GtkWindow *window,
254- GropeGestureEvent *gesture);
255+typedef void (* GropeGestureCallback) (GtkWindow *window,
256+ GropeGestureEvent *gesture,
257+ gpointer user_data);
258
259 GType grope_gesture_manager_get_type (void) G_GNUC_CONST;
260 GropeGestureManager *grope_gesture_manager_get (void);
261 void grope_gesture_manager_register_window (GropeGestureManager *manager,
262- GtkWindow *window,
263+ GtkWindow *window,
264 GropeGestureType gesture_type,
265- gint touch_points,
266+ gint touch_points,
267 GropeGestureCallback start,
268 GropeGestureCallback update,
269- GropeGestureCallback end);
270+ GropeGestureCallback end,
271+ gpointer user_data,
272+ GDestroyNotify destroy);
273
274 G_END_DECLS
275

Subscribers

People subscribed via source and target branches