Merge lp:~bratsche/oif/evince-libgrip into lp:~oif-team/oif/evince-gestures-trunk

Proposed by Cody Russell
Status: Merged
Merged at revision: 4209
Proposed branch: lp:~bratsche/oif/evince-libgrip
Merge into: lp:~oif-team/oif/evince-gestures-trunk
Diff against target: 279 lines (+115/-126)
2 files modified
configure.ac (+1/-1)
shell/ev-window.c (+114/-125)
To merge this branch: bzr merge lp:~bratsche/oif/evince-libgrip
Reviewer Review Type Date Requested Status
Mohamed IKBEL Boulabiar (community) Approve
Duncan McGreggor (community) Needs Information
Review via email: mp+41621@code.launchpad.net
To post a comment you must log in.
lp:~bratsche/oif/evince-libgrip updated
4208. By Cody Russell

Merge from trunk, resolve conflicts.

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

Hey Cody,

I tried building this but autogen fails since there's no package for libgrip... how do I work around that? (Or do you want to push a libgrip package into the PPA?).

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

Need to package libgrip still. :/

lp:~bratsche/oif/evince-libgrip updated
4209. By Cody Russell

Fix warnings, resolve conflict.

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

libgrip is packaged now and is in the PPA. I found a couple issues and fixed them in revno 4209.

Revision history for this message
Mohamed IKBEL Boulabiar (boulabiar) wrote :

I liked the factorization of ev_(pinch||drag||rotate)_gesture_(start||update||end) functions into one: ev_gesture_callback

