Re: Treeview Row Count

Also note that for *lists* (so no parent nodes, no children) a call
like gtk_tree_model_iter_n_children (model, NULL) will suffice.


On Thu, Sep 24, 2009 at 1:32 PM, Tadej BorovÅak <tadeboro gmail com> wrote:

Is there a function to give the number of rows in a treeview?

You probably want to know how many lines are in the GtkTreeModel that
serves as data source for GtkTreeView. There is no simple function
that would serve you this number, so you'll have to take one of the
two available paths:
1) maintain number of rows externally by increasing/decreasing it on
2) traverse the whole model and count the lines

If you go with second option, gtk_tree_model_foreach function may be
of help. Sample counter would look like this:

---- CODE ----

gint no_rows = 0;

gtk_tree_model_foreach( model, (GtkTreeModelForeachFunc)count, &no_rows );


static gboolean
count( GtkTreeModel *model,
   GtkTreePath Â*path,
   GtkTreeIter Â*iter,
   gint     *no_rows )
 Âreturn( FALSE );
---- CODE ----


Tadej BorovÅak
tadeboro gmail com
tadej borovsak gmail com
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]