summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-09-01 04:59:06 +0200
committerBenjamin Otte <otte@redhat.com>2018-09-16 18:50:17 +0200
commit4b5fb5ec7999e473064afacb107f99438b3a4eed (patch)
tree24d12485fdeb44e61ea8791a73b017b079d0d118 /testsuite
parent4f70f7234997bcb6ae91bbaaa277c573fc17b414 (diff)
downloadgtk+-4b5fb5ec7999e473064afacb107f99438b3a4eed.tar.gz
treelistmodel: Refactor to add GtkTreeListRow
This patch does multiple things: 1. Add a custom persistent per-row object. 2. Move all per-row API to that object. This means notifications are now possible. 3. Add a "passthrough" construct-only property to the TreeListModel that influences if the model returns these new object or passes through the ones from the model. This greatly simplifies the code needed to be written for widgetry, because one can just connect the per-row object to the expanders that expand and collapse rows. As an added power feature, these objects can also be passed through further models (like filter models). It also adds kind of a hack to Adwaita to make the test look neat.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/notify.c5
-rw-r--r--testsuite/gtk/treelistmodel.c14
2 files changed, 15 insertions, 4 deletions
diff --git a/testsuite/gtk/notify.c b/testsuite/gtk/notify.c
index 6474e2656f..47ca99207b 100644
--- a/testsuite/gtk/notify.c
+++ b/testsuite/gtk/notify.c
@@ -604,6 +604,11 @@ test_type (gconstpointer data)
g_str_equal (pspec->name, "max-content-height")))
continue;
+ /* expanding only works if rows are expandable */
+ if (g_type_is_a (type, GTK_TYPE_TREE_LIST_ROW) &&
+ g_str_equal (pspec->name, "expanded"))
+ continue;
+
if (g_test_verbose ())
g_print ("Property %s.%s\n", g_type_name (pspec->owner_type), pspec->name);
diff --git a/testsuite/gtk/treelistmodel.c b/testsuite/gtk/treelistmodel.c
index af6683ab66..91a7b180f7 100644
--- a/testsuite/gtk/treelistmodel.c
+++ b/testsuite/gtk/treelistmodel.c
@@ -167,7 +167,7 @@ new_model (guint size,
GtkTreeListModel *tree;
GString *changes;
- tree = gtk_tree_list_model_new (G_LIST_MODEL (new_store (size, size, size)), expanded, create_sub_model_cb, NULL, NULL);
+ tree = gtk_tree_list_model_new (TRUE, G_LIST_MODEL (new_store (size, size, size)), expanded, create_sub_model_cb, NULL, NULL);
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(tree), changes_quark, changes, free_changes);
g_signal_connect (tree, "items-changed", G_CALLBACK (items_changed), changes);
@@ -185,21 +185,27 @@ test_expand (void)
for (i = g_list_model_get_n_items (G_LIST_MODEL (tree)); i > 0; i--)
{
- gtk_tree_list_model_set_expanded (tree, i - 1, TRUE);
+ GtkTreeListRow *row = gtk_tree_list_model_get_row (tree, i - 1);
+ gtk_tree_list_row_set_expanded (row, TRUE);
+ g_object_unref (row);
}
assert_model (tree, "100 100 90 80 70 60 50 40 30 20 10");
assert_changes (tree, "1+10");
for (i = g_list_model_get_n_items (G_LIST_MODEL (tree)); i > 0; i--)
{
- gtk_tree_list_model_set_expanded (tree, i - 1, TRUE);
+ GtkTreeListRow *row = gtk_tree_list_model_get_row (tree, i - 1);
+ gtk_tree_list_row_set_expanded (row, TRUE);
+ g_object_unref (row);
}
assert_model (tree, "100 100 100 99 98 97 96 95 94 93 92 91 90 90 89 88 87 86 85 84 83 82 81 80 80 79 78 77 76 75 74 73 72 71 70 70 69 68 67 66 65 64 63 62 61 60 60 59 58 57 56 55 54 53 52 51 50 50 49 48 47 46 45 44 43 42 41 40 40 39 38 37 36 35 34 33 32 31 30 30 29 28 27 26 25 24 23 22 21 20 20 19 18 17 16 15 14 13 12 11 10 10 9 8 7 6 5 4 3 2 1");
assert_changes (tree, "11+10, 10+10, 9+10, 8+10, 7+10, 6+10, 5+10, 4+10, 3+10, 2+10");
for (i = g_list_model_get_n_items (G_LIST_MODEL (tree)); i > 0; i--)
{
- gtk_tree_list_model_set_expanded (tree, i - 1, TRUE);
+ GtkTreeListRow *row = gtk_tree_list_model_get_row (tree, i - 1);
+ gtk_tree_list_row_set_expanded (row, TRUE);
+ g_object_unref (row);
}
assert_model (tree, "100 100 100 99 98 97 96 95 94 93 92 91 90 90 89 88 87 86 85 84 83 82 81 80 80 79 78 77 76 75 74 73 72 71 70 70 69 68 67 66 65 64 63 62 61 60 60 59 58 57 56 55 54 53 52 51 50 50 49 48 47 46 45 44 43 42 41 40 40 39 38 37 36 35 34 33 32 31 30 30 29 28 27 26 25 24 23 22 21 20 20 19 18 17 16 15 14 13 12 11 10 10 9 8 7 6 5 4 3 2 1");
assert_changes (tree, "");