Fully tested and works fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2010-09-21 18:17:40 +0000
3+++ configure.ac 2010-11-29 17:47:48 +0000
4@@ -193,7 +193,7 @@
5 ;;
6 esac
7
8-PKG_CHECK_MODULES([SHELL_CORE],[libxml-2.0 >= $LIBXML_REQUIRED libido-0.1 >= 0.2 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gthread-2.0 $SHELL_PLATFORM_PKGS])
9+PKG_CHECK_MODULES([SHELL_CORE],[libxml-2.0 >= $LIBXML_REQUIRED libgrip-0.1 >= 0.1 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gthread-2.0 $SHELL_PLATFORM_PKGS])
10
11 # *********
12 # SM client
13
14=== modified file 'shell/ev-window.c'
15--- shell/ev-window.c 2010-11-23 14:45:21 +0000
16+++ shell/ev-window.c 2010-11-29 17:47:48 +0000
17@@ -41,7 +41,7 @@
18 #include <gio/gio.h>
19 #include <gtk/gtk.h>
20
21-#include <libido/idogesturemanager.h>
22+#include <libgrip/gripgesturemanager.h>
23
24 #include "egg-editable-toolbar.h"
25 #include "egg-toolbar-editor.h"
26@@ -5433,104 +5433,96 @@
27 }
28
29 static void
30-ev_pinch_gesture_start (GtkWindow *window,
31- IdoGestureEvent *event)
32-{
33- EvWindowPrivate *priv = EV_WINDOW (window)->priv;
34- IdoEventGesturePinch *pinch = (IdoEventGesturePinch *)event;
35-
36- priv->pinch_start_x = pinch->focus_x;
37- priv->pinch_start_y = pinch->focus_y;
38- priv->pinch_start_radius = pinch->radius;
39-}
40-
41-static void
42-ev_pinch_gesture_update (GtkWindow *window,
43- IdoGestureEvent *event)
44-{
45- IdoEventGesturePinch *pinch = (IdoEventGesturePinch *)event;
46- EvWindowPrivate *priv = EV_WINDOW (window)->priv;
47- gdouble increment = pinch->radius_delta * 0.01;
48-
49- if (increment < 0.0) increment = -increment;
50- increment += 1.0;
51-
52- if (pinch->radius_delta < 0.0) {
53- ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
54- ev_view_zoom_out_smooth (priv->view, (1.0 / increment));
55- } else if (pinch->radius_delta > 0.0) {
56- ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
57- ev_view_zoom_in_smooth (priv->view, increment);
58- }
59-}
60-
61-static void
62-ev_pinch_gesture_end (GtkWindow *window,
63- IdoGestureEvent *event)
64-{
65-}
66-
67-static void
68-ev_drag_gesture_start (GtkWindow *window,
69- IdoGestureEvent *event)
70-{
71- EvWindowPrivate *priv = EV_WINDOW (window)->priv;
72- IdoEventGestureDrag *drag = (IdoEventGestureDrag *)event;
73-
74- priv->drag_start_x = drag->position_x;
75- priv->drag_start_y = drag->position_y;
76-}
77-
78-static void
79-ev_drag_gesture_update (GtkWindow *window,
80- IdoGestureEvent *event)
81-{
82-}
83-
84-static void
85-ev_drag_gesture_end (GtkWindow *window,
86- IdoGestureEvent *event)
87-{
88- EvWindowPrivate *priv = EV_WINDOW (window)->priv;
89- IdoEventGestureDrag *drag = (IdoEventGestureDrag *)event;
90-
91- if (drag->velocity_y >= 1.0 &&
92- drag->position_y > priv->drag_start_y) {
93- ev_window_cmd_go_next_page (NULL, EV_WINDOW (window));
94- } else if (drag->velocity_y <= -1.0 &&
95- drag->position_y < priv->drag_start_y) {
96- ev_window_cmd_go_previous_page (NULL, EV_WINDOW (window));
97- } else if (drag->velocity_x >= 1.0 &&
98- drag->position_x > priv->drag_start_x) {
99- ev_window_cmd_go_next_page (NULL, EV_WINDOW (window));
100- } else if (drag->velocity_x <= -1.0 &&
101- drag->position_x < priv->drag_start_x) {
102- ev_window_cmd_go_previous_page (NULL, EV_WINDOW (window));
103- }
104-}
105-
106-static void
107-ev_rotate_gesture_start (GtkWindow *window,
108- IdoGestureEvent *event)
109-{
110-}
111-
112-static void
113-ev_rotate_gesture_update (GtkWindow *window,
114- IdoGestureEvent *event)
115-{
116-}
117-
118-static void
119-ev_rotate_gesture_end (GtkWindow *window,
120- IdoGestureEvent *event)
121-{
122- IdoEventGestureRotate *rotate = (IdoEventGestureRotate *)event;
123-
124- if (rotate->angle >= 1.0) {
125- ev_window_cmd_edit_rotate_right (NULL, EV_WINDOW (window));
126- } else if (rotate->angle <= -1.0) {
127- ev_window_cmd_edit_rotate_left (NULL, EV_WINDOW (window));
128+ev_gesture_callback (GtkWindow *window,
129+ GripTimeType time_type,
130+ GripGestureEvent *event,
131+ gpointer user_data)
132+{
133+ EvWindowPrivate *priv = EV_WINDOW (window)->priv;
134+
135+ if (time_type == GRIP_TIME_START) {
136+ switch (event->type) {
137+ case GRIP_GESTURE_DRAG: {
138+ GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
139+
140+ priv->drag_start_x = drag->position_x;
141+ priv->drag_start_y = drag->position_y;
142+
143+ break;
144+ }
145+
146+ case GRIP_GESTURE_PINCH: {
147+ GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
148+
149+ priv->pinch_start_x = pinch->focus_x;
150+ priv->pinch_start_y = pinch->focus_y;
151+ priv->pinch_start_radius = pinch->radius;
152+ break;
153+ }
154+
155+ default:
156+ break;
157+ }
158+ } else if (time_type == GRIP_TIME_END) {
159+ switch (event->type) {
160+ case GRIP_GESTURE_DRAG: {
161+ GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
162+
163+ if (drag->velocity_y >= 1.0 &&
164+ drag->position_y > priv->drag_start_y) {
165+ ev_window_cmd_go_next_page (NULL, EV_WINDOW (window));
166+ } else if (drag->velocity_y <= -1.0 &&
167+ drag->position_y < priv->drag_start_y) {
168+ ev_window_cmd_go_previous_page (NULL, EV_WINDOW (window));
169+ } else if (drag->velocity_x >= 1.0 &&
170+ drag->position_x > priv->drag_start_x) {
171+ ev_window_cmd_go_next_page (NULL, EV_WINDOW (window));
172+ } else if (drag->velocity_x <= -1.0 &&
173+ drag->position_x < priv->drag_start_x) {
174+ ev_window_cmd_go_previous_page (NULL, EV_WINDOW (window));
175+ }
176+
177+ break;
178+ }
179+
180+ case GRIP_GESTURE_ROTATE: {
181+ GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
182+
183+ if (rotate->angle >= 1.0) {
184+ ev_window_cmd_edit_rotate_right (NULL, EV_WINDOW (window));
185+ } else if (rotate->angle <= -1.0) {
186+ ev_window_cmd_edit_rotate_left (NULL, EV_WINDOW (window));
187+ }
188+
189+ break;
190+ }
191+
192+ default:
193+ break;
194+ }
195+ } else {
196+ switch (event->type) {
197+ case GRIP_GESTURE_PINCH: {
198+ GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
199+ gdouble increment = pinch->radius_delta * 0.01;
200+
201+ if (increment < 0.0) increment = -increment;
202+ increment += 1.0;
203+
204+ if (pinch->radius_delta < 0.0) {
205+ ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
206+ ev_view_zoom_out_smooth (EV_VIEW (priv->view), (1.0 / increment));
207+ } else if (pinch->radius_delta > 0.0) {
208+ ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
209+ ev_view_zoom_in_smooth (EV_VIEW (priv->view), increment);
210+ }
211+
212+ break;
213+ }
214+
215+ default:
216+ break;
217+ }
218 }
219 }
220
221@@ -5538,36 +5530,33 @@
222 on_window_mapped (GtkWidget *widget)
223 {
224 GtkWindow *window;
225- IdoGestureManager *manager;
226+ GripGestureManager *manager;
227
228 window = GTK_WINDOW (widget);
229
230 if (ev_application_get_gestures_enabled (EV_APP)) {
231- manager = ido_gesture_manager_get ();
232-
233- ido_gesture_manager_register_window (manager,
234- window,
235- IDO_GESTURE_PINCH,
236- 2,
237- ev_pinch_gesture_start,
238- ev_pinch_gesture_update,
239- ev_pinch_gesture_end);
240-
241- ido_gesture_manager_register_window (manager,
242- window,
243- IDO_GESTURE_DRAG,
244- 2,
245- ev_drag_gesture_start,
246- ev_drag_gesture_update,
247- ev_drag_gesture_end);
248-
249- ido_gesture_manager_register_window (manager,
250- window,
251- IDO_GESTURE_ROTATE,
252- 2,
253- ev_rotate_gesture_start,
254- ev_rotate_gesture_update,
255- ev_rotate_gesture_end);
256+ manager = grip_gesture_manager_get ();
257+
258+ grip_gesture_manager_register_window (manager,
259+ window,
260+ GRIP_GESTURE_PINCH,
261+ 2,
262+ ev_gesture_callback,
263+ NULL, NULL);
264+
265+ grip_gesture_manager_register_window (manager,
266+ window,
267+ GRIP_GESTURE_DRAG,
268+ 2,
269+ ev_gesture_callback,
270+ NULL, NULL);
271+
272+ grip_gesture_manager_register_window (manager,
273+ window,
274+ GRIP_GESTURE_ROTATE,
275+ 2,
276+ ev_gesture_callback,
277+ NULL, NULL);
278 }
279 }
280

Subscribers

People subscribed via source and target branches