[gtk+] dnd: Make GtkDragDest and GtkDragSource use GtkTargetList



commit 5a1a11bcde0acacb455fc3df10d6bd8f67f62850
Author: Benjamin Otte <otte redhat com>
Date:   Tue Nov 14 22:32:23 2017 +0100

    dnd: Make GtkDragDest and GtkDragSource use GtkTargetList
    
    This gets rid of GtkTargetEntry in the API and consistently uses
    GtkTargetList.

 demos/gtk-demo/clipboard.c          |    8 ++++----
 demos/icon-browser/iconbrowserwin.c |   17 +++++++----------
 gtk/gtkcalendar.c                   |    2 +-
 gtk/gtkcolorbutton.c                |    8 ++++++--
 gtk/gtkcolorswatch.c                |    8 ++++++--
 gtk/gtkdragdest.c                   |   15 ++++++---------
 gtk/gtkdragdest.h                   |    3 +--
 gtk/gtkdragsource.c                 |   19 ++++++++++---------
 gtk/gtkdragsource.h                 |    3 +--
 gtk/gtkentry.c                      |    2 +-
 gtk/gtkexpander.c                   |    2 +-
 gtk/gtkfilechooserbutton.c          |    9 ++++-----
 gtk/gtkfilechooserwidget.c          |    4 ++--
 gtk/gtkiconview.c                   |   30 ++++++++++++------------------
 gtk/gtkiconview.h                   |    6 ++----
 gtk/gtklinkbutton.c                 |    5 ++++-
 gtk/gtknotebook.c                   |    5 ++++-
 gtk/gtkpathbar.c                    |    2 +-
 gtk/gtkplacessidebar.c              |    2 +-
 gtk/gtkrecentchooserdefault.c       |    2 +-
 gtk/gtkstackswitcher.c              |    2 +-
 gtk/gtktextview.c                   |    2 +-
 gtk/gtktoolpalette.c                |   17 ++++++++++++++---
 gtk/gtktreeview.c                   |   33 ++++++++++++++-------------------
 gtk/gtktreeview.h                   |    6 ++----
 gtk/gtkwindow.c                     |    5 ++++-
 tests/testdnd.c                     |   18 +++++++++++++-----
 tests/testdnd2.c                    |   10 +++++-----
 tests/testiconview.c                |   16 +++++++---------
 tests/testimage.c                   |    4 ++--
 tests/testkineticscrolling.c        |    9 +++++----
 tests/testlist3.c                   |    9 +++++++--
 tests/testnotebookdnd.c             |    6 ++++--
 tests/testtoolbar.c                 |    7 +++++--
 tests/testtreecolumns.c             |   22 +++++++++-------------
 tests/testtreednd.c                 |   10 ++++++++--
 tests/testtreeview.c                |    9 +++++----
 37 files changed, 181 insertions(+), 156 deletions(-)
---
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index de9ffd8..7e01db4 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -276,7 +276,7 @@ do_clipboard (GtkWidget *do_widget)
       gtk_container_add (GTK_CONTAINER (hbox), image);
 
       /* make image a drag source */
-      gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+      gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
       gtk_drag_source_add_image_targets (image);
       g_signal_connect (image, "drag-begin",
                         G_CALLBACK (drag_begin), image);
@@ -285,7 +285,7 @@ do_clipboard (GtkWidget *do_widget)
 
       /* accept drops on image */
       gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
-                         NULL, 0, GDK_ACTION_COPY);
+                         NULL, GDK_ACTION_COPY);
       gtk_drag_dest_add_image_targets (image);
       g_signal_connect (image, "drag-data-received",
                         G_CALLBACK (drag_data_received), image);
@@ -300,7 +300,7 @@ do_clipboard (GtkWidget *do_widget)
       gtk_container_add (GTK_CONTAINER (hbox), image);
 
       /* make image a drag source */
-      gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+      gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
       gtk_drag_source_add_image_targets (image);
       g_signal_connect (image, "drag-begin",
                         G_CALLBACK (drag_begin), image);
@@ -309,7 +309,7 @@ do_clipboard (GtkWidget *do_widget)
 
       /* accept drops on image */
       gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
