gui/model: Add support for gtk_tree_model_iter_n_children()

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-17 10:02:51 -05:00
parent 13223427c1
commit ba59d6bd29
2 changed files with 13 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);
}