Re: gtk tree view index of node
- From: Tim Müller <zen18864 zen co uk>
- To: gtk-app-devel-list gnome org
- Subject: Re: gtk tree view index of node
- Date: Sat, 19 Jun 2004 12:57:14 +0100
On Saturday 19 June 2004 08:21, Marisa DeMeglio wrote:
I'm looking for a way to get a flat index of any node in a gtk tree
view. For example, in the following structure:
1. Birds
1.1 colorful birds
2. Dogs
2.1 little dogs
2.2 big dogs
item 2.2 would have a value of 5.
I didn't see anything in the API .. does anyone know if such a function
exists, or what would be a fast way to calculate this?
Maybe something along these lines:
gint
get_flat_idx (GtkTreeModel *model, GtkTreeIter *iter)
{
GtkTreePath *path;
gint idx, *indices, depth, i;
path = gtk_tree_model_get_path (model, iter);
if (path == NULL)
return -1
depth = gtk_tree_path_get_depth (path);
indices = gtk_tree_path_get_indices (path);
idx = 0;
for (i = 0; i < depth; ++i)
idx += (indices[i] + 1);
gtk_tree_path_free (path);
return idx + 1;
}
Cheers
-Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]