summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-14 22:32:23 +0100
committerBenjamin Otte <otte@redhat.com>2017-11-15 19:07:17 +0100
commit5a1a11bcde0acacb455fc3df10d6bd8f67f62850 (patch)
tree859a7f528af6d5407eed89fd127914ac3103f7c9 /tests
parent7efc5a1558449194caedaae5f27e4c9c48d88ab7 (diff)
downloadgtk+-5a1a11bcde0acacb455fc3df10d6bd8f67f62850.tar.gz
dnd: Make GtkDragDest and GtkDragSource use GtkTargetList
This gets rid of GtkTargetEntry in the API and consistently uses GtkTargetList.
Diffstat (limited to 'tests')
-rw-r--r--tests/testdnd.c18
-rw-r--r--tests/testdnd2.c10
-rw-r--r--tests/testiconview.c16
-rw-r--r--tests/testimage.c4
-rw-r--r--tests/testkineticscrolling.c9
-rw-r--r--tests/testlist3.c9
-rw-r--r--tests/testnotebookdnd.c6
-rw-r--r--tests/testtoolbar.c7
-rw-r--r--tests/testtreecolumns.c22
-rw-r--r--tests/testtreednd.c10
-rw-r--r--tests/testtreeview.c9
11 files changed, 70 insertions, 50 deletions
diff --git a/tests/testdnd.c b/tests/testdnd.c
index c93c2e9e7f..be3a963451 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 fe0e2eca07..67d0bb99ca 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 ef7e85f8e6..ba93785d84 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 a9be8683d2..e246635c6d 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 fe412d0fa7..6f9fe2993c 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 68bf67761c..aa99b342f7 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 bf050e4e53..3bda059c86 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 8b18e3e09d..12a776239c 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 7112643ba6..5fb8267000 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 96a8f9ee38..37eef92faf 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 2dd7930b9b..d73551aa0e 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 ();