summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-08-31 17:06:48 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-08-31 17:15:05 -0400
commit8d79a32c50a6f40de935b845ae9529147a705fa3 (patch)
treef5a95adb30fb48dd1620f6edf9221fbb87182906 /tests
parentd2d8b748e9d5458b8dacaa7c875a1e8bf10884a4 (diff)
downloadgtk+-8d79a32c50a6f40de935b845ae9529147a705fa3.tar.gz
list widgets: Use selection models in the api
Change the apis in GtkListView, GtkColumnView and GtkGridView to be explicitly about GtkSelectionModel, to make it obvious that the widgets handle selection. Update all users.
Diffstat (limited to 'tests')
-rw-r--r--tests/testcolumnview.c7
-rw-r--r--tests/testlistdnd.c8
-rw-r--r--tests/testlistview-animating.c5
-rw-r--r--tests/testlistview.c2
4 files changed, 14 insertions, 8 deletions
diff --git a/tests/testcolumnview.c b/tests/testcolumnview.c
index 58638b9adf..725ce67b7a 100644
--- a/tests/testcolumnview.c
+++ b/tests/testcolumnview.c
@@ -694,6 +694,7 @@ main (int argc, char *argv[])
GtkBuilderScope *scope;
GtkBuilder *builder;
GError *error = NULL;
+ GtkSelectionModel *selection;
gtk_init ();
@@ -759,7 +760,9 @@ main (int argc, char *argv[])
filter = gtk_filter_list_model_new (G_LIST_MODEL (sort), custom_filter);
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
- gtk_column_view_set_model (GTK_COLUMN_VIEW (view), G_LIST_MODEL (filter));
+ selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (filter)));
+ gtk_column_view_set_model (GTK_COLUMN_VIEW (view), selection);
+ g_object_unref (selection);
statusbar = gtk_statusbar_new ();
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);
@@ -771,7 +774,7 @@ main (int argc, char *argv[])
g_object_unref (filter);
list = gtk_list_view_new_with_factory (
- g_object_ref (gtk_column_view_get_columns (GTK_COLUMN_VIEW (view))),
+ GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (gtk_column_view_get_columns (GTK_COLUMN_VIEW (view))))),
gtk_builder_list_item_factory_new_from_bytes (scope, g_bytes_new_static (factory_ui, strlen (factory_ui))));
gtk_box_append (GTK_BOX (hbox), list);
diff --git a/tests/testlistdnd.c b/tests/testlistdnd.c
index b58cf82c7d..899ed1edc1 100644
--- a/tests/testlistdnd.c
+++ b/tests/testlistdnd.c
@@ -348,7 +348,7 @@ main (int argc, char *argv[])
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), NULL);
- grid = gtk_grid_view_new_with_factory (model, factory);
+ grid = gtk_grid_view_new_with_factory (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
gtk_grid_view_set_min_columns (GTK_GRID_VIEW (grid), 20);
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (grid), 20);
@@ -359,7 +359,7 @@ main (int argc, char *argv[])
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_stack_add_titled (GTK_STACK (stack), sw, "list", "GtkListView");
- list = gtk_list_view_new (create_model (0, 400, 1, FALSE));
+ list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (create_model (0, 400, 1, FALSE))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
factory = gtk_signal_list_item_factory_new ();
@@ -375,7 +375,7 @@ main (int argc, char *argv[])
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_stack_add_titled (GTK_STACK (stack), sw, "column", "GtkColumnView");
- cv = gtk_column_view_new (create_model (0, 400, 1, FALSE));
+ cv = gtk_column_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (create_model (0, 400, 1, FALSE))));
for (guint i = 0; i < 20; i++)
{
@@ -401,7 +401,7 @@ main (int argc, char *argv[])
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_stack_add_titled (GTK_STACK (stack), sw, "tree", "Tree");
- list = gtk_list_view_new (create_tree_model (20, 20));
+ list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (create_tree_model (20, 20))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
factory = gtk_signal_list_item_factory_new ();
diff --git a/tests/testlistview-animating.c b/tests/testlistview-animating.c
index 1baac2a7b9..70aa4a1de6 100644
--- a/tests/testlistview-animating.c
+++ b/tests/testlistview-animating.c
@@ -119,6 +119,7 @@ main (int argc,
GtkSorter *sorter;
guint i;
GtkListItemFactory *factory;
+ GtkSelectionModel *selection;
gtk_init ();
@@ -166,7 +167,9 @@ main (int argc,
listbox = gtk_list_box_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listbox);
- gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (sort));
+ selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (sort)));
+ gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
+ g_object_unref (selection);
gtk_list_box_bind_model (GTK_LIST_BOX (listbox),
G_LIST_MODEL (sort),
create_widget_for_listbox,
diff --git a/tests/testlistview.c b/tests/testlistview.c
index 567ab3224c..fcbac01e3c 100644
--- a/tests/testlistview.c
+++ b/tests/testlistview.c
@@ -636,7 +636,7 @@ main (int argc, char *argv[])
selectionmodel = file_info_selection_new (G_LIST_MODEL (filter));
g_object_unref (filter);
- gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selectionmodel));
+ gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selectionmodel));
statusbar = gtk_statusbar_new ();
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);