diff options
-rw-r--r-- | demos/gtk-demo/gestures.c | 4 | ||||
-rw-r--r-- | gtk/gtkgesture.c | 3 | ||||
-rw-r--r-- | gtk/gtkgestureswipe.c | 6 | ||||
-rw-r--r-- | gtk/gtkgestureswipe.h | 10 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.c | 7 | ||||
-rw-r--r-- | gtk/gtkspinbutton.c | 14 |
6 files changed, 22 insertions, 22 deletions
diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c index 3e520ff51a..f841eeb34f 100644 --- a/demos/gtk-demo/gestures.c +++ b/demos/gtk-demo/gestures.c @@ -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, diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index a90fd70cb9..66bb04fc38 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -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. diff --git a/gtk/gtkgestureswipe.c b/gtk/gtkgestureswipe.c index 15872f8096..83bc65653e 100644 --- a/gtk/gtkgestureswipe.c +++ b/gtk/gtkgestureswipe.c @@ -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); } diff --git a/gtk/gtkgestureswipe.h b/gtk/gtkgestureswipe.h index 1cfbfd773f..330ae7eb69 100644 --- a/gtk/gtkgestureswipe.h +++ b/gtk/gtkgestureswipe.h @@ -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 diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 3ce14b5f84..4f7d8cf7dd 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -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); diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 92e0d2dcc2..9d1b9bd7ff 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -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); |