summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/testiconview.c6
-rw-r--r--tests/testkineticscrolling.c7
-rw-r--r--tests/testtreecolumns.c38
-rw-r--r--tests/testtreednd.c39
-rw-r--r--tests/testtreeview.c6
5 files changed, 34 insertions, 62 deletions
diff --git a/tests/testiconview.c b/tests/testiconview.c
index bd5eeae3cb..9b87c41a38 100644
--- a/tests/testiconview.c
+++ b/tests/testiconview.c
@@ -389,10 +389,6 @@ popup_menu_handler (GtkWidget *widget)
return TRUE;
}
-static const char *item_targets[] = {
- "GTK_TREE_MODEL_ROW"
-};
-
gint
main (gint argc, gchar **argv)
{
@@ -506,7 +502,7 @@ main (gint argc, gchar **argv)
#endif
/* Allow DND between the icon view and the tree view */
- targets = gdk_content_formats_new (item_targets, G_N_ELEMENTS (item_targets));
+ targets = gdk_content_formats_new_for_gtype (GTK_TYPE_TREE_ROW_DATA);
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (icon_list),
GDK_BUTTON1_MASK,
targets,
diff --git a/tests/testkineticscrolling.c b/tests/testkineticscrolling.c
index eaac76cbe0..ca9f2581e4 100644
--- a/tests/testkineticscrolling.c
+++ b/tests/testkineticscrolling.c
@@ -1,10 +1,5 @@
#include <gtk/gtk.h>
-static const char *row_targets[] =
-{
- "GTK_TREE_MODEL_ROW"
-};
-
static void
on_button_clicked (GtkWidget *widget, gpointer data)
{
@@ -83,7 +78,7 @@ kinetic_scrolling (void)
gtk_widget_show (swindow);
treeview = gtk_tree_view_new ();
- targets = gdk_content_formats_new (row_targets, G_N_ELEMENTS (row_targets));
+ targets = gdk_content_formats_new_for_gtype (GTK_TYPE_TREE_ROW_DATA);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview),
GDK_BUTTON1_MASK,
targets,
diff --git a/tests/testtreecolumns.c b/tests/testtreecolumns.c
index c71f2c912a..6ad42964a5 100644
--- a/tests/testtreecolumns.c
+++ b/tests/testtreecolumns.c
@@ -268,17 +268,11 @@ view_column_model_tree_model_init (GtkTreeModelIface *iface)
iface->iter_parent = view_column_model_iter_parent;
}
-static gboolean
-view_column_model_drag_data_get (GtkTreeDragSource *drag_source,
- GtkTreePath *path,
- GtkSelectionData *selection_data)
-{
- if (gtk_tree_set_row_drag_data (selection_data,
- GTK_TREE_MODEL (drag_source),
- path))
- return TRUE;
- else
- return FALSE;
+static GdkContentProvider *
+view_column_model_drag_data_get (GtkTreeDragSource *drag_source,
+ GtkTreePath *path)
+{
+ return gtk_tree_create_row_drag_content (GTK_TREE_MODEL (drag_source), path);
}
static gboolean
@@ -291,13 +285,13 @@ view_column_model_drag_data_delete (GtkTreeDragSource *drag_source,
}
static gboolean
-view_column_model_row_drop_possible (GtkTreeDragDest *drag_dest,
- GtkTreePath *dest_path,
- GtkSelectionData *selection_data)
+view_column_model_row_drop_possible (GtkTreeDragDest *drag_dest,
+ GtkTreePath *dest_path,
+ const GValue *value)
{
GtkTreeModel *src_model;
- if (gtk_tree_get_row_drag_data (selection_data,
+ if (gtk_tree_get_row_drag_data (value,
&src_model,
NULL))
{
@@ -311,15 +305,15 @@ view_column_model_row_drop_possible (GtkTreeDragDest *drag_dest,
}
static gboolean
-view_column_model_drag_data_received (GtkTreeDragDest *drag_dest,
- GtkTreePath *dest,
- GtkSelectionData *selection_data)
+view_column_model_drag_data_received (GtkTreeDragDest *drag_dest,
+ GtkTreePath *dest,
+ const GValue *value)
{
GtkTreeModel *src_model;
GtkTreePath *src_path = NULL;
gboolean retval = FALSE;
- if (gtk_tree_get_row_drag_data (selection_data,
+ if (gtk_tree_get_row_drag_data (value,
&src_model,
&src_path))
{
@@ -703,10 +697,6 @@ selection_changed (GtkTreeSelection *selection, GtkWidget *button)
gtk_widget_set_sensitive (button, FALSE);
}
-static const char *row_targets[] = {
- "GTK_TREE_MODEL_ROW"
-};
-
static void
quit_cb (GtkWidget *widget,
gpointer data)
@@ -874,7 +864,7 @@ main (int argc, char *argv[])
/* Drag and Drop */
- targets = gdk_content_formats_new (row_targets, G_N_ELEMENTS (row_targets));
+ targets = gdk_content_formats_new_for_gtype (GTK_TYPE_TREE_ROW_DATA);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (left_tree_view),
GDK_BUTTON1_MASK,
targets,
diff --git a/tests/testtreednd.c b/tests/testtreednd.c
index 16efa7e302..c087527ce3 100644
--- a/tests/testtreednd.c
+++ b/tests/testtreednd.c
@@ -22,20 +22,20 @@ my_model_init (MyModel *object)
gtk_list_store_set_column_types (GTK_LIST_STORE (object), G_N_ELEMENTS (types), types);
}
-static gboolean
+static GdkContentProvider *
my_model_drag_data_get (GtkTreeDragSource *source,
- GtkTreePath *path,
- GtkSelectionData *data)
+ GtkTreePath *path)
{
+ GdkContentProvider *content;
GtkTreeIter iter;
gchar *text;
gtk_tree_model_get_iter (GTK_TREE_MODEL (source), &iter, path);
gtk_tree_model_get (GTK_TREE_MODEL (source), &iter, 0, &text, -1);
- gtk_selection_data_set_text (data, text, -1);
+ content = gdk_content_provider_new_typed (G_TYPE_STRING, text);
g_free (text);
- return TRUE;
+ return content;
}
static void
@@ -63,10 +63,6 @@ get_model (void)
return GTK_TREE_MODEL (model);
}
-static const char *entries[] = {
- "text/plain"
-};
-
static GtkWidget *
get_dragsource (void)
{
@@ -81,7 +77,7 @@ get_dragsource (void)
gtk_tree_view_append_column (tv, column);
gtk_tree_view_set_model (tv, get_model ());
- targets = gdk_content_formats_new (entries, G_N_ELEMENTS (entries));
+ targets = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, targets, GDK_ACTION_COPY);
gdk_content_formats_unref (targets);
@@ -93,18 +89,15 @@ got_text (GObject *source,
GAsyncResult *result,
gpointer data)
{
- GtkDropTarget *dest = GTK_DROP_TARGET (source);
- GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
- gchar *text;
- GtkSelectionData *selda;
+ GdkDrop *drop = GDK_DROP (source);
+ GtkWidget *widget = data;
+ const GValue *value;
- selda = gtk_drop_target_read_selection_finish (dest, result, NULL);
+ value = gdk_drop_read_value_finish (drop, result, NULL);
+ if (value == NULL)
+ return;
- text = (gchar*) gtk_selection_data_get_text (selda);
- gtk_label_set_label (GTK_LABEL (widget), text);
- g_free (text);
-
- gtk_selection_data_free (selda);
+ gtk_label_set_label (GTK_LABEL (widget), g_value_get_string (value));
}
static void
@@ -114,7 +107,9 @@ drag_drop (GtkDropTarget *dest,
int y,
gpointer dada)
{
- gtk_drop_target_read_selection (dest, "text/plain", NULL, got_text, dada);
+ GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
+
+ gdk_drop_read_value_async (drop, G_TYPE_STRING, G_PRIORITY_DEFAULT, NULL, got_text, widget);
}
static GtkWidget *
@@ -124,7 +119,7 @@ get_droptarget (void)
GtkDropTarget *dest;
label = gtk_label_new ("Drop here");
- dest = gtk_drop_target_new (gdk_content_formats_new (entries, G_N_ELEMENTS (entries)), GDK_ACTION_COPY);
+ dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (G_TYPE_STRING), GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), NULL);
gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
diff --git a/tests/testtreeview.c b/tests/testtreeview.c
index ffa06867e2..8df5ca4925 100644
--- a/tests/testtreeview.c
+++ b/tests/testtreeview.c
@@ -641,10 +641,6 @@ on_row_activated (GtkTreeView *tree_view,
g_print ("Row activated\n");
}
-static const char *row_targets[] = {
- "GTK_TREE_MODEL_ROW"
-};
-
static void
quit_cb (GtkWidget *widget,
gpointer data)
@@ -709,7 +705,7 @@ 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 = gdk_content_formats_new (row_targets, G_N_ELEMENTS (row_targets));
+ targets = gdk_content_formats_new_for_gtype (GTK_TYPE_TREE_ROW_DATA);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
GDK_BUTTON1_MASK,
targets,