From 3aa59d4ab9d1217fa47c4b1b265fd435547ed62f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 8 Mar 2014 16:42:57 -0500 Subject: Added Combobox/Listbox.Len() and its GTK+ implementation. --- listbox_unix.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'listbox_unix.go') diff --git a/listbox_unix.go b/listbox_unix.go index 10f2680..cc6ca44 100644 --- a/listbox_unix.go +++ b/listbox_unix.go @@ -211,3 +211,15 @@ func gListboxDelete(widget *gtkWidget, index int) { } C.gtk_list_store_remove(ls, &iter) } + +// this is a separate function because Combobox uses it too +func gtkTreeModelListLen(model *C.GtkTreeModel) int { + // "As a special case, if iter is NULL, then the number of toplevel nodes is returned." + return int(C.gtk_tree_model_iter_n_children(model, (*C.GtkTreeIter)(nil))) +} + +func gListboxLen(widget *gtkWidget) int { + tv := getTreeViewFrom(widget) + model := C.gtk_tree_view_get_model(tv) + return gtkTreeModelListLen(model) +} -- cgit v1.2.3