From ba59d6bd29f304de14a9750b70036ca630aef417 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Jan 2016 10:02:51 -0500 Subject: [PATCH] gui/model: Add support for gtk_tree_model_iter_n_children() Signed-off-by: Anna Schumaker --- gui/model.c | 9 +++++++++ tests/gui/model.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/gui/model.c b/gui/model.c index 1591e3ea..f62b9dc4 100644 --- a/gui/model.c +++ b/gui/model.c @@ -167,6 +167,14 @@ static gboolean _queue_model_iter_has_child(GtkTreeModel *model, return FALSE; } +static gint _queue_model_iter_n_children(GtkTreeModel *model, + GtkTreeIter *iter) +{ + if (iter != NULL) + return 0; + return queue_size(GUI_QUEUE_MODEL(model)->gqm_queue); +} + static void _queue_model_init(GuiQueueModel *model) { model->gqm_stamp = g_random_int(); @@ -198,6 +206,7 @@ static void _queue_tree_model_init(GtkTreeModelIface *iface) iface->iter_next = _queue_model_iter_next; iface->iter_children = _queue_model_iter_children; iface->iter_has_child = _queue_model_iter_has_child; + iface->iter_n_children = _queue_model_iter_n_children; } diff --git a/tests/gui/model.c b/tests/gui/model.c index a79ebbc6..753904d1 100644 --- a/tests/gui/model.c +++ b/tests/gui/model.c @@ -90,6 +90,8 @@ static void test_empty() test_equal(gtk_tree_model_iter_next(model, &iter), false); test_equal(gtk_tree_model_iter_children(model, &iter, NULL), false); test_equal(gtk_tree_model_iter_has_child(model, &iter), false); + test_equal(gtk_tree_model_iter_n_children(model, &iter), 0); + test_equal(gtk_tree_model_iter_n_children(model, NULL), 0); g_object_unref(model); } @@ -163,6 +165,8 @@ static void test_model() test_equal(track->tr_track, 1); test_equal(gtk_tree_model_iter_has_child(model, &iter), false); + test_equal(gtk_tree_model_iter_n_children(model, &iter), 0); + test_equal(gtk_tree_model_iter_n_children(model, NULL), 13); g_object_unref(model); }