-                         NULL, 0, GDK_ACTION_COPY);
+                         NULL, GDK_ACTION_COPY);
       gtk_drag_dest_add_image_targets (image);
       g_signal_connect (image, "drag-data-received",
                         G_CALLBACK (drag_data_received), image);
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index bd0e0d4..d828075 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -430,7 +430,7 @@ get_scalable_image_data (GtkWidget        *widget,
 static void
 setup_image_dnd (GtkWidget *image)
 {
-  gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
   gtk_drag_source_add_image_targets (image);
   g_signal_connect (image, "drag-data-get", G_CALLBACK (get_image_data), NULL);
 }
@@ -439,11 +439,14 @@ static void
 setup_scalable_image_dnd (GtkWidget *image)
 {
   GtkWidget *parent;
+  GtkTargetList *targets;
 
   parent = gtk_widget_get_parent (image);
+  targets = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
   gtk_drag_source_set (parent, GDK_BUTTON1_MASK,
-                       target_table, G_N_ELEMENTS (target_table),
+                       targets,
                        GDK_ACTION_COPY);
+  gtk_target_list_unref (targets);
 
   g_signal_connect (parent, "drag-data-get", G_CALLBACK (get_scalable_image_data), NULL);
 }
@@ -452,22 +455,16 @@ static void
 icon_browser_window_init (IconBrowserWindow *win)
 {
   GtkTargetList *list;
-  GtkTargetEntry *targets;
-  gint n_targets;
 
   gtk_widget_init_template (GTK_WIDGET (win));
 
   list = gtk_target_list_new (NULL, 0);
   gtk_target_list_add_text_targets (list, 0);
-  targets = gtk_target_table_new_from_list (list, &n_targets);
-  gtk_target_list_unref (list);
-
   gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
                                           GDK_BUTTON1_MASK,
-                                          targets, n_targets,
+                                          list,
                                           GDK_ACTION_COPY);
-
-  gtk_target_table_free (targets, n_targets);
+  gtk_target_list_unref (list);
 
   setup_image_dnd (win->image1);
   setup_image_dnd (win->image2);
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 9cb0a6e..7d4d07d 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -758,7 +758,7 @@ gtk_calendar_init (GtkCalendar *calendar)
   priv->in_drag = 0;
   priv->drag_highlight = 0;
 
-  gtk_drag_dest_set (widget, 0, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_dest_set (widget, 0, NULL, GDK_ACTION_COPY);
   gtk_drag_dest_add_text_targets (widget);
 
   priv->year_before = 0;
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index e583cda..3e142a6 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -388,6 +388,7 @@ gtk_color_button_init (GtkColorButton *button)
   PangoLayout *layout;
   PangoRectangle rect;
   GtkStyleContext *context;
+  GtkTargetList *targets;
 
   gtk_widget_set_has_window (GTK_WIDGET (button), FALSE);
 
@@ -416,15 +417,18 @@ gtk_color_button_init (GtkColorButton *button)
   priv->rgba.alpha = 1;
   priv->use_alpha = FALSE;
 
+  targets = gtk_target_list_new (drop_types, G_N_ELEMENTS (drop_types));
   gtk_drag_dest_set (priv->button,
                      GTK_DEST_DEFAULT_MOTION |
                      GTK_DEST_DEFAULT_HIGHLIGHT |
                      GTK_DEST_DEFAULT_DROP,
-                     drop_types, 1, GDK_ACTION_COPY);
+                     targets,
+                     GDK_ACTION_COPY);
   gtk_drag_source_set (priv->button,
                        GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
-                       drop_types, 1,
+                       targets,
                        GDK_ACTION_COPY);
+  gtk_target_list_unref (targets);
   g_signal_connect (priv->button, "drag-begin",
                     G_CALLBACK (gtk_color_button_drag_begin), button);
   g_signal_connect (priv->button, "drag-data-received",
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index 4b2bf62..b47a137 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -620,10 +620,12 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
 
   if (!swatch->priv->has_color)
     {
+      GtkTargetList *targets = gtk_target_list_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
       gtk_drag_source_set (GTK_WIDGET (swatch),
                            GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                           dnd_targets, G_N_ELEMENTS (dnd_targets),
+                           targets,
                            GDK_ACTION_COPY | GDK_ACTION_MOVE);
+      gtk_target_list_unref (targets);
     }
 
   swatch->priv->has_color = TRUE;
@@ -681,12 +683,14 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
 {
   if (can_drop)
     {
+      GtkTargetList *targets = gtk_target_list_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
       gtk_drag_dest_set (GTK_WIDGET (swatch),
                          GTK_DEST_DEFAULT_HIGHLIGHT |
                          GTK_DEST_DEFAULT_MOTION |
                          GTK_DEST_DEFAULT_DROP,
-                         dnd_targets, G_N_ELEMENTS (dnd_targets),
+                         targets,
                          GDK_ACTION_COPY);
+      gtk_target_list_unref (targets);
     }
   else
     {
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index 05915b2..ccbc7b6 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -97,11 +97,9 @@ gtk_drag_dest_set_internal (GtkWidget       *widget,
  * gtk_drag_dest_set: (method)
  * @widget: a #GtkWidget
  * @flags: which types of default drag behavior to use
- * @targets: (allow-none) (array length=n_targets): a pointer to an array of
- *     #GtkTargetEntrys indicating the drop types that this @widget will
+ * @targets: (allow-none): the drop types that this @widget will
  *     accept, or %NULL. Later you can access the list with
  *     gtk_drag_dest_get_target_list() and gtk_drag_dest_find_target().
- * @n_targets: the number of entries in @targets
  * @actions: a bitmask of possible actions for a drop onto this @widget.
  *
  * Sets a widget as a potential drop destination, and adds default behaviors.
@@ -145,11 +143,10 @@ gtk_drag_dest_set_internal (GtkWidget       *widget,
  * ]|
  */
 void
-gtk_drag_dest_set (GtkWidget            *widget,
-                   GtkDestDefaults       flags,
-                   const GtkTargetEntry *targets,
-                   gint                  n_targets,
-                   GdkDragAction         actions)
+gtk_drag_dest_set (GtkWidget       *widget,
+                   GtkDestDefaults  flags,
+                   GtkTargetList   *targets,
+                   GdkDragAction    actions)
 {
   GtkDragDestSite *site;
 
@@ -160,7 +157,7 @@ gtk_drag_dest_set (GtkWidget            *widget,
   site->flags = flags;
   site->have_drag = FALSE;
   if (targets)
-    site->target_list = gtk_target_list_new (targets, n_targets);
+    site->target_list = gtk_target_list_ref (targets);
   else
     site->target_list = NULL;
   site->actions = actions;
diff --git a/gtk/gtkdragdest.h b/gtk/gtkdragdest.h
index dfcbe52..609a32e 100644
--- a/gtk/gtkdragdest.h
+++ b/gtk/gtkdragdest.h
@@ -69,8 +69,7 @@ typedef enum {
 GDK_AVAILABLE_IN_ALL
 void gtk_drag_dest_set   (GtkWidget            *widget,
                           GtkDestDefaults       flags,
-                          const GtkTargetEntry *targets,
-                          gint                  n_targets,
+                          GtkTargetList        *targets,
                           GdkDragAction         actions);
 
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index 6ed5e94..b60f984 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -125,20 +125,18 @@ gtk_drag_source_site_destroy (gpointer data)
  * gtk_drag_source_set: (method)
  * @widget: a #GtkWidget
  * @start_button_mask: the bitmask of buttons that can start the drag
- * @targets: (allow-none) (array length=n_targets): the table of targets
- *     that the drag will support, may be %NULL
- * @n_targets: the number of items in @targets
+ * @targets: (allow-none): the targets that the drag will support,
+ *     may be %NULL
  * @actions: the bitmask of possible actions for a drag from this widget
  *
  * Sets up a widget so that GTK+ will start a drag operation when the user
  * clicks and drags on the widget. The widget must have a window.
  */
 void
-gtk_drag_source_set (GtkWidget            *widget,
-                     GdkModifierType       start_button_mask,
-                     const GtkTargetEntry *targets,
-                     gint                  n_targets,
-                     GdkDragAction         actions)
+gtk_drag_source_set (GtkWidget       *widget,
+                     GdkModifierType  start_button_mask,
+                     GtkTargetList   *targets,
+                     GdkDragAction    actions)
 {
   GtkDragSourceSite *site;
 
@@ -179,7 +177,10 @@ gtk_drag_source_set (GtkWidget            *widget,
 
   site->start_button_mask = start_button_mask;
 
-  site->target_list = gtk_target_list_new (targets, n_targets);
+  if (targets)
+    site->target_list = gtk_target_list_ref (targets);
+  else
+    site->target_list = NULL;
 
   site->actions = actions;
 }
diff --git a/gtk/gtkdragsource.h b/gtk/gtkdragsource.h
index cca2a97..8c1c6a2 100644
--- a/gtk/gtkdragsource.h
+++ b/gtk/gtkdragsource.h
@@ -40,8 +40,7 @@ G_BEGIN_DECLS
 GDK_AVAILABLE_IN_ALL
 void gtk_drag_source_set  (GtkWidget            *widget,
                           GdkModifierType       start_button_mask,
-                          const GtkTargetEntry *targets,
-                          gint                  n_targets,
+                          GtkTargetList        *targets,
                           GdkDragAction         actions);
 
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 185450d..9f5deca 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -2466,7 +2466,7 @@ gtk_entry_init (GtkEntry *entry)
   priv->caps_lock_warning = TRUE;
   priv->caps_lock_warning_shown = FALSE;
 
-  gtk_drag_dest_set (GTK_WIDGET (entry), 0, NULL, 0,
+  gtk_drag_dest_set (GTK_WIDGET (entry), 0, NULL,
                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
   gtk_drag_dest_add_text_targets (GTK_WIDGET (entry));
 
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 19f0f96..6090ef7 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -377,7 +377,7 @@ gtk_expander_init (GtkExpander *expander)
                                GTK_STYLE_CLASS_HORIZONTAL);
   gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
 
-  gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0, 0);
+  gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0);
   gtk_drag_dest_set_track_motion (GTK_WIDGET (expander), TRUE);
 
   priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (expander));
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 932c7fe..ae88e42 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -554,14 +554,13 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
                                      NULL, NULL);
 
   /* DnD */
-  gtk_drag_dest_set (GTK_WIDGET (button),
-                     (GTK_DEST_DEFAULT_ALL),
-                    NULL, 0,
-                    GDK_ACTION_COPY);
   target_list = gtk_target_list_new (NULL, 0);
   gtk_target_list_add_uri_targets (target_list, TEXT_URI_LIST);
   gtk_target_list_add_text_targets (target_list, TEXT_PLAIN);
-  gtk_drag_dest_set_target_list (GTK_WIDGET (button), target_list);
+  gtk_drag_dest_set (GTK_WIDGET (button),
+                     (GTK_DEST_DEFAULT_ALL),
+                    target_list,
+                    GDK_ACTION_COPY);
   gtk_target_list_unref (target_list);
 }
 
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 4176457..ffcd594 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -8555,13 +8555,13 @@ post_process_ui (GtkFileChooserWidget *impl)
                                           impl, NULL);
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->priv->browse_files_tree_view),
                                           GDK_BUTTON1_MASK,
-                                          NULL, 0,
+                                          NULL,
                                           GDK_ACTION_COPY | GDK_ACTION_MOVE);
   gtk_drag_source_add_uri_targets (impl->priv->browse_files_tree_view);
 
   gtk_drag_dest_set (impl->priv->browse_files_tree_view,
                      GTK_DEST_DEFAULT_ALL,
-                     NULL, 0,
+                     NULL,
                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
   gtk_drag_dest_add_uri_targets (impl->priv->browse_files_tree_view);
 
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 656a21a..48771e5 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -6555,9 +6555,7 @@ gtk_icon_view_drag_data_received (GtkWidget        *widget,
  * gtk_icon_view_enable_model_drag_source:
  * @icon_view: a #GtkIconView
  * @start_button_mask: Mask of allowed buttons to start drag
- * @targets: (array length=n_targets): the table of targets that the drag will
- *           support
- * @n_targets: the number of items in @targets
+ * @targets: the targets that the drag will support
  * @actions: the bitmask of possible actions for a drag from this
  *    widget
  *
@@ -6569,13 +6567,12 @@ gtk_icon_view_drag_data_received (GtkWidget        *widget,
 void
 gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
                                        GdkModifierType           start_button_mask,
-                                       const GtkTargetEntry     *targets,
-                                       gint                      n_targets,
+                                        GtkTargetList            *targets,
                                        GdkDragAction             actions)
 {
   g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
 
-  gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
+  gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, actions);
 
   icon_view->priv->start_button_mask = start_button_mask;
   icon_view->priv->source_actions = actions;
@@ -6588,9 +6585,7 @@ gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
 /**
  * gtk_icon_view_enable_model_drag_dest:
  * @icon_view: a #GtkIconView
- * @targets: (array length=n_targets): the table of targets that the drag will
- *           support
- * @n_targets: the number of items in @targets
+ * @targets: the targets that the drag will support
  * @actions: the bitmask of possible actions for a drag to this
  *    widget
  *
@@ -6600,14 +6595,13 @@ gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
  * Since: 2.8
  **/
 void 
-gtk_icon_view_enable_model_drag_dest (GtkIconView          *icon_view,
-                                     const GtkTargetEntry *targets,
-                                     gint                  n_targets,
-                                     GdkDragAction         actions)
+gtk_icon_view_enable_model_drag_dest (GtkIconView   *icon_view,
+                                      GtkTargetList *targets,
+                                     GdkDragAction  actions)
 {
   g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
 
-  gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
+  gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, actions);
 
   icon_view->priv->dest_actions = actions;
 
@@ -6943,15 +6937,15 @@ gtk_icon_view_set_reorderable (GtkIconView *icon_view,
 
   if (reorderable)
     {
+      GtkTargetList *targets = gtk_target_list_new (item_targets, G_N_ELEMENTS (item_targets));
       gtk_icon_view_enable_model_drag_source (icon_view,
                                              GDK_BUTTON1_MASK,
-                                             item_targets,
-                                             G_N_ELEMENTS (item_targets),
+                                             targets,
                                              GDK_ACTION_MOVE);
       gtk_icon_view_enable_model_drag_dest (icon_view,
-                                           item_targets,
-                                           G_N_ELEMENTS (item_targets),
+                                           targets,
                                            GDK_ACTION_MOVE);
+      gtk_target_list_unref (targets);
     }
   else
     {
diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h
index ee409f0..fc402c2 100644
--- a/gtk/gtkiconview.h
+++ b/gtk/gtkiconview.h
@@ -253,13 +253,11 @@ void             gtk_icon_view_scroll_to_path     (GtkIconView            *icon_
 GDK_AVAILABLE_IN_ALL
 void                   gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
                                                               GdkModifierType           start_button_mask,
-                                                              const GtkTargetEntry     *targets,
-                                                              gint                      n_targets,
+                                                              GtkTargetList            *targets,
                                                               GdkDragAction             actions);
 GDK_AVAILABLE_IN_ALL
 void                   gtk_icon_view_enable_model_drag_dest   (GtkIconView              *icon_view,
-                                                              const GtkTargetEntry     *targets,
-                                                              gint                      n_targets,
+                                                              GtkTargetList            *targets,
                                                               GdkDragAction             actions);
 GDK_AVAILABLE_IN_ALL
 void                   gtk_icon_view_unset_model_drag_source  (GtkIconView              *icon_view);
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index 382776a..de87bfa 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -218,6 +218,7 @@ gtk_link_button_init (GtkLinkButton *link_button)
 {
   GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
   GtkStyleContext *context;
+  GtkTargetList *targets;
 
   link_button->priv = priv;
 
@@ -232,10 +233,12 @@ gtk_link_button_init (GtkLinkButton *link_button)
                     G_CALLBACK (gtk_link_button_query_tooltip_cb), NULL);
 
   /* enable drag source */
+  targets = gtk_target_list_new (link_drop_types, G_N_ELEMENTS (link_drop_types));
   gtk_drag_source_set (GTK_WIDGET (link_button),
                       GDK_BUTTON1_MASK,
-                      link_drop_types, G_N_ELEMENTS (link_drop_types),
+                      targets,
                       GDK_ACTION_COPY);
+  gtk_target_list_unref (targets);
 
   priv->click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (link_button));
   gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->click_gesture), FALSE);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 65be844..419b48c 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -1050,6 +1050,7 @@ static void
 gtk_notebook_init (GtkNotebook *notebook)
 {
   GtkNotebookPrivate *priv;
+  GtkTargetList *targets;
 
   gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
   gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE);
@@ -1087,9 +1088,11 @@ gtk_notebook_init (GtkNotebook *notebook)
   else
     priv->tabs_reversed = FALSE;
 
+  targets = gtk_target_list_new (dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets));
   gtk_drag_dest_set (GTK_WIDGET (notebook), 0,
-                     dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets),
+                     targets,
                      GDK_ACTION_MOVE);
+  gtk_target_list_unref (targets);
 
   gtk_drag_dest_set_track_motion (GTK_WIDGET (notebook), TRUE);
 
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 7895a90..b461834 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -1549,7 +1549,7 @@ make_directory_button (GtkPathBar  *path_bar,
 
   gtk_drag_source_set (button_data->button,
                       GDK_BUTTON1_MASK,
-                      NULL, 0,
+                      NULL,
                       GDK_ACTION_COPY);
   gtk_drag_source_add_uri_targets (button_data->button);
   g_signal_connect (button_data->button, "drag-data-get",
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index acd866f..e758d2a 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -4072,7 +4072,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
   /* DND support */
   gtk_drag_dest_set (sidebar->list_box,
                      0,
-                     NULL, 0,
+                     NULL,
                      GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
   target_list = gtk_target_list_new  (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets));
   gtk_target_list_add_uri_targets (target_list, DND_TEXT_URI_LIST);
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 4eca2d4..49b949b 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -380,7 +380,7 @@ _gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl)
                                           NULL);
   gtk_drag_source_set (priv->recent_view,
                       GDK_BUTTON1_MASK,
-                      NULL, 0,
+                      NULL,
                       GDK_ACTION_COPY);
   gtk_drag_source_add_uri_targets (priv->recent_view);
 }
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 77d5670..06fd457 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -99,7 +99,7 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher)
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
 
