[gtk/dnd-gestures-2: 87/175] Replace gtk_drop_target_attach/detach
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 87/175] Replace gtk_drop_target_attach/detach
- Date: Wed, 8 Jan 2020 16:45:09 +0000 (UTC)
commit bc452b848253412883cbc89a6cd32691c5a6d942
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 6 00:12:21 2020 -0500
Replace gtk_drop_target_attach/detach
Since drop targets are now just event controller,
gtk_widget_add/remove_controller works just fine
for them.
demos/gtk-demo/clipboard.c | 4 ++--
gtk/gtkcalendar.c | 2 +-
gtk/gtkcolorbutton.c | 3 ++-
gtk/gtkcolorswatch.c | 6 +++---
gtk/gtkdragdest.c | 40 +---------------------------------------
gtk/gtkdragdest.h | 6 ------
gtk/gtkexpander.c | 2 +-
gtk/gtkfilechooserbutton.c | 3 ++-
gtk/gtkfilechooserwidget.c | 2 +-
gtk/gtkiconview.c | 5 ++---
gtk/gtknotebook.c | 3 ++-
gtk/gtkplacessidebar.c | 2 +-
gtk/gtkstackswitcher.c | 2 +-
gtk/gtktext.c | 2 +-
gtk/gtktextview.c | 2 +-
gtk/gtktreeview.c | 11 +++++++----
gtk/gtkwindow.c | 2 +-
tests/testdnd.c | 8 ++++----
tests/testdnd2.c | 2 +-
tests/testlist3.c | 2 +-
tests/testnotebookdnd.c | 2 +-
tests/testtoolbar.c | 2 +-
tests/testtreednd.c | 2 +-
23 files changed, 38 insertions(+), 77 deletions(-)
---
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index e40b89ac4c..b484f5eec7 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -342,7 +342,7 @@ do_clipboard (GtkWidget *do_widget)
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
- gtk_drop_target_attach (dest, image);
+ gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
/* context menu on image */
gesture = gtk_gesture_click_new ();
@@ -375,7 +375,7 @@ do_clipboard (GtkWidget *do_widget)
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
- gtk_drop_target_attach (dest, image);
+ gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
/* context menu on image */
gesture = gtk_gesture_click_new ();
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index b9b7d1d062..7e3b8b49d8 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -791,7 +791,7 @@ gtk_calendar_init (GtkCalendar *calendar)
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_calendar_drag_leave), calendar);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_calendar_drag_drop), calendar);
- gtk_drop_target_attach (dest, widget);
+ gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (dest));
priv->year_before = 0;
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 20b0471492..581da04d59 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -46,6 +46,7 @@
#include "gtkstylecontext.h"
#include "gtkdragsource.h"
#include "gtkdragdest.h"
+#include "gtkeventcontroller.h"
/**
@@ -328,7 +329,7 @@ gtk_color_button_init (GtkColorButton *button)
targets = gdk_content_formats_new (drop_types, G_N_ELEMENTS (drop_types));
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_color_button_drag_drop), button);
- gtk_drop_target_attach (dest, GTK_WIDGET (button));
+ gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (targets);
content = gdk_content_provider_new_with_callback (GDK_TYPE_RGBA, get_rgba_value, button);
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index 4f22fbd39b..188f08d8d1 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -473,7 +473,6 @@ swatch_finalize (GObject *object)
g_free (priv->icon);
gtk_widget_unparent (priv->overlay_widget);
- g_clear_pointer (&priv->dest, gtk_drop_target_detach);
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->finalize (object);
}
@@ -678,12 +677,13 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
targets = gdk_content_formats_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
priv->dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
g_signal_connect (priv->dest, "drag-drop", G_CALLBACK (swatch_drag_drop), swatch);
- gtk_drop_target_attach (priv->dest, GTK_WIDGET (swatch));
+ gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (priv->dest));
gdk_content_formats_unref (targets);
}
if (!can_drop && priv->dest)
{
- g_clear_pointer (&priv->dest, gtk_drop_target_detach);
+ gtk_widget_remove_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (priv->dest));
+ priv->dest = NULL;
}
g_object_notify (G_OBJECT (swatch), "can-drop");
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index 0dc2c27761..9c2e802076 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -46,7 +46,7 @@
*
* To use a GtkDropTarget to receive drops on a widget, you create
* a GtkDropTarget object, connect to its signals, and then attach
- * it to the widget with gtk_drop_target_attach().
+ * it to the widget with gtk_widget_add_controller().
*/
struct _GtkDropTarget
@@ -445,44 +445,6 @@ gtk_drop_target_get (GtkWidget *widget)
return g_object_get_data (G_OBJECT (widget), I_("gtk-drag-dest"));
}
-/**
- * gtk_drop_target_attach:
- * @dest: (transfer full): a #GtkDropTarget
- * @widget the widget to attach @dest to
- *
- * Attaches the @dest to widget and makes it accept drops
- * on the widgets.
- *
- * To undo the effect of this call, use gtk_drop_target_detach().
- */
-void
-gtk_drop_target_attach (GtkDropTarget *dest,
- GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_DROP_TARGET (dest));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (dest), GTK_PHASE_BUBBLE);
- gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (dest));
-}
-
-/**
- * gtk_drop_target_detach:
- * @dest: a #GtkDropTarget
- *
- * Undoes the effect of a prior gtk_drop_target_attach() call.
- */
-void
-gtk_drop_target_detach (GtkDropTarget *dest)
-{
- GtkWidget *widget;
-
- g_return_if_fail (GTK_IS_DROP_TARGET (dest));
-
- widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
- gtk_widget_remove_controller (widget, GTK_EVENT_CONTROLLER (dest));
-}
-
/**
* gtk_drop_target_get_target:
* @dest: a #GtkDropTarget
diff --git a/gtk/gtkdragdest.h b/gtk/gtkdragdest.h
index 267600b4b5..11271c46b4 100644
--- a/gtk/gtkdragdest.h
+++ b/gtk/gtkdragdest.h
@@ -68,12 +68,6 @@ void gtk_drop_target_set_actions (GtkDropTarget *dest,
GDK_AVAILABLE_IN_ALL
GdkDragAction gtk_drop_target_get_actions (GtkDropTarget *dest);
-GDK_AVAILABLE_IN_ALL
-void gtk_drop_target_attach (GtkDropTarget *dest,
- GtkWidget *widget);
-GDK_AVAILABLE_IN_ALL
-void gtk_drop_target_detach (GtkDropTarget *dest);
-
GDK_AVAILABLE_IN_ALL
GdkDrop *gtk_drop_target_get_drop (GtkDropTarget *dest);
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 5528c8416e..ac5b6034ab 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -379,7 +379,7 @@ gtk_expander_init (GtkExpander *expander)
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_expander_drag_motion), expander);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_expander_drag_leave), expander);
- gtk_drop_target_attach (dest, GTK_WIDGET (expander));
+ gtk_widget_add_controller (GTK_WIDGET (expander), GTK_EVENT_CONTROLLER (dest));
gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture),
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index a80e56f0bc..f20423198e 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -60,6 +60,7 @@
#include "gtksettings.h"
#include "gtkstylecontextprivate.h"
#include "gtkbitmaskprivate.h"
+#include "gtkeventcontroller.h"
/**
* SECTION:gtkfilechooserbutton
@@ -500,7 +501,7 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
target_list = gtk_content_formats_add_text_targets (target_list);
dest = gtk_drop_target_new (target_list, GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_file_chooser_button_drag_drop), button);
- gtk_drop_target_attach (dest, GTK_WIDGET (button));
+ gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (target_list);
}
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 8635228b01..23f7ed0b93 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -8522,7 +8522,7 @@ post_process_ui (GtkFileChooserWidget *impl)
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (file_list_drag_motion_cb), impl);
g_signal_connect (dest, "drag-drop", G_CALLBACK (file_list_drag_drop_cb), impl);
- gtk_drop_target_attach (dest, priv->browse_files_tree_view);
+ gtk_widget_add_controller (priv->browse_files_tree_view, GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (formats);
/* File browser treemodel columns are shared between GtkFileChooser implementations,
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index d243666376..a2491bcf06 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1025,7 +1025,6 @@ gtk_icon_view_dispose (GObject *object)
g_clear_object (&priv->key_controller);
g_clear_object (&priv->source);
- g_clear_pointer (&priv->dest, gtk_drop_target_detach);
G_OBJECT_CLASS (gtk_icon_view_parent_class)->dispose (object);
}
@@ -6499,7 +6498,7 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
g_signal_connect (icon_view->priv->dest, "drag-leave", G_CALLBACK (gtk_icon_view_drag_leave), icon_view);
g_signal_connect (icon_view->priv->dest, "drag-motion", G_CALLBACK (gtk_icon_view_drag_motion), icon_view);
g_signal_connect (icon_view->priv->dest, "drag-drop", G_CALLBACK (gtk_icon_view_drag_drop), icon_view);
- gtk_drop_target_attach (icon_view->priv->dest, GTK_WIDGET (icon_view));
+ gtk_widget_add_controller (GTK_WIDGET (icon_view), GTK_EVENT_CONTROLLER (icon_view->priv->dest));
icon_view->priv->dest_actions = actions;
@@ -6545,7 +6544,7 @@ gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view)
if (icon_view->priv->dest_set)
{
- gtk_drop_target_detach (icon_view->priv->dest);
+ gtk_widget_remove_controller (GTK_WIDGET (icon_view), GTK_EVENT_CONTROLLER (icon_view->priv->dest));
icon_view->priv->dest = NULL;
icon_view->priv->dest_set = FALSE;
}
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index c1eda8ea3e..5127e7c177 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -1329,7 +1329,8 @@ gtk_notebook_init (GtkNotebook *notebook)
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_notebook_drag_motion), NULL);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_notebook_drag_leave), NULL);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_notebook_drag_drop), NULL);
- gtk_drop_target_attach (dest, GTK_WIDGET (notebook));
+ gtk_widget_add_controller (GTK_WIDGET (notebook), GTK_EVENT_CONTROLLER (dest));
+
gdk_content_formats_unref (targets);
priv->header_widget = g_object_new (GTK_TYPE_BOX,
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 3b0f588536..907482748c 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -4099,7 +4099,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
g_signal_connect (dest, "drag-motion", G_CALLBACK (drag_motion_callback), sidebar);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop_callback), sidebar);
g_signal_connect (dest, "drag-leave", G_CALLBACK (drag_leave_callback), sidebar);
- gtk_drop_target_attach (dest, sidebar->list_box);
+ gtk_widget_add_controller (sidebar->list_box, GTK_EVENT_CONTROLLER (dest));
sidebar->source_targets = gdk_content_formats_new (dnd_source_targets, G_N_ELEMENTS (dnd_source_targets));
sidebar->source_targets = gtk_content_formats_add_text_targets (sidebar->source_targets);
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index b3688ab4d4..02d22dec08 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -120,7 +120,7 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher)
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_stack_switcher_drag_leave), switcher);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_stack_switcher_drag_motion), switcher);
- gtk_drop_target_attach (dest, GTK_WIDGET (switcher));
+ gtk_widget_add_controller (GTK_WIDGET (switcher), GTK_EVENT_CONTROLLER (dest));
}
static void
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 51216d5513..27916ada67 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1732,7 +1732,7 @@ gtk_text_init (GtkText *self)
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_text_drag_leave), self);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_text_drag_drop), self);
gdk_content_formats_unref (formats);
- gtk_drop_target_attach (dest, GTK_WIDGET (self));
+ gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (dest));
/* This object is completely private. No external entity can gain a reference
* to it; so we create it here and destroy it in finalize().
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 87b6435d0c..99f830f747 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1635,7 +1635,7 @@ gtk_text_view_init (GtkTextView *text_view)
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_text_view_drag_leave), text_view);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_text_view_drag_motion), text_view);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_text_view_drag_drop), text_view);
- gtk_drop_target_attach (dest, GTK_WIDGET (text_view));
+ gtk_widget_add_controller (GTK_WIDGET (text_view), GTK_EVENT_CONTROLLER (dest));
priv->virtual_cursor_x = -1;
priv->virtual_cursor_y = -1;
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index fd0d50f40f..e319430e03 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -6743,8 +6743,6 @@ static void
destroy_info (TreeViewDragInfo *di)
{
g_clear_object (&di->source);
- if (di->dest)
- gtk_drop_target_detach (di->dest);
g_clear_object (&di->dest);
g_slice_free (TreeViewDragInfo, di);
@@ -6773,6 +6771,11 @@ ensure_info (GtkTreeView *tree_view)
static void
remove_info (GtkTreeView *tree_view)
{
+ TreeViewDragInfo *di;
+
+ di = get_info (tree_view);
+ if (di && di->dest)
+ gtk_widget_remove_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (di->dest));
g_object_set_data (G_OBJECT (tree_view), I_("gtk-tree-view-drag-info"), NULL);
}
@@ -12968,7 +12971,7 @@ gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
g_signal_connect (di->dest, "drag-leave", G_CALLBACK (gtk_tree_view_drag_leave), tree_view);
g_signal_connect (di->dest, "drag-motion", G_CALLBACK (gtk_tree_view_drag_motion), tree_view);
g_signal_connect (di->dest, "drag-drop", G_CALLBACK (gtk_tree_view_drag_drop), tree_view);
- gtk_drop_target_attach (di->dest, GTK_WIDGET (tree_view));
+ gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (di->dest));
g_object_ref (di->dest);
unset_reorderable (tree_view);
@@ -13029,7 +13032,7 @@ gtk_tree_view_unset_rows_drag_dest (GtkTreeView *tree_view)
{
if (di->dest_set)
{
- gtk_drop_target_detach (di->dest);
+ gtk_widget_remove_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (di->dest));
di->dest = NULL;
di->dest_set = FALSE;
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 0c5a8e3f6a..c0a5067a52 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1841,7 +1841,7 @@ gtk_window_init (GtkWindow *window)
targets = gdk_content_formats_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets));
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
gdk_content_formats_unref (targets);
- gtk_drop_target_attach (dest, GTK_WIDGET (window));
+ gtk_widget_add_controller (GTK_WIDGET (window), GTK_EVENT_CONTROLLER (dest));
#endif
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
diff --git a/tests/testdnd.c b/tests/testdnd.c
index 9c43601ffe..4057e77235 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -504,7 +504,7 @@ popup_cb (gpointer data)
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (popup_motion), NULL);
g_signal_connect (dest, "drag-leave", G_CALLBACK (popup_leave), NULL);
- gtk_drop_target_attach (dest, button);
+ gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (dest));
}
gtk_container_add (GTK_CONTAINER (popup_window), grid);
gdk_content_formats_unref (targets);
@@ -597,7 +597,7 @@ main (int argc, char **argv)
targets = gdk_content_formats_new (target_table, n_targets - 1); /* no rootwin */
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-drop", G_CALLBACK (label_drag_drop), NULL);
- gtk_drop_target_attach (dest, label);
+ gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
@@ -608,7 +608,7 @@ main (int argc, char **argv)
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (popsite_motion), NULL);
g_signal_connect (dest, "drag-leave", G_CALLBACK (popsite_leave), NULL);
- gtk_drop_target_attach (dest, label);
+ gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
@@ -622,7 +622,7 @@ main (int argc, char **argv)
g_signal_connect (dest, "drag-leave", G_CALLBACK (target_drag_leave), pixmap);
g_signal_connect (dest, "drag-motion", G_CALLBACK (target_drag_motion), pixmap);
g_signal_connect (dest, "drag-drop", G_CALLBACK (target_drag_drop), pixmap);
- gtk_drop_target_attach (dest, pixmap);
+ gtk_widget_add_controller (pixmap, GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (targets);
gtk_widget_set_hexpand (pixmap, TRUE);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 1911346026..98c44c8c76 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -307,7 +307,7 @@ make_image (const gchar *icon_name, int hotspot)
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_ASK);
g_signal_connect (dest, "drag-drop", G_CALLBACK (image_drag_drop), image);
- gtk_drop_target_attach (dest, image);
+ gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (formats);
diff --git a/tests/testlist3.c b/tests/testlist3.c
index b43454ee76..5795067e93 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -90,7 +90,7 @@ create_row (const gchar *text)
targets = gdk_content_formats_new (entries, 1);
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), row);
- gtk_drop_target_attach (dest, row);
+ gtk_widget_add_controller (GTK_WIDGET (row), GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (targets);
diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c
index 8cea384793..1f95172137 100644
--- a/tests/testnotebookdnd.c
+++ b/tests/testnotebookdnd.c
@@ -303,7 +303,7 @@ create_trash_button (void)
targets = gdk_content_formats_new (button_targets, G_N_ELEMENTS (button_targets));
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-drop", G_CALLBACK (on_button_drag_drop), NULL);
- gtk_drop_target_attach (dest, button);
+ gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (targets);
return button;
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
index 82ee0a4f2b..d585bde96c 100644
--- a/tests/testtoolbar.c
+++ b/tests/testtoolbar.c
@@ -625,7 +625,7 @@ main (gint argc, gchar **argv)
g_signal_connect (dest, "drag_motion", G_CALLBACK (toolbar_drag_motion), toolbar);
g_signal_connect (dest, "drag_leave", G_CALLBACK (toolbar_drag_leave), toolbar);
g_signal_connect (dest, "drag_drop", G_CALLBACK (toolbar_drag_drop), label);
- gtk_drop_target_attach (dest, toolbar);
+ gtk_widget_add_controller (toolbar, GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (targets);
gtk_widget_show (window);
diff --git a/tests/testtreednd.c b/tests/testtreednd.c
index 9b2d44c252..7de29236bc 100644
--- a/tests/testtreednd.c
+++ b/tests/testtreednd.c
@@ -127,7 +127,7 @@ get_droptarget (void)
targets = gdk_content_formats_new (entries, G_N_ELEMENTS (entries));
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), NULL);
- gtk_drop_target_attach (dest, label);
+ gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
gdk_content_formats_unref (targets);
return label;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]