[gtk/wip/otte/controller] draggesture: Port to new API model
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/controller] draggesture: Port to new API model
- Date: Sat, 10 Mar 2018 18:24:47 +0000 (UTC)
commit 8613d335863d3e52e07df35649ae9620e249987e
Author: Benjamin Otte <otte redhat com>
Date: Sat Mar 10 18:05:57 2018 +0100
draggesture: Port to new API model
demos/gtk-demo/drawingarea.c | 5 +++--
demos/gtk-demo/fontplane.c | 13 ++++++-------
examples/drawing.c | 5 ++---
gtk/gtkcalendar.c | 9 ++++-----
gtk/gtkcolorplane.c | 15 ++++++---------
gtk/gtkdragsource.c | 6 ++++--
gtk/gtkentry.c | 4 ++--
gtk/gtkflowbox.c | 5 ++---
gtk/gtkgesturedrag.c | 6 +-----
gtk/gtkgesturedrag.h | 2 +-
gtk/gtklabel.c | 6 +++---
gtk/gtkpaned.c | 4 ++--
gtk/gtkrange.c | 4 ++--
gtk/gtkscrolledwindow.c | 4 ++--
gtk/gtktextview.c | 4 ++--
gtk/gtktreeview.c | 8 ++++----
gtk/gtkwindow.c | 6 ++----
tests/testinput.c | 3 ++-
18 files changed, 50 insertions(+), 59 deletions(-)
---
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index 985345de8a..fbcf581f0f 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -244,13 +244,14 @@ do_drawingarea (GtkWidget *do_widget)
g_signal_connect (da, "size-allocate",
G_CALLBACK (scribble_size_allocate), NULL);
- drag = gtk_gesture_drag_new (da);
+ drag = gtk_gesture_drag_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), GDK_BUTTON_PRIMARY);
- g_object_set_data_full (G_OBJECT (da), "drag", drag, g_object_unref);
+ gtk_widget_add_controller (da, GTK_EVENT_CONTROLLER (drag));
g_signal_connect (drag, "drag-begin", G_CALLBACK (drag_begin), da);
g_signal_connect (drag, "drag-update", G_CALLBACK (drag_update), da);
g_signal_connect (drag, "drag-end", G_CALLBACK (drag_end), da);
+
}
if (!gtk_widget_get_visible (window))
diff --git a/demos/gtk-demo/fontplane.c b/demos/gtk-demo/fontplane.c
index 63f175c12a..7cf1e23b01 100644
--- a/demos/gtk-demo/fontplane.c
+++ b/demos/gtk-demo/fontplane.c
@@ -213,14 +213,15 @@ gtk_font_plane_init (GtkFontPlane *plane)
gtk_widget_set_has_window (GTK_WIDGET (plane), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
- plane->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (plane));
- g_signal_connect (plane->drag_gesture, "drag-begin",
+ gesture = gtk_gesture_drag_new ();
+ g_signal_connect (gesture, "drag-begin",
G_CALLBACK (plane_drag_gesture_begin), plane);
- g_signal_connect (plane->drag_gesture, "drag-update",
+ g_signal_connect (gesture, "drag-update",
G_CALLBACK (plane_drag_gesture_update), plane);
- g_signal_connect (plane->drag_gesture, "drag-end",
+ g_signal_connect (gesture, "drag-end",
G_CALLBACK (plane_drag_gesture_end), plane);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (plane->drag_gesture), 0);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
+ gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed",
@@ -238,8 +239,6 @@ plane_finalize (GObject *object)
g_clear_object (&plane->weight_adj);
g_clear_object (&plane->width_adj);
- g_clear_object (&plane->drag_gesture);
-
G_OBJECT_CLASS (gtk_font_plane_parent_class)->finalize (object);
}
diff --git a/examples/drawing.c b/examples/drawing.c
index be2ea2466a..06ee9b6b59 100644
--- a/examples/drawing.c
+++ b/examples/drawing.c
@@ -158,10 +158,9 @@ activate (GtkApplication *app,
g_signal_connect_after (drawing_area, "size-allocate",
G_CALLBACK (size_allocate_cb), NULL);
- drag = gtk_gesture_drag_new (drawing_area);
+ drag = gtk_gesture_drag_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), GDK_BUTTON_PRIMARY);
- g_object_set_data_full (G_OBJECT (drawing_area), "drag", drag, g_object_unref);
-
+ gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (drag));
g_signal_connect (drag, "drag-begin", G_CALLBACK (drag_begin), drawing_area);
g_signal_connect (drag, "drag-update", G_CALLBACK (drag_update), drawing_area);
g_signal_connect (drag, "drag-end", G_CALLBACK (drag_end), drawing_area);
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 9b59c557de..f1f4c1d0b9 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -248,7 +248,6 @@ struct _GtkCalendarPrivate
gint detail_width_chars;
gint detail_overflow[6];
- GtkGesture *drag_gesture;
GtkEventController *scroll_controller;
};
@@ -675,9 +674,10 @@ gtk_calendar_init (GtkCalendar *calendar)
g_signal_connect (gesture, "released", G_CALLBACK (gtk_calendar_button_release), calendar);
gtk_widget_add_controller (GTK_WIDGET (calendar), GTK_EVENT_CONTROLLER (gesture));
- priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (calendar));
- g_signal_connect (priv->drag_gesture, "drag-begin", G_CALLBACK (gtk_calendar_drag_begin), calendar);
- g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_calendar_drag_update), calendar);
+ gesture = gtk_gesture_drag_new ();
+ g_signal_connect (gesture, "drag-begin", G_CALLBACK (gtk_calendar_drag_begin), calendar);
+ g_signal_connect (gesture, "drag-update", G_CALLBACK (gtk_calendar_drag_update), calendar);
+ gtk_widget_add_controller (GTK_WIDGET (calendar), GTK_EVENT_CONTROLLER (gesture));
priv->scroll_controller =
gtk_event_controller_scroll_new (GTK_WIDGET (calendar),
@@ -1319,7 +1319,6 @@ gtk_calendar_finalize (GObject *object)
{
GtkCalendarPrivate *priv = GTK_CALENDAR (object)->priv;
- g_object_unref (priv->drag_gesture);
g_object_unref (priv->scroll_controller);
G_OBJECT_CLASS (gtk_calendar_parent_class)->finalize (object);
diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c
index 353c09122c..e2da7a2276 100644
--- a/gtk/gtkcolorplane.c
+++ b/gtk/gtkcolorplane.c
@@ -35,8 +35,6 @@ struct _GtkColorPlanePrivate
GtkAdjustment *v_adj;
cairo_surface_t *surface;
-
- GtkGesture *drag_gesture;
};
enum {
@@ -418,14 +416,15 @@ gtk_color_plane_init (GtkColorPlane *plane)
atk_object_set_role (atk_obj, ATK_ROLE_COLOR_CHOOSER);
}
- plane->priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (plane));
- g_signal_connect (plane->priv->drag_gesture, "drag-begin",
+ gesture = gtk_gesture_drag_new ();
+ g_signal_connect (gesture, "drag-begin",
G_CALLBACK (plane_drag_gesture_begin), plane);
- g_signal_connect (plane->priv->drag_gesture, "drag-update",
+ g_signal_connect (gesture, "drag-update",
G_CALLBACK (plane_drag_gesture_update), plane);
- g_signal_connect (plane->priv->drag_gesture, "drag-end",
+ g_signal_connect (gesture, "drag-end",
G_CALLBACK (plane_drag_gesture_end), plane);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (plane->priv->drag_gesture), 0);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
+ gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed",
@@ -447,8 +446,6 @@ plane_finalize (GObject *object)
g_clear_object (&plane->priv->s_adj);
g_clear_object (&plane->priv->v_adj);
- g_clear_object (&plane->priv->drag_gesture);
-
G_OBJECT_CLASS (gtk_color_plane_parent_class)->finalize (object);
}
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index a50b6826b4..cec29eceff 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -108,7 +108,8 @@ gtk_drag_source_site_destroy (gpointer data)
gdk_content_formats_unref (site->target_list);
gtk_image_definition_unref (site->image_def);
- g_clear_object (&site->drag_gesture);
+ /* This gets called only during widget finalization.
+ * And widget finalization takes care of gestures. */
g_slice_free (GtkDragSourceSite, site);
}
@@ -144,7 +145,7 @@ gtk_drag_source_set (GtkWidget *widget,
{
site = g_slice_new0 (GtkDragSourceSite);
site->image_def = gtk_image_definition_new_empty ();
- site->drag_gesture = gtk_gesture_drag_new (widget);
+ site->drag_gesture = gtk_gesture_drag_new ();
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (site->drag_gesture),
GTK_PHASE_BUBBLE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (site->drag_gesture), 0);
@@ -154,6 +155,7 @@ gtk_drag_source_set (GtkWidget *widget,
g_signal_connect (site->drag_gesture, "update",
G_CALLBACK (gtk_drag_source_gesture_update),
site);
+ gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (site->drag_gesture));
g_object_set_data_full (G_OBJECT (widget),
I_("gtk-site-data"),
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index a1a49e9f6d..3c1f42ff1e 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -2536,13 +2536,14 @@ gtk_entry_init (GtkEntry *entry)
gtk_entry_update_cached_style_values (entry);
- priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (entry));
+ priv->drag_gesture = gtk_gesture_drag_new ();
g_signal_connect (priv->drag_gesture, "drag-update",
G_CALLBACK (gtk_entry_drag_gesture_update), entry);
g_signal_connect (priv->drag_gesture, "drag-end",
G_CALLBACK (gtk_entry_drag_gesture_end), entry);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture), 0);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE);
+ gtk_widget_add_controller (GTK_WIDGET (entry), GTK_EVENT_CONTROLLER (priv->drag_gesture));
gesture = gtk_gesture_multi_press_new ();
g_signal_connect (gesture, "pressed",
@@ -2763,7 +2764,6 @@ gtk_entry_finalize (GObject *object)
g_free (priv->placeholder_text);
g_free (priv->im_module);
- g_clear_object (&priv->drag_gesture);
g_clear_object (&priv->motion_controller);
if (priv->tabs)
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 8f67ecb7f5..3937e55a7e 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -3383,8 +3383,6 @@ gtk_flow_box_finalize (GObject *obj)
g_clear_object (&priv->hadjustment);
g_clear_object (&priv->vadjustment);
- g_object_unref (priv->drag_gesture);
-
if (priv->bound_model)
{
if (priv->create_widget_func_data_destroy)
@@ -3763,7 +3761,7 @@ gtk_flow_box_init (GtkFlowBox *box)
G_CALLBACK (gtk_flow_box_multipress_unpaired_release), box);
gtk_widget_add_controller (GTK_WIDGET (box), GTK_EVENT_CONTROLLER (gesture));
- priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (box));
+ priv->drag_gesture = gtk_gesture_drag_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture),
FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture),
@@ -3776,6 +3774,7 @@ gtk_flow_box_init (GtkFlowBox *box)
G_CALLBACK (gtk_flow_box_drag_gesture_update), box);
g_signal_connect (priv->drag_gesture, "drag-end",
G_CALLBACK (gtk_flow_box_drag_gesture_end), box);
+ gtk_widget_add_controller (GTK_WIDGET (box), GTK_EVENT_CONTROLLER (priv->drag_gesture));
}
static void
diff --git a/gtk/gtkgesturedrag.c b/gtk/gtkgesturedrag.c
index 11d7752056..baccf2f2df 100644
--- a/gtk/gtkgesturedrag.c
+++ b/gtk/gtkgesturedrag.c
@@ -195,19 +195,15 @@ gtk_gesture_drag_init (GtkGestureDrag *gesture)
/**
* gtk_gesture_drag_new:
- * @widget: a #GtkWidget
*
* Returns a newly created #GtkGesture that recognizes drags.
*
* Returns: a newly created #GtkGestureDrag
**/
GtkGesture *
-gtk_gesture_drag_new (GtkWidget *widget)
+gtk_gesture_drag_new (void)
{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
return g_object_new (GTK_TYPE_GESTURE_DRAG,
- "widget", widget,
NULL);
}
diff --git a/gtk/gtkgesturedrag.h b/gtk/gtkgesturedrag.h
index ab0cba773c..2493e65de4 100644
--- a/gtk/gtkgesturedrag.h
+++ b/gtk/gtkgesturedrag.h
@@ -42,7 +42,7 @@ GDK_AVAILABLE_IN_ALL
GType gtk_gesture_drag_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
-GtkGesture * gtk_gesture_drag_new (GtkWidget *widget);
+GtkGesture * gtk_gesture_drag_new (void);
GDK_AVAILABLE_IN_ALL
gboolean gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6fe2b8ac2a..2585a8d96d 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3178,7 +3178,6 @@ gtk_label_finalize (GObject *object)
if (priv->select_info)
{
- g_object_unref (priv->select_info->drag_gesture);
g_object_unref (priv->select_info->motion_controller);
g_object_unref (priv->select_info->provider);
}
@@ -5048,12 +5047,13 @@ gtk_label_ensure_select_info (GtkLabel *label)
if (gtk_widget_get_realized (GTK_WIDGET (label)))
gtk_label_set_selectable_hint (label);
- priv->select_info->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (label));
+ priv->select_info->drag_gesture = gtk_gesture_drag_new ();
g_signal_connect (priv->select_info->drag_gesture, "drag-begin",
G_CALLBACK (gtk_label_drag_gesture_begin), label);
g_signal_connect (priv->select_info->drag_gesture, "drag-update",
G_CALLBACK (gtk_label_drag_gesture_update), label);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->select_info->drag_gesture), TRUE);
+ gtk_widget_add_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER (priv->select_info->drag_gesture));
priv->select_info->multipress_gesture = gtk_gesture_multi_press_new ();
g_signal_connect (priv->select_info->multipress_gesture, "pressed",
@@ -5085,7 +5085,7 @@ gtk_label_clear_select_info (GtkLabel *label)
if (!priv->select_info->selectable && !priv->select_info->links)
{
- g_object_unref (priv->select_info->drag_gesture);
+ gtk_widget_remove_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER
(priv->select_info->drag_gesture));
gtk_widget_remove_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER
(priv->select_info->multipress_gesture));
g_object_unref (priv->select_info->motion_controller);
GTK_LABEL_CONTENT (priv->select_info->provider)->label = NULL;
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 60a9f73e64..0912ae3a26 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -995,7 +995,6 @@ gtk_paned_finalize (GObject *object)
gtk_paned_set_saved_focus (paned, NULL);
gtk_paned_set_first_paned (paned, NULL);
- g_clear_object (&paned->priv->drag_gesture);
g_clear_object (&paned->priv->motion_controller);
gtk_widget_unparent (priv->handle_widget);
@@ -1533,10 +1532,11 @@ gtk_paned_init (GtkPaned *paned)
priv->pan_gesture = gesture;
/* Pointer gesture */
- gesture = gtk_gesture_drag_new (GTK_WIDGET (paned));
+ gesture = gtk_gesture_drag_new ();
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_CAPTURE);
connect_drag_gesture_signals (paned, gesture);
+ gtk_widget_add_controller (GTK_WIDGET (paned), GTK_EVENT_CONTROLLER (gesture));
priv->drag_gesture = gesture;
priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (paned));
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 3777433e81..c0072daedf 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -566,12 +566,13 @@ gtk_range_init (GtkRange *range)
* in the oppposite order in which they are added to their
* widget.
*/
- priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (range));
+ priv->drag_gesture = gtk_gesture_drag_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture), 0);
g_signal_connect (priv->drag_gesture, "drag-begin",
G_CALLBACK (gtk_range_drag_gesture_begin), range);
g_signal_connect (priv->drag_gesture, "drag-update",
G_CALLBACK (gtk_range_drag_gesture_update), range);
+ gtk_widget_add_controller (GTK_WIDGET (range), GTK_EVENT_CONTROLLER (priv->drag_gesture));
priv->multipress_gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), 0);
@@ -1261,7 +1262,6 @@ gtk_range_finalize (GObject *object)
GtkRange *range = GTK_RANGE (object);
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
- g_clear_object (&priv->drag_gesture);
g_clear_object (&priv->scroll_controller);
gtk_widget_unparent (priv->slider_widget);
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 43614736d1..860d6a35b6 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1935,7 +1935,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
priv->overlay_scrolling = TRUE;
- priv->drag_gesture = gtk_gesture_drag_new (widget);
+ priv->drag_gesture = gtk_gesture_drag_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE);
g_signal_connect_swapped (priv->drag_gesture, "drag-begin",
G_CALLBACK (scrolled_window_drag_begin_cb),
@@ -1946,6 +1946,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
g_signal_connect_swapped (priv->drag_gesture, "end",
G_CALLBACK (scrolled_window_drag_end_cb),
scrolled_window);
+ gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->drag_gesture));
priv->pan_gesture = gtk_gesture_pan_new (GTK_ORIENTATION_VERTICAL);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->pan_gesture), TRUE);
@@ -2632,7 +2633,6 @@ gtk_scrolled_window_finalize (GObject *object)
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object);
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
- g_clear_object (&priv->drag_gesture);
g_clear_object (&priv->scroll_controller);
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 978ba5779a..dbcac2096e 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1686,13 +1686,14 @@ gtk_text_view_init (GtkTextView *text_view)
widget);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
- priv->drag_gesture = gtk_gesture_drag_new (widget);
+ priv->drag_gesture = gtk_gesture_drag_new ();
g_signal_connect (priv->drag_gesture, "drag-update",
G_CALLBACK (gtk_text_view_drag_gesture_update),
widget);
g_signal_connect (priv->drag_gesture, "drag-end",
G_CALLBACK (gtk_text_view_drag_gesture_end),
widget);
+ gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->drag_gesture));
priv->motion_controller = gtk_event_controller_motion_new (widget);
g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_text_view_motion), widget);
@@ -3589,7 +3590,6 @@ gtk_text_view_finalize (GObject *object)
cancel_pending_scroll (text_view);
- g_object_unref (priv->drag_gesture);
g_object_unref (priv->motion_controller);
if (priv->tabs)
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index b48842e6e8..4ce3b890c2 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -1737,15 +1737,16 @@ gtk_tree_view_init (GtkTreeView *tree_view)
GTK_PHASE_CAPTURE);
gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (gesture));
- priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (tree_view));
+ priv->drag_gesture = gtk_gesture_drag_new ();
g_signal_connect (priv->drag_gesture, "drag-begin",
G_CALLBACK (gtk_tree_view_drag_gesture_begin), tree_view);
g_signal_connect (priv->drag_gesture, "drag-update",
G_CALLBACK (gtk_tree_view_drag_gesture_update), tree_view);
g_signal_connect (priv->drag_gesture, "drag-end",
G_CALLBACK (gtk_tree_view_drag_gesture_end), tree_view);
+ gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (priv->drag_gesture));
- priv->column_drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (tree_view));
+ priv->column_drag_gesture = gtk_gesture_drag_new ();
g_signal_connect (priv->column_drag_gesture, "drag-begin",
G_CALLBACK (gtk_tree_view_column_drag_gesture_begin), tree_view);
g_signal_connect (priv->column_drag_gesture, "drag-update",
@@ -1754,6 +1755,7 @@ gtk_tree_view_init (GtkTreeView *tree_view)
G_CALLBACK (gtk_tree_view_column_drag_gesture_end), tree_view);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->column_drag_gesture),
GTK_PHASE_CAPTURE);
+ gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (priv->column_drag_gesture));
priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (tree_view));
g_signal_connect (priv->motion_controller, "enter",
@@ -2145,8 +2147,6 @@ gtk_tree_view_destroy (GtkWidget *widget)
tree_view->priv->vadjustment = NULL;
}
- g_clear_object (&tree_view->priv->drag_gesture);
- g_clear_object (&tree_view->priv->column_drag_gesture);
g_clear_object (&tree_view->priv->motion_controller);
GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->destroy (widget);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 86085e10e3..71615eda43 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1978,13 +1978,14 @@ gtk_window_constructed (GObject *object)
G_CALLBACK (multipress_gesture_pressed_cb), object);
gtk_widget_add_controller (GTK_WIDGET (object), GTK_EVENT_CONTROLLER (priv->multipress_gesture));
- priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (object));
+ priv->drag_gesture = gtk_gesture_drag_new ();
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->drag_gesture),
GTK_PHASE_CAPTURE);
g_signal_connect (priv->drag_gesture, "drag-begin",
G_CALLBACK (drag_gesture_begin_cb), object);
g_signal_connect (priv->drag_gesture, "drag-update",
G_CALLBACK (drag_gesture_update_cb), object);
+ gtk_widget_add_controller (GTK_WIDGET (object), GTK_EVENT_CONTROLLER (priv->drag_gesture));
}
}
@@ -5964,9 +5965,6 @@ gtk_window_finalize (GObject *object)
priv->mnemonics_display_timeout_id = 0;
}
- if (priv->drag_gesture)
- g_object_unref (priv->drag_gesture);
-
g_clear_object (&priv->renderer);
G_OBJECT_CLASS (gtk_window_parent_class)->finalize (object);
diff --git a/tests/testinput.c b/tests/testinput.c
index 69b1230159..708f567b1b 100644
--- a/tests/testinput.c
+++ b/tests/testinput.c
@@ -255,13 +255,14 @@ main (int argc, char *argv[])
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw, NULL, NULL);
g_signal_connect (drawing_area, "size-allocate", G_CALLBACK (size_allocate), NULL);
- gesture = gtk_gesture_drag_new (drawing_area);
+ gesture = gtk_gesture_drag_new ();
g_object_set_data_full (G_OBJECT (drawing_area), "gesture",
gesture, g_object_unref);
g_signal_connect (gesture, "drag-begin",
G_CALLBACK (drag_begin), drawing_area);
g_signal_connect (gesture, "drag-update",
G_CALLBACK (drag_update), drawing_area);
+ gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
g_signal_connect (drawing_area, "key_press_event",
G_CALLBACK (key_press_event), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]