[clutter/clutter-1.18] gesture: Make threshold-trigger-edge public



commit ed2fdf85f6f30452531722dbfd045298b6359458
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Dec 5 14:04:10 2013 +0000

    gesture: Make threshold-trigger-edge public
    
    When the threshold-trigger-edge property was introduced in
    GestureAction, it was late in the cycle and I elected to keep it
    private, given the fact that nobody was subclassing GestureAction
    outside of Clutter itself.
    
    These days, people are experimenting more with the GestureAction API, so
    they will need access to the various knobs that control the class
    default behaviour.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710227

 clutter/clutter-enums.h                    |   23 ++++++
 clutter/clutter-gesture-action-private.h   |   28 -------
 clutter/clutter-gesture-action.c           |  107 +++++++++++++++++++---------
 clutter/clutter-gesture-action.h           |    6 ++
 clutter/clutter.symbols                    |    3 +
 doc/reference/clutter/clutter-sections.txt |    2 +
 6 files changed, 107 insertions(+), 62 deletions(-)
---
diff --git a/clutter/clutter-enums.h b/clutter/clutter-enums.h
index f2a6662..a3cd7c7 100644
--- a/clutter/clutter-enums.h
+++ b/clutter/clutter-enums.h
@@ -1357,6 +1357,29 @@ typedef enum { /*< prefix=CLUTTER_ZOOM >*/
   CLUTTER_ZOOM_BOTH
 } ClutterZoomAxis;
 
+/**
+ * ClutterGestureTriggerEdge:
+ * @CLUTTER_GESTURE_TRIGGER_EDGE_NONE: Tell #ClutterGestureAction that
+ * the gesture must begin immediately and there's no drag limit that
+ * will cause its cancellation;
+ * @CLUTTER_GESTURE_TRIGGER_EDGE_AFTER: Tell #ClutterGestureAction that
+ * it needs to wait until the drag threshold has been exceeded before
+ * considering that the gesture has begun;
+ * @CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE: Tell #ClutterGestureAction that
+ * the gesture must begin immediately and that it must be cancelled
+ * once the drag exceed the configured threshold.
+ *
+ * Enum passed to the clutter_gesture_action_set_threshold_trigger_edge()
+ * function.
+ *
+ * Since: 1.18
+ */
+typedef enum {
+  CLUTTER_GESTURE_TRIGGER_EDGE_NONE  = 0,
+  CLUTTER_GESTURE_TRIGGER_EDGE_AFTER,
+  CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE
+} ClutterGestureTriggerEdge;
+
 G_END_DECLS
 
 #endif /* __CLUTTER_ENUMS_H__ */
diff --git a/clutter/clutter-gesture-action-private.h b/clutter/clutter-gesture-action-private.h
index cb6440b..cd804ab 100644
--- a/clutter/clutter-gesture-action-private.h
+++ b/clutter/clutter-gesture-action-private.h
@@ -26,34 +26,6 @@
 
 G_BEGIN_DECLS
 
-/*< private >
- * ClutterGestureTriggerEdge:
- * @CLUTTER_GESTURE_TRIGGER_EDGE_NONE: Tell #ClutterGestureAction that
- * the gesture must begin immediately and there's no drag limit that
- * will cause its cancellation;
- * @CLUTTER_GESTURE_TRIGGER_EDGE_AFTER: Tell #ClutterGestureAction that
- * it needs to wait until the drag threshold has been exceeded before
- * considering that the gesture has begun;
- * @CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE: Tell #ClutterGestureAction that
- * the gesture must begin immediately and that it must be cancelled
- * once the drag exceed the configured threshold.
- *
- * Enum passed to the clutter_gesture_action_set_threshold_trigger_edge()
- * function.
- */
-typedef enum
-{
-  CLUTTER_GESTURE_TRIGGER_EDGE_NONE  = 0,
-  CLUTTER_GESTURE_TRIGGER_EDGE_AFTER,
-  CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE
-} ClutterGestureTriggerEdge;
-
-G_GNUC_INTERNAL
-void                            clutter_gesture_action_set_threshold_trigger_edge       
(ClutterGestureAction      *action,
-                                                                                         
ClutterGestureTriggerEdge  edge);
-G_GNUC_INTERNAL
-ClutterGestureTriggerEdge       clutter_gesture_action_get_threshold_trigger_egde       
(ClutterGestureAction      *action);
-
 G_END_DECLS
 
 #endif /* __CLUTTER_GESTURE_ACTION_PRIVATE_H__ */
