[eog] Gestures work
- From: Gustavo Noronha Silva <gns src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [eog] Gestures work
- Date: Thu, 5 Nov 2009 17:29:22 +0000 (UTC)
commit 3ab0900706bb808446014f45e7ec182744c17ec5
Author: Gustavo Noronha Silva <kov debian org>
Date: Thu Nov 5 09:40:55 2009 -0200
Gestures work
configure.ac | 5 ++-
src/eog-clutter-view.c | 36 +++++++++++++++++++++++++++++++++++
src/eog-window.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9979ec0..223b213 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,12 +237,13 @@ have_clutter=no
if test "x$with_clutter" != "xno"; then
PKG_CHECK_MODULES(CLUTTER,
clutter-1.0 >= $CLUTTER_REQUIRED dnl
- clutter-gtk-0.10,
+ clutter-gtk-0.10
+ clutter-gesture,
have_clutter=yes, have_clutter=no)
fi
if test "x$have_clutter" = "xyes"; then
AC_DEFINE(WITH_CLUTTER_BACKEND, 1, [Clutter backend.])
- EOG_MODULES="$EOG_MODULES clutter-1.0 >= $CLUTTER_REQUIRED clutter-gtk-0.10"
+ EOG_MODULES="$EOG_MODULES clutter-1.0 >= $CLUTTER_REQUIRED clutter-gtk-0.10 clutter-gesture"
fi
AM_CONDITIONAL([WITH_CLUTTER_BACKEND], [test "x$have_clutter" = "xyes"])
diff --git a/src/eog-clutter-view.c b/src/eog-clutter-view.c
index 1b30109..3ec1fc1 100644
--- a/src/eog-clutter-view.c
+++ b/src/eog-clutter-view.c
@@ -20,6 +20,7 @@
*/
#include <clutter/clutter.h>
+#include <clutter-gesture/clutter-gesture.h>
#include <clutter-gtk/clutter-gtk.h>
#include "eog-clutter-view.h"
@@ -134,6 +135,29 @@ eog_clutter_view_iface_init (EogViewClass *iface)
}
static void
+eog_clutter_view_gesture_cb (ClutterGesture *gesture,
+ ClutterGestureEvent *event,
+ gpointer data)
+{
+ EogView *view = EOG_VIEW (data);
+
+ if (event->type == GESTURE_SLIDE) {
+ ClutterGestureSlideEvent *slide = (ClutterGestureSlideEvent*)event;
+
+ switch (slide->direction) {
+ case 3:
+ g_signal_emit_by_name (view, "next_image", 0);
+ break;
+ case 4:
+ g_signal_emit_by_name (view, "previous_image", 0);
+ break;
+ default:
+ g_debug ("DIRECTION: %d", slide->direction);
+ }
+ }
+}
+
+static void
eog_clutter_view_init (EogClutterView *clutter_view)
{
EogClutterViewPrivate *priv;
@@ -285,6 +309,7 @@ eog_clutter_view_set_image (EogView *view, EogImage *image)
EogClutterView *clutter_view;
EogClutterViewPrivate *priv;
GdkPixbuf *pixbuf;
+ ClutterGesture *gesture;
GError *error = NULL;
g_return_if_fail (EOG_IS_CLUTTER_VIEW (view));
@@ -325,9 +350,20 @@ eog_clutter_view_set_image (EogView *view, EogImage *image)
eog_clutter_view_set_zoom_fit (clutter_view);
eog_clutter_view_place_texture (clutter_view, CLUTTER_TEXTURE (priv->texture_in));
+ clutter_actor_set_reactive (priv->texture_in, TRUE);
+
clutter_behaviour_apply (priv->behaviour_in, priv->texture_in);
clutter_actor_set_opacity (priv->texture_in, 0);
+ gesture = clutter_gesture_new (CLUTTER_ACTOR (priv->texture_in));
+ clutter_gesture_set_gesture_mask (gesture, priv->texture_in,
+ GESTURE_MASK_SLIDE | GESTURE_MASK_HOLD);
+
+ g_signal_connect (gesture, "gesture-slide-event",
+ G_CALLBACK (eog_clutter_view_gesture_cb), view);
+ g_signal_connect (gesture, "gesture-hold-event",
+ G_CALLBACK (eog_clutter_view_gesture_cb), view);
+
clutter_actor_show (priv->texture_in);
}
diff --git a/src/eog-window.c b/src/eog-window.c
index d3799ad..15c88b4 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -1726,6 +1726,44 @@ view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
}
static void
+eog_window_activate_action (EogWindow *window, gchar *action_name)
+{
+ EogWindowPrivate *priv;
+ GtkAction *action;
+
+ priv = window->priv;
+
+ action = gtk_action_group_get_action (priv->actions_collection,
+ action_name);
+
+ gtk_action_activate (action);
+}
+
+static void
+next_image_cb (GtkWidget *widget, gpointer user_data)
+{
+ EogWindow *window;
+
+ g_return_if_fail (EOG_IS_WINDOW (user_data));
+
+ window = EOG_WINDOW (user_data);
+
+ eog_window_activate_action (window, "GoNext");
+}
+
+static void
+previous_image_cb (GtkWidget *widget, gpointer user_data)
+{
+ EogWindow *window;
+
+ g_return_if_fail (EOG_IS_WINDOW (user_data));
+
+ window = EOG_WINDOW (user_data);
+
+ eog_window_activate_action (window, "GoPrevious");
+}
+
+static void
eog_window_open_recent_cb (GtkAction *action, EogWindow *window)
{
GtkRecentInfo *info;
@@ -4264,11 +4302,22 @@ eog_window_construct_ui (EogWindow *window)
priv->view = eog_scroll_view_new ();
#endif
gtk_widget_set_size_request (GTK_WIDGET (priv->view), 100, 100);
+
g_signal_connect (G_OBJECT (priv->view),
"zoom_changed",
G_CALLBACK (view_zoom_changed_cb),
window);
+ g_signal_connect (G_OBJECT (priv->view),
+ "next_image",
+ G_CALLBACK (next_image_cb),
+ window);
+
+ g_signal_connect (G_OBJECT (priv->view),
+ "previous_image",
+ G_CALLBACK (previous_image_cb),
+ window);
+
view_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ViewPopup");
eog_view_set_popup (EOG_VIEW (priv->view),
GTK_MENU (view_popup));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]