forked from AuroraMiddleware/gtk
swipegesture: Port to new API model
This commit is contained in:
parent
91efa37fcb
commit
66223aaa08
@ -157,12 +157,12 @@ do_gestures (GtkWidget *do_widget)
|
||||
NULL, NULL);
|
||||
|
||||
/* Swipe */
|
||||
gesture = gtk_gesture_swipe_new (drawing_area);
|
||||
gesture = gtk_gesture_swipe_new ();
|
||||
g_signal_connect (gesture, "swipe",
|
||||
G_CALLBACK (swipe_gesture_swept), drawing_area);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
|
||||
GTK_PHASE_BUBBLE);
|
||||
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
|
||||
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
/* 3fg swipe for touchpads */
|
||||
gesture = g_object_new (GTK_TYPE_GESTURE_SWIPE,
|
||||
|
@ -1472,6 +1472,9 @@ _gtk_gesture_get_group_link (GtkGesture *gesture)
|
||||
* Adds @gesture to the same group than @group_gesture. Gestures
|
||||
* are by default isolated in their own groups.
|
||||
*
|
||||
* Both gestures must have been added to the same widget before they
|
||||
* can be grouped.
|
||||
*
|
||||
* When gestures are grouped, the state of #GdkEventSequences
|
||||
* is kept in sync for all of those, so calling gtk_gesture_set_sequence_state(),
|
||||
* on one will transfer the same value to the others.
|
||||
|
@ -252,19 +252,15 @@ gtk_gesture_swipe_init (GtkGestureSwipe *gesture)
|
||||
|
||||
/**
|
||||
* gtk_gesture_swipe_new:
|
||||
* @widget: a #GtkWidget
|
||||
*
|
||||
* Returns a newly created #GtkGesture that recognizes swipes.
|
||||
*
|
||||
* Returns: a newly created #GtkGestureSwipe
|
||||
**/
|
||||
GtkGesture *
|
||||
gtk_gesture_swipe_new (GtkWidget *widget)
|
||||
gtk_gesture_swipe_new (void)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_GESTURE_SWIPE,
|
||||
"widget", widget,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -40,15 +40,15 @@ typedef struct _GtkGestureSwipe GtkGestureSwipe;
|
||||
typedef struct _GtkGestureSwipeClass GtkGestureSwipeClass;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_gesture_swipe_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_gesture_swipe_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkGesture * gtk_gesture_swipe_new (GtkWidget *widget);
|
||||
GtkGesture * gtk_gesture_swipe_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_gesture_swipe_get_velocity (GtkGestureSwipe *gesture,
|
||||
gdouble *velocity_x,
|
||||
gdouble *velocity_y);
|
||||
gboolean gtk_gesture_swipe_get_velocity (GtkGestureSwipe *gesture,
|
||||
gdouble *velocity_x,
|
||||
gdouble *velocity_y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -1935,12 +1935,14 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
|
||||
gtk_gesture_group (priv->pan_gesture, priv->drag_gesture);
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->pan_gesture), TRUE);
|
||||
|
||||
priv->swipe_gesture = gtk_gesture_swipe_new (widget);
|
||||
gtk_gesture_group (priv->swipe_gesture, priv->drag_gesture);
|
||||
priv->swipe_gesture = gtk_gesture_swipe_new ();
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->swipe_gesture), TRUE);
|
||||
g_signal_connect_swapped (priv->swipe_gesture, "swipe",
|
||||
G_CALLBACK (scrolled_window_swipe_cb),
|
||||
scrolled_window);
|
||||
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->swipe_gesture));
|
||||
gtk_gesture_group (priv->swipe_gesture, priv->drag_gesture);
|
||||
|
||||
priv->long_press_gesture = gtk_gesture_long_press_new (widget);
|
||||
gtk_gesture_group (priv->long_press_gesture, priv->drag_gesture);
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->long_press_gesture), TRUE);
|
||||
@ -2613,7 +2615,6 @@ gtk_scrolled_window_finalize (GObject *object)
|
||||
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
|
||||
|
||||
g_clear_object (&priv->drag_gesture);
|
||||
g_clear_object (&priv->swipe_gesture);
|
||||
g_clear_object (&priv->long_press_gesture);
|
||||
g_clear_object (&priv->pan_gesture);
|
||||
g_clear_object (&priv->scroll_controller);
|
||||
|
@ -202,7 +202,6 @@ struct _GtkSpinButtonPrivate
|
||||
|
||||
GtkOrientation orientation;
|
||||
|
||||
GtkGesture *swipe_gesture;
|
||||
GtkEventController *scroll_controller;
|
||||
|
||||
guint digits : 10;
|
||||
@ -831,6 +830,7 @@ static void
|
||||
gtk_spin_button_init (GtkSpinButton *spin_button)
|
||||
{
|
||||
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
|
||||
GtkGesture *gesture;
|
||||
|
||||
gtk_widget_set_has_surface (GTK_WIDGET (spin_button), FALSE);
|
||||
|
||||
@ -890,14 +890,15 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
|
||||
|
||||
gtk_spin_button_set_adjustment (spin_button, NULL);
|
||||
|
||||
priv->swipe_gesture = gtk_gesture_swipe_new (GTK_WIDGET (spin_button));
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->swipe_gesture), TRUE);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->swipe_gesture),
|
||||
gesture = gtk_gesture_swipe_new ();
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
|
||||
GTK_PHASE_CAPTURE);
|
||||
g_signal_connect (priv->swipe_gesture, "begin",
|
||||
g_signal_connect (gesture, "begin",
|
||||
G_CALLBACK (swipe_gesture_begin), spin_button);
|
||||
g_signal_connect (priv->swipe_gesture, "update",
|
||||
g_signal_connect (gesture, "update",
|
||||
G_CALLBACK (swipe_gesture_update), spin_button);
|
||||
gtk_widget_add_controller (GTK_WIDGET (spin_button), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
priv->scroll_controller =
|
||||
gtk_event_controller_scroll_new (GTK_WIDGET (spin_button),
|
||||
@ -916,7 +917,6 @@ gtk_spin_button_finalize (GObject *object)
|
||||
gtk_spin_button_unset_adjustment (spin_button);
|
||||
|
||||
g_object_unref (priv->scroll_controller);
|
||||
g_object_unref (priv->swipe_gesture);
|
||||
g_object_unref (priv->up_click_gesture);
|
||||
g_object_unref (priv->down_click_gesture);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user