diff --git a/clutter/clutter-gesture-action.c b/clutter/clutter-gesture-action.c
index 5794152..3e8b50c 100644
--- a/clutter/clutter-gesture-action.c
+++ b/clutter/clutter-gesture-action.c
@@ -133,6 +133,7 @@ enum
   PROP_0,
 
   PROP_N_TOUCH_POINTS,
+  PROP_THRESHOLD_TRIGGER_EDGE,
 
   PROP_LAST
 };
@@ -552,40 +553,6 @@ default_event_handler (ClutterGestureAction *action,
   return TRUE;
 }
 
-
-/*< private >
- * clutter_gesture_action_set_threshold_trigger_edge:
- * @action: a #ClutterGestureAction
- * @edge: the %ClutterGestureTriggerEdge
- *
- * Sets the edge trigger for the gesture drag threshold, if any.
- *
- * This function can be called by #ClutterGestureAction subclasses that needs
- * to change the %CLUTTER_GESTURE_TRIGGER_EDGE_AFTER default.
- */
-void
-clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction      *action,
-                                                   ClutterGestureTriggerEdge  edge)
-{
-  if (action->priv->edge != edge)
-    action->priv->edge = edge;
-}
-
-/*< private >
- * clutter_gesture_action_get_threshold_trigger_egde:
- * @action: a #ClutterGestureAction
- *
- * Retrieves the edge trigger of the gesture @action, as set using
- * clutter_gesture_action_set_threshold_trigger_edge().
- *
- * Return value: the edge trigger
- */
-ClutterGestureTriggerEdge
-clutter_gesture_action_get_threshold_trigger_egde (ClutterGestureAction *action)
-{
-  return action->priv->edge;
-}
-
 static void
 clutter_gesture_action_set_property (GObject      *gobject,
                                      guint         prop_id,
@@ -600,6 +567,10 @@ clutter_gesture_action_set_property (GObject      *gobject,
       clutter_gesture_action_set_n_touch_points (self, g_value_get_int (value));
       break;
 
+    case PROP_THRESHOLD_TRIGGER_EDGE:
+      clutter_gesture_action_set_threshold_trigger_edge (self, g_value_get_enum (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -620,6 +591,10 @@ clutter_gesture_action_get_property (GObject    *gobject,
       g_value_set_int (value, self->priv->requested_nb_points);
       break;
 
+    case PROP_THRESHOLD_TRIGGER_EDGE:
+      g_value_set_enum (value, self->priv->edge);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -666,6 +641,24 @@ clutter_gesture_action_class_init (ClutterGestureActionClass *klass)
                       1, G_MAXINT, 1,
                       CLUTTER_PARAM_READWRITE);
 
+  /**
+   * ClutterGestureAction:threshold-trigger-edge:
+   *
+   * The trigger edge to be used by the action to either emit the
+   * #ClutterGestureAction::gesture-begin signal or to emit the
+   * #ClutterGestureAction::gesture-cancel signal.
+   *
+   * Since: 1.18
+   */
+  gesture_props[PROP_THRESHOLD_TRIGGER_EDGE] =
+    g_param_spec_enum ("threshold-trigger-edge",
+                       P_("Threshold Trigger Edge"),
+                       P_("The trigger edge used by the action"),
+                       CLUTTER_TYPE_GESTURE_TRIGGER_EDGE,
+                       CLUTTER_GESTURE_TRIGGER_EDGE_NONE,
+                       CLUTTER_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT_ONLY);
+
   g_object_class_install_properties (gobject_class,
                                      PROP_LAST,
                                      gesture_props);
@@ -1161,3 +1154,49 @@ clutter_gesture_action_cancel (ClutterGestureAction *action)
 
   cancel_gesture (action);
 }
+
+/**
+ * clutter_gesture_action_set_threshold_trigger_edge:
+ * @action: a #ClutterGestureAction
+ * @edge: the %ClutterGestureTriggerEdge
+ *
+ * Sets the edge trigger for the gesture drag threshold, if any.
+ *
+ * This function should only be called by sub-classes of
+ * #ClutterGestureAction during their construction phase.
+ *
+ * Since: 1.18
+ */
+void
+clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction      *action,
+                                                   ClutterGestureTriggerEdge  edge)
+{
+  g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
+
+  if (action->priv->edge == edge)
+    return;
+
+  action->priv->edge = edge;
+
+  g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_EDGE]);
+}
+
+/**
+ * clutter_gesture_action_get_threshold_trigger_egde:
+ * @action: a #ClutterGestureAction
+ *
+ * Retrieves the edge trigger of the gesture @action, as set using
+ * clutter_gesture_action_set_threshold_trigger_edge().
+ *
+ * Return value: the edge trigger
+ *
+ * Since: 1.18
+ */
+ClutterGestureTriggerEdge
+clutter_gesture_action_get_threshold_trigger_egde (ClutterGestureAction *action)
+{
+  g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action),
+                        CLUTTER_GESTURE_TRIGGER_EDGE_NONE);
+
+  return action->priv->edge;
+}
diff --git a/clutter/clutter-gesture-action.h b/clutter/clutter-gesture-action.h
index ab38b4b..9660c3e 100644
--- a/clutter/clutter-gesture-action.h
+++ b/clutter/clutter-gesture-action.h
@@ -149,6 +149,12 @@ const ClutterEvent *   clutter_gesture_action_get_last_event       (ClutterGestu
 CLUTTER_AVAILABLE_IN_1_12
 void                   clutter_gesture_action_cancel               (ClutterGestureAction *action);
 
+CLUTTER_AVAILABLE_IN_1_18
+void                            clutter_gesture_action_set_threshold_trigger_edge       
(ClutterGestureAction      *action,
+                                                                                         
ClutterGestureTriggerEdge  edge);
+CLUTTER_AVAILABLE_IN_1_18
+ClutterGestureTriggerEdge       clutter_gesture_action_get_threshold_trigger_egde       
(ClutterGestureAction      *action);
+
 G_END_DECLS
 
 #endif /* __CLUTTER_GESTURE_ACTION_H__ */
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 86d7afa..0c54a7b 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -750,10 +750,13 @@ clutter_gesture_action_get_n_touch_points
 clutter_gesture_action_get_press_coords
 clutter_gesture_action_get_release_coords
 clutter_gesture_action_get_sequence
+clutter_gesture_action_get_threshold_trigger_egde
 clutter_gesture_action_get_type
 clutter_gesture_action_get_velocity
 clutter_gesture_action_set_n_touch_points
+clutter_gesture_action_set_threshold_trigger_edge
 clutter_gesture_action_new
+clutter_gesture_trigger_edge_get_type
 clutter_get_accessibility_enabled
 clutter_get_actor_by_gid
 clutter_get_current_event
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index d3c7f5b..8550d34 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -2989,6 +2989,8 @@ clutter_gesture_action_set_n_touch_points
 clutter_gesture_action_get_n_current_points
 clutter_gesture_action_get_sequence
 clutter_gesture_action_get_device
+clutter_gesture_action_set_threshold_trigger_edge
+clutter_gesture_action_get_threshold_trigger_egde
 clutter_gesture_action_cancel
 <SUBSECTION Standard>
 CLUTTER_GESTURE_ACTION


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