-  gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0, 0);
+  gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0);
   gtk_drag_dest_set_track_motion (GTK_WIDGET (switcher), TRUE);
 }
 
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index f03428f..f322a20 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1659,7 +1659,7 @@ gtk_text_view_init (GtkTextView *text_view)
 
   priv->scroll_after_paste = TRUE;
 
-  gtk_drag_dest_set (widget, 0, NULL, 0,
+  gtk_drag_dest_set (widget, 0, NULL,
                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
   target_list = gtk_target_list_new (NULL, 0);
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index 19570f8..b2d85c3 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -1616,6 +1616,7 @@ gtk_tool_palette_add_drag_dest (GtkToolPalette            *palette,
 {
   GtkTargetEntry entries[G_N_ELEMENTS (dnd_targets)];
   gint n_entries = 0;
+  GtkTargetList *list;
 
   g_return_if_fail (GTK_IS_TOOL_PALETTE (palette));
   g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -1628,7 +1629,9 @@ gtk_tool_palette_add_drag_dest (GtkToolPalette            *palette,
   if (targets & GTK_TOOL_PALETTE_DRAG_GROUPS)
     entries[n_entries++] = dnd_targets[1];
 
-  gtk_drag_dest_set (widget, flags, entries, n_entries, actions);
+  list = gtk_target_list_new (entries, n_entries);
+  gtk_drag_dest_set (widget, flags, list, actions);
+  gtk_target_list_unref (list);
 }
 
 void
@@ -1727,6 +1730,8 @@ _gtk_tool_palette_child_set_drag_source (GtkWidget *child,
   if (GTK_IS_TOOL_ITEM (child) &&
       (palette->priv->drag_source & GTK_TOOL_PALETTE_DRAG_ITEMS))
     {
+      GtkTargetList *targets;
+
       /* Connect to child instead of the item itself,
        * to work arround bug 510377.
        */
@@ -1736,8 +1741,10 @@ _gtk_tool_palette_child_set_drag_source (GtkWidget *child,
       if (!child)
         return;
 
+      targets = gtk_target_list_new (&dnd_targets[0], 1);
       gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                           &dnd_targets[0], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+                           targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+      gtk_target_list_unref (targets);
 
       g_signal_connect (child, "drag-data-get",
                         G_CALLBACK (gtk_tool_palette_item_drag_data_get),
@@ -1746,8 +1753,12 @@ _gtk_tool_palette_child_set_drag_source (GtkWidget *child,
   else if (GTK_IS_BUTTON (child) &&
            (palette->priv->drag_source & GTK_TOOL_PALETTE_DRAG_GROUPS))
     {
+      GtkTargetList *targets;
+
+      targets = gtk_target_list_new (&dnd_targets[1], 1);
       gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                           &dnd_targets[1], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+                           targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+      gtk_target_list_unref (targets);
 
       g_signal_connect (child, "drag-data-get",
                         G_CALLBACK (gtk_tool_palette_child_drag_data_get),
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index e0d68b8..d623415 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -12549,15 +12549,16 @@ gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
       const GtkTargetEntry row_targets[] = {
         { (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
       };
+      GtkTargetList *targets;
+
+      targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
 
       gtk_tree_view_enable_model_drag_source (tree_view,
                                              GDK_BUTTON1_MASK,
-                                             row_targets,
-                                             G_N_ELEMENTS (row_targets),
+                                             targets,
                                              GDK_ACTION_MOVE);
       gtk_tree_view_enable_model_drag_dest (tree_view,
-                                           row_targets,
-                                           G_N_ELEMENTS (row_targets),
+                                           targets,
                                            GDK_ACTION_MOVE);
     }
   else
@@ -13534,8 +13535,7 @@ unset_reorderable (GtkTreeView *tree_view)
  * gtk_tree_view_enable_model_drag_source:
  * @tree_view: a #GtkTreeView
  * @start_button_mask: Mask of allowed buttons to start drag
- * @targets: (array length=n_targets): the table of targets that the drag will support
- * @n_targets: the number of items in @targets
+ * @targets: the targets that the drag will support
  * @actions: the bitmask of possible actions for a drag from this
  *    widget
  *
@@ -13543,11 +13543,10 @@ unset_reorderable (GtkTreeView *tree_view)
  * method sets #GtkTreeView:reorderable to %FALSE.
  **/
 void
-gtk_tree_view_enable_model_drag_source (GtkTreeView              *tree_view,
-                                       GdkModifierType           start_button_mask,
-                                       const GtkTargetEntry     *targets,
-                                       gint                      n_targets,
-                                       GdkDragAction             actions)
+gtk_tree_view_enable_model_drag_source (GtkTreeView     *tree_view,
+                                       GdkModifierType  start_button_mask,
+                                       GtkTargetList   *targets,
+                                       GdkDragAction    actions)
 {
   TreeViewDragInfo *di;
 
@@ -13556,7 +13555,6 @@ gtk_tree_view_enable_model_drag_source (GtkTreeView              *tree_view,
   gtk_drag_source_set (GTK_WIDGET (tree_view),
                       0,
                       targets,
-                      n_targets,
                       actions);
 
   di = ensure_info (tree_view);
@@ -13571,8 +13569,7 @@ gtk_tree_view_enable_model_drag_source (GtkTreeView              *tree_view,
 /**
  * gtk_tree_view_enable_model_drag_dest:
  * @tree_view: a #GtkTreeView
- * @targets: (array length=n_targets): the table of targets that
- *           the drag will support
+ * @targets: the targets that the drag will support
  * @n_targets: the number of items in @targets
  * @actions: the bitmask of possible actions for a drag from this
  *    widget
@@ -13581,10 +13578,9 @@ gtk_tree_view_enable_model_drag_source (GtkTreeView              *tree_view,
  * this method sets #GtkTreeView:reorderable to %FALSE.
  **/
 void
-gtk_tree_view_enable_model_drag_dest (GtkTreeView              *tree_view,
-                                     const GtkTargetEntry     *targets,
-                                     gint                      n_targets,
-                                     GdkDragAction             actions)
+gtk_tree_view_enable_model_drag_dest (GtkTreeView   *tree_view,
+                                     GtkTargetList *targets,
+                                     GdkDragAction  actions)
 {
   TreeViewDragInfo *di;
 
@@ -13593,7 +13589,6 @@ gtk_tree_view_enable_model_drag_dest (GtkTreeView              *tree_view,
   gtk_drag_dest_set (GTK_WIDGET (tree_view),
                      0,
                      targets,
-                     n_targets,
                      actions);
 
   di = ensure_info (tree_view);
diff --git a/gtk/gtktreeview.h b/gtk/gtktreeview.h
index da4062b..147e568 100644
--- a/gtk/gtktreeview.h
+++ b/gtk/gtktreeview.h
@@ -382,13 +382,11 @@ gboolean               gtk_tree_view_is_blank_at_pos               (GtkTreeView
 GDK_AVAILABLE_IN_ALL
 void                   gtk_tree_view_enable_model_drag_source      (GtkTreeView               *tree_view,
                                                                    GdkModifierType            
start_button_mask,
-                                                                   const GtkTargetEntry      *targets,
-                                                                   gint                       n_targets,
+                                                                   GtkTargetList             *targets,
                                                                    GdkDragAction              actions);
 GDK_AVAILABLE_IN_ALL
 void                   gtk_tree_view_enable_model_drag_dest        (GtkTreeView               *tree_view,
-                                                                   const GtkTargetEntry      *targets,
-                                                                   gint                       n_targets,
+                                                                   GtkTargetList             *targets,
                                                                    GdkDragAction              actions);
 GDK_AVAILABLE_IN_ALL
 void                   gtk_tree_view_unset_rows_drag_source        (GtkTreeView               *tree_view);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5b19d75..340ee59 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1844,6 +1844,7 @@ gtk_window_init (GtkWindow *window)
   GtkWidget *widget;
   GtkCssNode *widget_node;
   GdkSeat *seat;
+  GtkTargetList *targets;
 
   widget = GTK_WIDGET (window);
 
@@ -1905,10 +1906,12 @@ gtk_window_init (GtkWindow *window)
 
   priv->scale = gtk_widget_get_scale_factor (widget);
 
+  targets = gtk_target_list_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets));
   gtk_drag_dest_set (GTK_WIDGET (window),
                      GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
-                     dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets),
+                     targets,
                      GDK_ACTION_MOVE);
+  gtk_target_list_unref (targets);
 
   seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
   g_signal_connect (seat, "device-removed",
diff --git a/tests/testdnd.c b/tests/testdnd.c
index c93c2e9..be3a963 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -496,11 +496,13 @@ popup_cb (gpointer data)
          GtkWidget *button;
          GtkWidget *grid;
          int i, j;
+          GtkTargetList *targets;
          
          popup_window = gtk_window_new (GTK_WINDOW_POPUP);
          gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_MOUSE);
 
          grid = gtk_grid_new ();
+          targets = gtk_target_list_new (target_table, n_targets - 1); /* no rootwin */
 
          for (i=0; i<3; i++)
            for (j=0; j<3; j++)
@@ -514,7 +516,7 @@ popup_cb (gpointer data)
 
                gtk_drag_dest_set (button,
                                   GTK_DEST_DEFAULT_ALL,
-                                  target_table, n_targets - 1, /* no rootwin */
+                                   targets,
                                   GDK_ACTION_COPY | GDK_ACTION_MOVE);
                g_signal_connect (button, "drag_motion",
                                  G_CALLBACK (popup_motion), NULL);
@@ -522,6 +524,7 @@ popup_cb (gpointer data)
                                  G_CALLBACK (popup_leave), NULL);
              }
          gtk_container_add (GTK_CONTAINER (popup_window), grid);
+          gtk_target_list_unref (targets);
 
        }
       gtk_widget_show (popup_window);
@@ -585,6 +588,7 @@ main (int argc, char **argv)
   GtkWidget *pixmap;
   GtkWidget *button;
   GdkPixbuf *drag_icon;
+  GtkTargetList *targets;
 
   test_init ();
   
@@ -604,9 +608,10 @@ main (int argc, char **argv)
   
   label = gtk_label_new ("Drop Here\n");
 
+  targets = gtk_target_list_new (target_table, n_targets - 1); /* no rootwin */
   gtk_drag_dest_set (label,
                     GTK_DEST_DEFAULT_ALL,
-                    target_table, n_targets - 1, /* no rootwin */
+                     targets,
                     GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
   g_signal_connect (label, "drag_data_received",
@@ -620,7 +625,7 @@ main (int argc, char **argv)
 
   gtk_drag_dest_set (label,
                     GTK_DEST_DEFAULT_ALL,
-                    target_table, n_targets - 1, /* no rootwin */
+                     targets,
                     GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
   gtk_widget_set_hexpand (label, TRUE);
@@ -631,9 +636,10 @@ main (int argc, char **argv)
                    G_CALLBACK (popsite_motion), NULL);
   g_signal_connect (label, "drag_leave",
                    G_CALLBACK (popsite_leave), NULL);
+  gtk_target_list_unref (targets);
   
   pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
-  gtk_drag_dest_set (pixmap, 0, NULL, 0, 0);
+  gtk_drag_dest_set (pixmap, 0, NULL, 0);
   gtk_widget_set_hexpand (pixmap, TRUE);
   gtk_widget_set_vexpand (pixmap, TRUE);
   gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
@@ -654,10 +660,12 @@ main (int argc, char **argv)
 
   button = gtk_button_new_with_label ("Drag Here\n");
 
+  targets = gtk_target_list_new (target_table, n_targets);
   gtk_drag_source_set (button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
-                      target_table, n_targets, 
+                       targets,
                       GDK_ACTION_COPY | GDK_ACTION_MOVE);
   gtk_drag_source_set_icon_pixbuf (button, drag_icon);
+  gtk_target_list_unref (targets);
 
   g_object_unref (drag_icon);
 
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index fe0e2ec..67d0bb9 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -226,7 +226,7 @@ make_image (const gchar *icon_name, int hotspot)
 
   image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
 
-  gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
   update_source_target_list (image);
 
   g_object_set_data  (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
@@ -234,7 +234,7 @@ make_image (const gchar *icon_name, int hotspot)
   g_signal_connect (image, "drag-begin", G_CALLBACK (image_drag_begin), image);
   g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
 
-  gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
   g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
   update_dest_target_list (image);
 
@@ -248,7 +248,7 @@ make_image2 (const gchar *icon_name, int hotspot)
 
   image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
 
-  gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
   update_source_target_list (image);
 
   g_object_set_data  (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
@@ -256,7 +256,7 @@ make_image2 (const gchar *icon_name, int hotspot)
   g_signal_connect (image, "drag-begin", G_CALLBACK (window_drag_begin), image);
   g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
 
-  gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
   g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
   update_dest_target_list (image);
 
@@ -328,7 +328,7 @@ make_spinner (void)
   spinner = gtk_spinner_new ();
   gtk_spinner_start (GTK_SPINNER (spinner));
 
-  gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+  gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
   gtk_drag_source_add_text_targets (spinner);
 
   g_signal_connect (spinner, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
diff --git a/tests/testiconview.c b/tests/testiconview.c
index ef7e85f..ba93785 100644
--- a/tests/testiconview.c
+++ b/tests/testiconview.c
@@ -425,6 +425,7 @@ main (gint argc, gchar **argv)
   GtkTreeModel *model;
   GtkCellRenderer *cell;
   GtkTreeViewColumn *tvc;
+  GtkTargetList *targets;
   
 #ifdef GTK_SRCDIR
   g_chdir (GTK_SRCDIR);
@@ -527,26 +528,23 @@ main (gint argc, gchar **argv)
 #endif
   /* Allow DND between the icon view and the tree view */
   
+  targets = gtk_target_list_new (item_targets, G_N_ELEMENTS (item_targets));
   gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (icon_list),
                                          GDK_BUTTON1_MASK,
-                                         item_targets,
-                                         G_N_ELEMENTS (item_targets),
+                                          targets,
                                          GDK_ACTION_MOVE);
   gtk_icon_view_enable_model_drag_dest (GTK_ICON_VIEW (icon_list),
-                                       item_targets,
-                                       G_N_ELEMENTS (item_targets),
+                                        targets,
                                        GDK_ACTION_MOVE);
 
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
                                          GDK_BUTTON1_MASK,
-                                         item_targets,
-                                         G_N_ELEMENTS (item_targets),
+                                          targets,
                                          GDK_ACTION_MOVE);
   gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
-                                       item_targets,
-                                       G_N_ELEMENTS (item_targets),
+                                        targets,
                                        GDK_ACTION_MOVE);
-
+  gtk_target_list_unref (targets);
                              
   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
   gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list);
diff --git a/tests/testimage.c b/tests/testimage.c
index a9be868..e246635 100644
--- a/tests/testimage.c
+++ b/tests/testimage.c
@@ -115,7 +115,7 @@ main (int argc, char **argv)
   gtk_grid_attach (GTK_GRID (grid), image, 2, 1, 1, 1);
 
   gtk_drag_source_set (image, GDK_BUTTON1_MASK, 
-                      NULL, 0,
+                      NULL,
                       GDK_ACTION_COPY);
   gtk_drag_source_add_image_targets (image);
   g_signal_connect (image, "drag_begin", G_CALLBACK (drag_begin), image);
@@ -125,7 +125,7 @@ main (int argc, char **argv)
                      GTK_DEST_DEFAULT_MOTION |
                      GTK_DEST_DEFAULT_HIGHLIGHT |
                      GTK_DEST_DEFAULT_DROP,
-                     NULL, 0, GDK_ACTION_COPY);
+                     NULL, GDK_ACTION_COPY);
   gtk_drag_dest_add_image_targets (image);
   g_signal_connect (image, "drag_data_received",
                    G_CALLBACK (drag_data_received), image);
diff --git a/tests/testkineticscrolling.c b/tests/testkineticscrolling.c
index fe412d0..6f9fe29 100644
--- a/tests/testkineticscrolling.c
+++ b/tests/testkineticscrolling.c
@@ -26,6 +26,7 @@ kinetic_scrolling (void)
   GtkCellRenderer *renderer;
   GtkListStore *store;
   GtkWidget *textview;
+  GtkTargetList *targets;
   gint i;
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -75,15 +76,15 @@ kinetic_scrolling (void)
   gtk_widget_show (swindow);
 
   treeview = gtk_tree_view_new ();
+  targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview),
                                           GDK_BUTTON1_MASK,
-                                          row_targets,
-                                          G_N_ELEMENTS (row_targets),
+                                          targets,
                                           GDK_ACTION_MOVE | GDK_ACTION_COPY);
   gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (treeview),
-                                        row_targets,
-                                        G_N_ELEMENTS (row_targets),
+                                        targets,
                                         GDK_ACTION_MOVE | GDK_ACTION_COPY);
+  gtk_target_list_unref (targets);
 
   renderer = gtk_cell_renderer_text_new ();
   g_object_set (renderer, "editable", TRUE, NULL);
diff --git a/tests/testlist3.c b/tests/testlist3.c
index 68bf677..aa99b34 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -83,6 +83,7 @@ static GtkWidget *
 create_row (const gchar *text)
 {
   GtkWidget *row, *box, *label, *image;
+  GtkTargetList *targets;
 
   row = gtk_list_box_row_new (); 
   image = gtk_image_new_from_icon_name ("open-menu-symbolic", 1);
@@ -94,13 +95,17 @@ create_row (const gchar *text)
   gtk_container_add (GTK_CONTAINER (box), label);
   gtk_container_add (GTK_CONTAINER (box), image);
 
-  gtk_drag_source_set (image, GDK_BUTTON1_MASK, entries, 1, GDK_ACTION_MOVE);
+  targets = gtk_target_list_new (entries, 1);
+
+  gtk_drag_source_set (image, GDK_BUTTON1_MASK, targets, GDK_ACTION_MOVE);
   g_signal_connect (image, "drag-begin", G_CALLBACK (drag_begin), NULL);
   g_signal_connect (image, "drag-data-get", G_CALLBACK (drag_data_get), NULL);
 
-  gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, entries, 1, GDK_ACTION_MOVE);
+  gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_MOVE);
   g_signal_connect (row, "drag-data-received", G_CALLBACK (drag_data_received), NULL);
 
+  gtk_target_list_unref (targets);
+
   return row;
 }
 
diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c
index bf050e4..3bda059 100644
--- a/tests/testnotebookdnd.c
+++ b/tests/testnotebookdnd.c
@@ -301,15 +301,17 @@ create_notebook_with_notebooks (gchar           **labels,
 static GtkWidget*
 create_trash_button (void)
 {
+  GtkTargetList *targets;
   GtkWidget *button;
 
   button = gtk_button_new_with_mnemonic ("_Delete");
 
+  targets = gtk_target_list_new (button_targets, G_N_ELEMENTS (button_targets));
   gtk_drag_dest_set (button,
                      GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
-                     button_targets,
-                     G_N_ELEMENTS (button_targets),
+                     targets,
                      GDK_ACTION_MOVE);
+  gtk_target_list_unref (targets);
 
   g_signal_connect_after (G_OBJECT (button), "drag-data-received",
                           G_CALLBACK (on_button_drag_data_received), NULL);
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
index 8b18e3e..12a7762 100644
--- a/tests/testtoolbar.c
+++ b/tests/testtoolbar.c
@@ -479,6 +479,7 @@ main (gint argc, gchar **argv)
   GtkWidget *window, *toolbar, *grid, *treeview, *scrolled_window;
   GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
   gint i;
+  GtkTargetList *targets;
   static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
                                           "both (horizontal)" };
   GtkToolItem *item;
@@ -712,12 +713,14 @@ main (gint argc, gchar **argv)
 
   gtk_box_pack_end (GTK_BOX (hbox), checkbox);
 
+  targets = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
   gtk_drag_source_set (button, GDK_BUTTON1_MASK,
-                      target_table, G_N_ELEMENTS (target_table),
+                       targets,
                       GDK_ACTION_MOVE);
   gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
-                    target_table, G_N_ELEMENTS (target_table),
+                     targets,
                     GDK_ACTION_MOVE);
+  gtk_target_list_unref (targets);
   g_signal_connect (toolbar, "drag_motion",
                    G_CALLBACK (toolbar_drag_motion), NULL);
   g_signal_connect (toolbar, "drag_leave",
diff --git a/tests/testtreecolumns.c b/tests/testtreecolumns.c
index 7112643..5fb8267 100644
--- a/tests/testtreecolumns.c
+++ b/tests/testtreecolumns.c
@@ -718,6 +718,7 @@ main (int argc, char *argv[])
   GtkCellRenderer *cell;
   GtkWidget *swindow;
   GtkTreeModel *sample_model;
+  GtkTargetList *targets;
   gint i;
 
   gtk_init ();
@@ -863,36 +864,31 @@ main (int argc, char *argv[])
 
 
   /* Drag and Drop */
+  targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (left_tree_view),
                                          GDK_BUTTON1_MASK,
-                                         row_targets,
-                                         G_N_ELEMENTS (row_targets),
+                                          targets,
                                          GDK_ACTION_MOVE);
   gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (left_tree_view),
-                                       row_targets,
-                                       G_N_ELEMENTS (row_targets),
+                                       targets,
                                        GDK_ACTION_MOVE);
 
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (top_right_tree_view),
                                          GDK_BUTTON1_MASK,
-                                         row_targets,
-                                         G_N_ELEMENTS (row_targets),
+                                         targets,
                                          GDK_ACTION_MOVE);
   gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (top_right_tree_view),
-                                       row_targets,
-                                       G_N_ELEMENTS (row_targets),
+                                       targets,
                                        GDK_ACTION_MOVE);
 
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (bottom_right_tree_view),
                                          GDK_BUTTON1_MASK,
-                                         row_targets,
-                                         G_N_ELEMENTS (row_targets),
+                                         targets,
                                          GDK_ACTION_MOVE);
   gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (bottom_right_tree_view),
-                                       row_targets,
-                                       G_N_ELEMENTS (row_targets),
+                                       targets,
                                        GDK_ACTION_MOVE);
-
+  gtk_target_list_unref (targets);
 
   gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
 
diff --git a/tests/testtreednd.c b/tests/testtreednd.c
index 96a8f9e..37eef92 100644
--- a/tests/testtreednd.c
+++ b/tests/testtreednd.c
@@ -73,6 +73,7 @@ get_dragsource (void)
   GtkTreeView *tv;
   GtkCellRenderer *renderer;
   GtkTreeViewColumn *column;
+  GtkTargetList *targets;
 
   tv = (GtkTreeView*) gtk_tree_view_new ();
   renderer = gtk_cell_renderer_text_new ();
@@ -80,7 +81,9 @@ get_dragsource (void)
   gtk_tree_view_append_column (tv, column);
 
   gtk_tree_view_set_model (tv, get_model ());
-  gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, entries, G_N_ELEMENTS (entries), 
GDK_ACTION_COPY);
+  targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
+  gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, targets, GDK_ACTION_COPY);
+  gtk_target_list_unref (targets);
 
   return GTK_WIDGET (tv);
 }
