diff options
-rw-r--r-- | demos/gtk-demo/fontplane.c | 10 | ||||
-rw-r--r-- | demos/gtk-demo/fontplane.h | 1 | ||||
-rw-r--r-- | demos/gtk-demo/gestures.c | 4 | ||||
-rw-r--r-- | gtk/gtkcolorplane.c | 10 | ||||
-rw-r--r-- | gtk/gtkcolorscale.c | 21 | ||||
-rw-r--r-- | gtk/gtkcolorswatch.c | 9 | ||||
-rw-r--r-- | gtk/gtkemojicompletion.c | 10 | ||||
-rw-r--r-- | gtk/gtkgesturelongpress.c | 6 | ||||
-rw-r--r-- | gtk/gtkgesturelongpress.h | 2 | ||||
-rw-r--r-- | gtk/gtkplacessidebar.c | 10 | ||||
-rw-r--r-- | gtk/gtkrange.c | 12 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.c | 6 |
12 files changed, 42 insertions, 59 deletions
diff --git a/demos/gtk-demo/fontplane.c b/demos/gtk-demo/fontplane.c index ce81ecce95..6f31c2d8c5 100644 --- a/demos/gtk-demo/fontplane.c +++ b/demos/gtk-demo/fontplane.c @@ -207,6 +207,8 @@ plane_drag_gesture_end (GtkGestureDrag *gesture, static void gtk_font_plane_init (GtkFontPlane *plane) { + GtkGesture *gesture; + gtk_widget_set_has_surface (GTK_WIDGET (plane), FALSE); gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE); @@ -219,11 +221,12 @@ gtk_font_plane_init (GtkFontPlane *plane) G_CALLBACK (plane_drag_gesture_end), plane); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (plane->drag_gesture), 0); - plane->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (plane)); - g_signal_connect (plane->long_press_gesture, "pressed", + gesture = gtk_gesture_long_press_new (); + g_signal_connect (gesture, "pressed", G_CALLBACK (hold_action), plane); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (plane->long_press_gesture), + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE); + gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture)); } static void @@ -235,7 +238,6 @@ plane_finalize (GObject *object) g_clear_object (&plane->width_adj); g_clear_object (&plane->drag_gesture); - g_clear_object (&plane->long_press_gesture); G_OBJECT_CLASS (gtk_font_plane_parent_class)->finalize (object); } diff --git a/demos/gtk-demo/fontplane.h b/demos/gtk-demo/fontplane.h index e9983a1194..73b310a917 100644 --- a/demos/gtk-demo/fontplane.h +++ b/demos/gtk-demo/fontplane.h @@ -41,7 +41,6 @@ struct _GtkFontPlane GtkAdjustment *width_adj; GtkGesture *drag_gesture; - GtkGesture *long_press_gesture; }; struct _GtkFontPlaneClass diff --git a/demos/gtk-demo/gestures.c b/demos/gtk-demo/gestures.c index f841eeb34f..73630a2ef6 100644 --- a/demos/gtk-demo/gestures.c +++ b/demos/gtk-demo/gestures.c @@ -178,14 +178,14 @@ do_gestures (GtkWidget *do_widget) g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture); /* Long press */ - gesture = gtk_gesture_long_press_new (drawing_area); + gesture = gtk_gesture_long_press_new (); g_signal_connect (gesture, "pressed", G_CALLBACK (long_press_gesture_pressed), drawing_area); g_signal_connect (gesture, "end", G_CALLBACK (long_press_gesture_end), 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)); /* Rotate */ rotate = gesture = gtk_gesture_rotate_new (); diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c index 7162d7ebdf..30d0a80056 100644 --- a/gtk/gtkcolorplane.c +++ b/gtk/gtkcolorplane.c @@ -38,7 +38,6 @@ struct _GtkColorPlanePrivate GdkTexture *texture; GtkGesture *drag_gesture; - GtkGesture *long_press_gesture; GtkEventController *key_controller; }; @@ -394,6 +393,7 @@ plane_drag_gesture_end (GtkGestureDrag *gesture, static void gtk_color_plane_init (GtkColorPlane *plane) { + GtkGesture *gesture; AtkObject *atk_obj; plane->priv = gtk_color_plane_get_instance_private (plane); @@ -417,11 +417,12 @@ gtk_color_plane_init (GtkColorPlane *plane) G_CALLBACK (plane_drag_gesture_end), plane); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (plane->priv->drag_gesture), 0); - plane->priv->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (plane)); - g_signal_connect (plane->priv->long_press_gesture, "pressed", + gesture = gtk_gesture_long_press_new (); + g_signal_connect (gesture, "pressed", G_CALLBACK (hold_action), plane); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (plane->priv->long_press_gesture), + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE); + gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture)); plane->priv->key_controller = gtk_event_controller_key_new (GTK_WIDGET (plane)); g_signal_connect (plane->priv->key_controller, "key-pressed", @@ -440,7 +441,6 @@ plane_finalize (GObject *object) g_clear_object (&plane->priv->v_adj); g_clear_object (&plane->priv->drag_gesture); - g_clear_object (&plane->priv->long_press_gesture); g_clear_object (&plane->priv->key_controller); G_OBJECT_CLASS (gtk_color_plane_parent_class)->finalize (object); diff --git a/gtk/gtkcolorscale.c b/gtk/gtkcolorscale.c index 1556259e08..3f52951765 100644 --- a/gtk/gtkcolorscale.c +++ b/gtk/gtkcolorscale.c @@ -36,8 +36,6 @@ struct _GtkColorScalePrivate { GdkRGBA color; GtkColorScaleType type; - - GtkGesture *long_press_gesture; }; enum @@ -163,30 +161,22 @@ static void gtk_color_scale_init (GtkColorScale *scale) { GtkStyleContext *context; + GtkGesture *gesture; scale->priv = gtk_color_scale_get_instance_private (scale); - scale->priv->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (scale)); - g_signal_connect (scale->priv->long_press_gesture, "pressed", + gesture = gtk_gesture_long_press_new (); + g_signal_connect (gesture, "pressed", G_CALLBACK (hold_action), scale); - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (scale->priv->long_press_gesture), + gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_TARGET); + gtk_widget_add_controller (GTK_WIDGET (scale), GTK_EVENT_CONTROLLER (gesture)); context = gtk_widget_get_style_context (GTK_WIDGET (scale)); gtk_style_context_add_class (context, "color"); } static void -scale_finalize (GObject *object) -{ - GtkColorScale *scale = GTK_COLOR_SCALE (object); - - g_clear_object (&scale->priv->long_press_gesture); - - G_OBJECT_CLASS (gtk_color_scale_parent_class)->finalize (object); -} - -static void scale_get_property (GObject *object, guint prop_id, GValue *value, @@ -259,7 +249,6 @@ gtk_color_scale_class_init (GtkColorScaleClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - object_class->finalize = scale_finalize; object_class->get_property = scale_get_property; object_class->set_property = scale_set_property; diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 7b2765b76e..7993dab50b 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -65,7 +65,6 @@ struct _GtkColorSwatchPrivate guint selectable : 1; guint has_menu : 1; - GtkGesture *long_press_gesture; GtkEventController *key_controller; GtkWidget *overlay_widget; @@ -503,7 +502,6 @@ swatch_dispose (GObject *object) swatch->priv->popover = NULL; } - g_clear_object (&swatch->priv->long_press_gesture); g_clear_object (&swatch->priv->key_controller); G_OBJECT_CLASS (gtk_color_swatch_parent_class)->dispose (object); @@ -570,11 +568,12 @@ gtk_color_swatch_init (GtkColorSwatch *swatch) gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE); gtk_widget_set_has_surface (GTK_WIDGET (swatch), FALSE); - swatch->priv->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (swatch)); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (swatch->priv->long_press_gesture), + gesture = gtk_gesture_long_press_new (); + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE); - g_signal_connect (swatch->priv->long_press_gesture, "pressed", + g_signal_connect (gesture, "pressed", G_CALLBACK (hold_action), swatch); + gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (gesture)); gesture = gtk_gesture_multi_press_new (); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c index f1868c7e2a..c8a1be12c4 100644 --- a/gtk/gtkemojicompletion.c +++ b/gtk/gtkemojicompletion.c @@ -47,8 +47,6 @@ struct _GtkEmojiCompletion GtkWidget *active_variation; GVariant *data; - - GtkGesture *long_press; }; struct _GtkEmojiCompletionClass { @@ -76,8 +74,6 @@ gtk_emoji_completion_finalize (GObject *object) g_free (completion->text); g_variant_unref (completion->data); - g_clear_object (&completion->long_press); - G_OBJECT_CLASS (gtk_emoji_completion_parent_class)->finalize (object); } @@ -625,14 +621,16 @@ static void gtk_emoji_completion_init (GtkEmojiCompletion *completion) { g_autoptr(GBytes) bytes = NULL; + GtkGesture *long_press; gtk_widget_init_template (GTK_WIDGET (completion)); bytes = g_resources_lookup_data ("/org/gtk/libgtk/emoji/emoji.data", 0, NULL); completion->data = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(auss)"), bytes, TRUE)); - completion->long_press = gtk_gesture_long_press_new (completion->list); - g_signal_connect (completion->long_press, "pressed", G_CALLBACK (long_pressed_cb), completion); + long_press = gtk_gesture_long_press_new (); + g_signal_connect (long_press, "pressed", G_CALLBACK (long_pressed_cb), completion); + gtk_widget_add_controller (completion->list, GTK_EVENT_CONTROLLER (long_press)); } static void diff --git a/gtk/gtkgesturelongpress.c b/gtk/gtkgesturelongpress.c index 68f2813139..f16bc1da90 100644 --- a/gtk/gtkgesturelongpress.c +++ b/gtk/gtkgesturelongpress.c @@ -323,18 +323,14 @@ gtk_gesture_long_press_class_init (GtkGestureLongPressClass *klass) /** * gtk_gesture_long_press_new: - * @widget: a #GtkWidget * * Returns a newly created #GtkGesture that recognizes long presses. * * Returns: a newly created #GtkGestureLongPress **/ GtkGesture * -gtk_gesture_long_press_new (GtkWidget *widget) +gtk_gesture_long_press_new (void) { - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - return g_object_new (GTK_TYPE_GESTURE_LONG_PRESS, - "widget", widget, NULL); } diff --git a/gtk/gtkgesturelongpress.h b/gtk/gtkgesturelongpress.h index 6ab2cee777..f42d78a010 100644 --- a/gtk/gtkgesturelongpress.h +++ b/gtk/gtkgesturelongpress.h @@ -42,7 +42,7 @@ GDK_AVAILABLE_IN_ALL GType gtk_gesture_long_press_get_type (void) G_GNUC_CONST; GDK_AVAILABLE_IN_ALL -GtkGesture * gtk_gesture_long_press_new (GtkWidget *widget); +GtkGesture * gtk_gesture_long_press_new (void); G_END_DECLS diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index e670cd6ad0..3dc112559f 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -157,7 +157,6 @@ struct _GtkPlacesSidebar { gint drag_y; GtkWidget *row_placeholder; DropState drop_state; - GtkGesture *long_press_gesture; /* volume mounting - delayed open process */ GtkPlacesOpenFlags go_to_after_mount_open_flags; @@ -4008,6 +4007,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar) GdkContentFormats *target_list; gboolean show_desktop; GtkStyleContext *context; + GtkGesture *gesture; sidebar->cancellable = g_cancellable_new (); @@ -4051,10 +4051,11 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar) g_signal_connect (sidebar->list_box_key_controller, "key-pressed", G_CALLBACK (on_key_pressed), sidebar); - sidebar->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (sidebar)); - gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (sidebar->long_press_gesture), TRUE); - g_signal_connect (sidebar->long_press_gesture, "pressed", + gesture = gtk_gesture_long_press_new (); + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE); + g_signal_connect (gesture, "pressed", G_CALLBACK (long_press_cb), sidebar); + gtk_widget_add_controller (GTK_WIDGET (sidebar), GTK_EVENT_CONTROLLER (gesture)); /* DND support */ gtk_drag_dest_set (sidebar->list_box, @@ -4323,7 +4324,6 @@ gtk_places_sidebar_dispose (GObject *object) g_clear_object (&sidebar->current_location); g_clear_pointer (&sidebar->rename_uri, g_free); - g_clear_object (&sidebar->long_press_gesture); g_clear_object (&sidebar->list_box_key_controller); if (sidebar->source_targets) diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index f1a6acc179..f79e60beb6 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -115,7 +115,6 @@ struct _GtkRangePrivate /* Whether dragging is ongoing */ guint in_drag : 1; - GtkGesture *long_press_gesture; GtkGesture *multipress_gesture; GtkGesture *drag_gesture; GtkEventController *scroll_controller; @@ -535,6 +534,7 @@ static void gtk_range_init (GtkRange *range) { GtkRangePrivate *priv = gtk_range_get_instance_private (range); + GtkGesture *gesture; gtk_widget_set_has_surface (GTK_WIDGET (range), FALSE); @@ -583,11 +583,12 @@ gtk_range_init (GtkRange *range) gtk_widget_add_controller (GTK_WIDGET (range), GTK_EVENT_CONTROLLER (priv->multipress_gesture)); gtk_gesture_group (priv->drag_gesture, priv->multipress_gesture); - priv->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (range)); - g_object_set (priv->long_press_gesture, "delay-factor", 2.0, NULL); - gtk_gesture_group (priv->drag_gesture, priv->long_press_gesture); - g_signal_connect (priv->long_press_gesture, "pressed", + gesture = gtk_gesture_long_press_new (); + g_object_set (gesture, "delay-factor", 2.0, NULL); + g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_range_long_press_gesture_pressed), range); + gtk_widget_add_controller (GTK_WIDGET (range), GTK_EVENT_CONTROLLER (gesture)); + gtk_gesture_group (priv->drag_gesture, gesture); priv->scroll_controller = gtk_event_controller_scroll_new (GTK_WIDGET (range), @@ -1293,7 +1294,6 @@ gtk_range_finalize (GObject *object) GtkRangePrivate *priv = gtk_range_get_instance_private (range); g_clear_object (&priv->drag_gesture); - g_clear_object (&priv->long_press_gesture); g_clear_object (&priv->scroll_controller); g_clear_object (&priv->key_controller); diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 96a8ea6f35..65eedc4dff 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1944,8 +1944,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *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); + priv->long_press_gesture = gtk_gesture_long_press_new (); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->long_press_gesture), TRUE); g_signal_connect_swapped (priv->long_press_gesture, "pressed", G_CALLBACK (scrolled_window_long_press_cb), @@ -1953,6 +1952,8 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window) g_signal_connect_swapped (priv->long_press_gesture, "cancelled", G_CALLBACK (scrolled_window_long_press_cancelled_cb), scrolled_window); + gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->long_press_gesture)); + gtk_gesture_group (priv->long_press_gesture, priv->drag_gesture); gtk_scrolled_window_set_kinetic_scrolling (scrolled_window, TRUE); gtk_scrolled_window_set_capture_button_press (scrolled_window, TRUE); @@ -2616,7 +2617,6 @@ gtk_scrolled_window_finalize (GObject *object) GtkScrolledWindowPrivate *priv = scrolled_window->priv; g_clear_object (&priv->drag_gesture); - g_clear_object (&priv->long_press_gesture); g_clear_object (&priv->scroll_controller); |