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
=== modified file 'example/gesture.c'
--- example/gesture.c 2010-10-12 15:42:04 +0000
+++ example/gesture.c 2010-11-09 22:01:46 +0000
@@ -62,7 +62,8 @@
6262
63static void63static void
64gesture_start (GtkWindow *window,64gesture_start (GtkWindow *window,
65 GropeGestureEvent *event)65 GropeGestureEvent *event,
66 gpointer user_data)
66{67{
67 in_touch++;68 in_touch++;
6869
@@ -71,7 +72,8 @@
7172
72static void73static void
73gesture_end (GtkWindow *window,74gesture_end (GtkWindow *window,
74 GropeGestureEvent *event)75 GropeGestureEvent *event,
76 gpointer user_data)
75{77{
76 in_touch--;78 in_touch--;
7779
@@ -80,7 +82,8 @@
8082
81static void83static void
82rotate_update (GtkWindow *window,84rotate_update (GtkWindow *window,
83 GropeGestureEvent *event)85 GropeGestureEvent *event,
86 gpointer user_data)
84{87{
85 GropeEventGestureRotate *e = (GropeEventGestureRotate *)event;88 GropeEventGestureRotate *e = (GropeEventGestureRotate *)event;
8689
@@ -91,7 +94,8 @@
9194
92static void95static void
93pinch_update (GtkWindow *window,96pinch_update (GtkWindow *window,
94 GropeGestureEvent *event)97 GropeGestureEvent *event,
98 gpointer user_data)
95{99{
96 GropeEventGesturePinch *e = (GropeEventGesturePinch *)event;100 GropeEventGesturePinch *e = (GropeEventGesturePinch *)event;
97101
@@ -102,7 +106,8 @@
102106
103static void107static void
104drag_update (GtkWindow *window,108drag_update (GtkWindow *window,
105 GropeGestureEvent *event)109 GropeGestureEvent *event,
110 gpointer user_data)
106{111{
107 GropeEventGestureDrag *e = (GropeEventGestureDrag *)event;112 GropeEventGestureDrag *e = (GropeEventGestureDrag *)event;
108113
@@ -124,7 +129,8 @@
124 2,129 2,
125 gesture_start,130 gesture_start,
126 pinch_update,131 pinch_update,
127 gesture_end);132 gesture_end,
133 NULL, NULL);
128134
129 grope_gesture_manager_register_window (manager,135 grope_gesture_manager_register_window (manager,
130 window,136 window,
@@ -132,7 +138,8 @@
132 2,138 2,
133 gesture_start,139 gesture_start,
134 rotate_update,140 rotate_update,
135 gesture_end);141 gesture_end,
142 NULL, NULL);
136143
137 grope_gesture_manager_register_window (manager,144 grope_gesture_manager_register_window (manager,
138 window,145 window,
@@ -140,7 +147,8 @@
140 2,147 2,
141 gesture_start,148 gesture_start,
142 drag_update,149 drag_update,
143 gesture_end);150 gesture_end,
151 NULL, NULL);
144}152}
145153
146static void154static void
147155
=== modified file 'src/grope.h'
--- src/grope.h 2010-10-12 15:42:04 +0000
+++ src/grope.h 2010-11-09 22:01:46 +0000
@@ -26,8 +26,6 @@
26#ifndef __GROPE_H__26#ifndef __GROPE_H__
27#define __GROPE_H__27#define __GROPE_H__
2828
29#include <libgrope/gropescalemenuitem.h>29#include <libgrope/gropegesturemanager.h>
30#include <libgrope/gropeentrymenuitem.h>
31#include <libgrope/gropemessagedialog.h>
3230
33#endif /* __GROPE_H__ */31#endif /* __GROPE_H__ */
3432
=== modified file 'src/gropegesturemanager.c'
--- src/gropegesturemanager.c 2010-10-12 15:42:04 +0000
+++ src/gropegesturemanager.c 2010-11-09 22:01:46 +0000
@@ -38,11 +38,13 @@
3838
39struct _GropeGestureBinding39struct _GropeGestureBinding
40{40{
41 GropeGestureType type;41 GropeGestureType type;
42 gint touches;42 gint touches;
43 GropeGestureCallback start;43 GropeGestureCallback start;
44 GropeGestureCallback update;44 GropeGestureCallback update;
45 GropeGestureCallback end;45 GropeGestureCallback end;
46 gpointer data;
47 GDestroyNotify destroy;
46};48};
4749
48struct _GropeGestureRegistration50struct _GropeGestureRegistration
@@ -366,7 +368,8 @@
366 if (drag.fingers == binding->touches)368 if (drag.fingers == binding->touches)
367 {369 {
368 binding->start (reg->window,370 binding->start (reg->window,
369 ((GropeGestureEvent*)&drag));371 ((GropeGestureEvent*)&drag),
372 binding->data);
370 }373 }
371 }374 }
372 else if (type == GROPE_GESTURE_PINCH)375 else if (type == GROPE_GESTURE_PINCH)
@@ -382,7 +385,8 @@
382 if (pinch.fingers == binding->touches)385 if (pinch.fingers == binding->touches)
383 {386 {
384 binding->start (reg->window,387 binding->start (reg->window,
385 ((GropeGestureEvent*)&pinch));388 ((GropeGestureEvent*)&pinch),
389 binding->data);
386 }390 }
387 }391 }
388 else if (type == GROPE_GESTURE_ROTATE)392 else if (type == GROPE_GESTURE_ROTATE)
@@ -398,7 +402,8 @@
398 if (rotate.fingers == binding->touches)402 if (rotate.fingers == binding->touches)
399 {403 {
400 binding->start (reg->window,404 binding->start (reg->window,
401 ((GropeGestureEvent*)&rotate));405 ((GropeGestureEvent*)&rotate),
406 binding->data);
402 }407 }
403 }408 }
404409
@@ -436,7 +441,8 @@
436 if (drag.fingers == binding->touches)441 if (drag.fingers == binding->touches)
437 {442 {
438 binding->update (reg->window,443 binding->update (reg->window,
439 ((GropeGestureEvent*)&drag));444 ((GropeGestureEvent*)&drag),
445 binding->data);
440 }446 }
441 }447 }
442 else if (type == GROPE_GESTURE_PINCH)448 else if (type == GROPE_GESTURE_PINCH)
@@ -452,7 +458,8 @@
452 if (pinch.fingers == binding->touches)458 if (pinch.fingers == binding->touches)
453 {459 {
454 binding->update (reg->window,460 binding->update (reg->window,
455 ((GropeGestureEvent*)&pinch));461 ((GropeGestureEvent*)&pinch),
462 binding->data);
456 }463 }
457 }464 }
458 else if (type == GROPE_GESTURE_ROTATE)465 else if (type == GROPE_GESTURE_ROTATE)
@@ -468,7 +475,8 @@
468 if (rotate.fingers == binding->touches)475 if (rotate.fingers == binding->touches)
469 {476 {
470 binding->update (reg->window,477 binding->update (reg->window,
471 ((GropeGestureEvent*)&rotate));478 ((GropeGestureEvent*)&rotate),
479 binding->data);
472 }480 }
473 }481 }
474 }482 }
@@ -504,7 +512,8 @@
504 if (drag.fingers == binding->touches)512 if (drag.fingers == binding->touches)
505 {513 {
506 binding->end (reg->window,514 binding->end (reg->window,
507 ((GropeGestureEvent*)&drag));515 ((GropeGestureEvent*)&drag),
516 binding->data);
508 }517 }
509 }518 }
510 else if (type == GROPE_GESTURE_PINCH)519 else if (type == GROPE_GESTURE_PINCH)
@@ -520,7 +529,8 @@
520 if (pinch.fingers == binding->touches)529 if (pinch.fingers == binding->touches)
521 {530 {
522 binding->end (reg->window,531 binding->end (reg->window,
523 ((GropeGestureEvent*)&pinch));532 ((GropeGestureEvent*)&pinch),
533 binding->data);
524 }534 }
525 }535 }
526 else if (type == GROPE_GESTURE_ROTATE)536 else if (type == GROPE_GESTURE_ROTATE)
@@ -536,7 +546,8 @@
536 if (rotate.fingers == binding->touches)546 if (rotate.fingers == binding->touches)
537 {547 {
538 binding->end (reg->window,548 binding->end (reg->window,
539 ((GropeGestureEvent*)&rotate));549 ((GropeGestureEvent*)&rotate),
550 binding->data);
540 }551 }
541 }552 }
542 }553 }
@@ -578,6 +589,13 @@
578 {589 {
579 GropeGestureBinding *binding = (GropeGestureBinding *)list->data;590 GropeGestureBinding *binding = (GropeGestureBinding *)list->data;
580591
592 if (binding->destroy)
593 {
594 GDestroyNotify d = binding->destroy;
595
596 d (binding->data);
597 }
598
581 g_free (binding);599 g_free (binding);
582 }600 }
583601
@@ -620,7 +638,9 @@
620 gint touch_points,638 gint touch_points,
621 GropeGestureCallback start,639 GropeGestureCallback start,
622 GropeGestureCallback update,640 GropeGestureCallback update,
623 GropeGestureCallback end)641 GropeGestureCallback end,
642 gpointer user_data,
643 GDestroyNotify destroy)
624{644{
625 GropeGestureManagerPrivate *priv;645 GropeGestureManagerPrivate *priv;
626 GropeGestureRegistration *reg;646 GropeGestureRegistration *reg;
@@ -701,6 +721,8 @@
701 binding->start = start;721 binding->start = start;
702 binding->update = update;722 binding->update = update;
703 binding->end = end;723 binding->end = end;
724 binding->data = user_data;
725 binding->destroy = destroy;
704726
705 reg->bindings = g_list_append (reg->bindings, binding);727 reg->bindings = g_list_append (reg->bindings, binding);
706728
707729
=== modified file 'src/gropegesturemanager.h'
--- src/gropegesturemanager.h 2010-10-12 15:42:04 +0000
+++ src/gropegesturemanager.h 2010-11-09 22:01:46 +0000
@@ -123,18 +123,21 @@
123 GObjectClass parent_class;123 GObjectClass parent_class;
124};124};
125125
126typedef void (* GropeGestureCallback) (GtkWindow *window,126typedef void (* GropeGestureCallback) (GtkWindow *window,
127 GropeGestureEvent *gesture);127 GropeGestureEvent *gesture,
128 gpointer user_data);
128129
129GType grope_gesture_manager_get_type (void) G_GNUC_CONST;130GType grope_gesture_manager_get_type (void) G_GNUC_CONST;
130GropeGestureManager *grope_gesture_manager_get (void);131GropeGestureManager *grope_gesture_manager_get (void);
131void grope_gesture_manager_register_window (GropeGestureManager *manager,132void grope_gesture_manager_register_window (GropeGestureManager *manager,
132 GtkWindow *window,133 GtkWindow *window,
133 GropeGestureType gesture_type,134 GropeGestureType gesture_type,
134 gint touch_points,135 gint touch_points,
135 GropeGestureCallback start,136 GropeGestureCallback start,
136 GropeGestureCallback update,137 GropeGestureCallback update,
137 GropeGestureCallback end);138 GropeGestureCallback end,
139 gpointer user_data,
140 GDestroyNotify destroy);
138141
139G_END_DECLS142G_END_DECLS
140143

Subscribers

People subscribed via source and target branches