@@ -104,10 +107,13 @@ static GtkWidget *
 get_droptarget (void)
 {
   GtkWidget *label;
+  GtkTargetList *targets;
 
   label = gtk_label_new ("Drop here");
-  gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, entries, G_N_ELEMENTS (entries), GDK_ACTION_COPY);
+  targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
+  gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_COPY);
   g_signal_connect (label, "drag-data-received", G_CALLBACK (data_received), NULL);
+  gtk_target_list_unref (targets);
 
   return label;
 }
diff --git a/tests/testtreeview.c b/tests/testtreeview.c
index 2dd7930..d73551a 100644
--- a/tests/testtreeview.c
+++ b/tests/testtreeview.c
@@ -661,6 +661,7 @@ main (int    argc,
   GtkWidget *box;
   GtkWidget *combo_box;
   GtkTreeModel *model;
+  GtkTargetList *targets;
   gint i;
   
   gtk_init ();
@@ -702,16 +703,16 @@ main (int    argc,
   tv = gtk_tree_view_new_with_model (models[0]);
   g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL);
 
+  targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
                                          GDK_BUTTON1_MASK,
-                                         row_targets,
-                                         G_N_ELEMENTS (row_targets),
+                                          targets,
                                          GDK_ACTION_MOVE | GDK_ACTION_COPY);
 
   gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
-                                       row_targets,
-                                       G_N_ELEMENTS (row_targets),
+                                        targets,
                                        GDK_ACTION_MOVE | GDK_ACTION_COPY);
+  gtk_target_list_unref (targets);
   
   /* Model menu */
   combo_box = gtk_combo_box_text_new ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]