[gtk+/wip/baedert/gtkimageview: 164/205] Set State to DENIED in gesture ::begin



commit 7a141968720aef3d0fb1b858d0c838a63c7ca80c
Author: Timm Bäder <mail baedert org>
Date:   Mon Jan 18 19:17:49 2016 +0100

    Set State to DENIED in gesture ::begin

 gtk/gtkimageview.c |   53 +++++++++++++++++++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkimageview.c b/gtk/gtkimageview.c
index a497c4b..a275339 100644
--- a/gtk/gtkimageview.c
+++ b/gtk/gtkimageview.c
@@ -375,12 +375,6 @@ gesture_angle_changed_cb (GtkGestureRotate *gesture,
   State old_state;
   double new_angle;
 
-  if (!priv->rotate_gesture_enabled)
-    {
-      gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
-      return;
-    }
-
   if (!priv->in_rotate)
     {
       priv->in_rotate = TRUE;
@@ -664,12 +658,6 @@ gesture_scale_changed_cb (GtkGestureZoom *gesture,
   State state;
   double new_scale;
 
-  if (!priv->rotate_gesture_enabled)
-    {
-      gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
-      return;
-    }
-
   if (!priv->in_zoom)
     {
       priv->in_zoom = TRUE;
@@ -695,12 +683,19 @@ gesture_scale_changed_cb (GtkGestureZoom *gesture,
 }
 
 static void
-gesture_begin_cb (GtkGesture       *gesture,
-                  GdkEventSequence *sequence,
-                  gpointer          user_data)
+gesture_rotate_begin_cb (GtkGesture       *gesture,
+                         GdkEventSequence *sequence,
+                         gpointer          user_data)
 {
   GtkImageViewPrivate *priv = gtk_image_view_get_instance_private (user_data);
 
+  if (!priv->rotate_gesture_enabled)
+    {
+      gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
+      return;
+    }
+
+
   if (priv->anchor_x == -1 && priv->anchor_y == -1)
     {
       gtk_gesture_get_bounding_box_center (gesture,
@@ -709,6 +704,30 @@ gesture_begin_cb (GtkGesture       *gesture,
     }
 }
 
+static void
+gesture_zoom_begin_cb (GtkGesture       *gesture,
+                       GdkEventSequence *sequence,
+                       gpointer          user_data)
+{
+  GtkImageViewPrivate *priv = gtk_image_view_get_instance_private (user_data);
+
+  if (!priv->zoom_gesture_enabled)
+    {
+      gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
+      return;
+    }
+
+
+  if (priv->anchor_x == -1 && priv->anchor_y == -1)
+    {
+      gtk_gesture_get_bounding_box_center (gesture,
+                                           &priv->anchor_x,
+                                           &priv->anchor_y);
+    }
+}
+
+
+
 
 static void
 gtk_image_view_init (GtkImageView *image_view)
@@ -733,13 +752,13 @@ gtk_image_view_init (GtkImageView *image_view)
   gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->rotate_gesture),
                                               GTK_PHASE_CAPTURE);
   g_signal_connect (priv->rotate_gesture, "angle-changed", (GCallback)gesture_angle_changed_cb, image_view);
-  g_signal_connect (priv->rotate_gesture, "begin", (GCallback)gesture_begin_cb, image_view);
+  g_signal_connect (priv->rotate_gesture, "begin", (GCallback)gesture_rotate_begin_cb, image_view);
   g_signal_connect (priv->rotate_gesture, "end", (GCallback)gesture_rotate_end_cb, image_view);
   g_signal_connect (priv->rotate_gesture, "cancel", (GCallback)gesture_rotate_cancel_cb, image_view);
 
   priv->zoom_gesture = gtk_gesture_zoom_new (widget);
   g_signal_connect (priv->zoom_gesture, "scale-changed", (GCallback)gesture_scale_changed_cb, image_view);
-  g_signal_connect (priv->zoom_gesture, "begin", (GCallback)gesture_begin_cb, image_view);
+  g_signal_connect (priv->zoom_gesture, "begin", (GCallback)gesture_zoom_begin_cb, image_view);
   g_signal_connect (priv->zoom_gesture, "end", (GCallback)gesture_zoom_end_cb, image_view);
   g_signal_connect (priv->zoom_gesture, "cancel", (GCallback)gesture_zoom_cancel_cb, image_view);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]