[gtk+/gesture-fixes: 5/6] gesturerotate: Just return a double in get_angle_delta()



commit 83bb9d10a3372aded8efff434cbe466538f80aa1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 26 14:29:17 2014 +0200

    gesturerotate: Just return a double in get_angle_delta()
    
    Whether the gesture is active or recognized should be checked before in
    callers, or just not used naively.

 demos/gtk-demo/gestures.c |    4 ++--
 gtk/gtkgesturerotate.c    |   20 +++++++-------------
 gtk/gtkgesturerotate.h    |    3 +--
 3 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c
index 77da335..e9f80fc 100644
--- a/demos/gtk-demo/gestures.c
+++ b/demos/gtk-demo/gestures.c
@@ -93,8 +93,8 @@ drawing_area_draw (GtkWidget *widget,
 
       cairo_save (cr);
 
-      if (gtk_gesture_rotate_get_angle_delta (GTK_GESTURE_ROTATE (rotate), &angle))
-        cairo_matrix_rotate (&matrix, angle);
+      angle = gtk_gesture_rotate_get_angle_delta (GTK_GESTURE_ROTATE (rotate));
+      cairo_matrix_rotate (&matrix, angle);
 
       if (gtk_gesture_zoom_get_scale_delta (GTK_GESTURE_ZOOM (zoom), &scale))
         cairo_matrix_scale (&matrix, scale, scale);
diff --git a/gtk/gtkgesturerotate.c b/gtk/gtkgesturerotate.c
index ec8b12a..8675125 100644
--- a/gtk/gtkgesturerotate.c
+++ b/gtk/gtkgesturerotate.c
@@ -196,19 +196,16 @@ gtk_gesture_rotate_new (GtkWidget *widget)
 /**
  * gtk_gesture_rotate_get_angle_delta:
  * @gesture: a #GtkGestureRotate
- * @delta: (out) (transfer none): angle delta
  *
- * If @gesture is active, this function returns %TRUE and fills
- * in @delta with the angle difference in radians since the
- * gesture was first recognized.
+ * If @gesture is active, this function returns the angle difference
+ * in radians since the gesture was first recognized.
  *
- * Returns: %TRUE if @controller is recognizing a rotate gesture
+ * Returns: the angle delta in radians
  *
  * Since: 3.14
  **/
-gboolean
-gtk_gesture_rotate_get_angle_delta (GtkGestureRotate *gesture,
-                                    gdouble          *delta)
+gdouble
+gtk_gesture_rotate_get_angle_delta (GtkGestureRotate *gesture)
 {
   GtkGestureRotatePrivate *priv;
   gdouble angle;
@@ -216,12 +213,9 @@ gtk_gesture_rotate_get_angle_delta (GtkGestureRotate *gesture,
   g_return_val_if_fail (GTK_IS_GESTURE_ROTATE (gesture), FALSE);
 
   if (!_gtk_gesture_rotate_get_angle (gesture, &angle))
-    return FALSE;
+    return 0;
 
   priv = gtk_gesture_rotate_get_instance_private (gesture);
 
-  if (delta)
-    *delta = angle - priv->initial_angle;
-
-  return TRUE;
+  return angle - priv->initial_angle;
 }
diff --git a/gtk/gtkgesturerotate.h b/gtk/gtkgesturerotate.h
index 803355d..4db84e4 100644
--- a/gtk/gtkgesturerotate.h
+++ b/gtk/gtkgesturerotate.h
@@ -46,8 +46,7 @@ GDK_AVAILABLE_IN_3_14
 GtkGesture * gtk_gesture_rotate_new             (GtkWidget        *widget);
 
 GDK_AVAILABLE_IN_3_14
-gboolean     gtk_gesture_rotate_get_angle_delta (GtkGestureRotate *gesture,
-                                                 gdouble          *delta);
+gdouble      gtk_gesture_rotate_get_angle_delta (GtkGestureRotate *gesture);
 
 G_END_DECLS
 


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