Re: Treeview Row Count
- From: Kristian Rietveld <kris gtk org>
- To: Tadej BorovÅak <tadeboro gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Treeview Row Count
- Date: Thu, 24 Sep 2009 13:41:48 +0200
Also note that for *lists* (so no parent nodes, no children) a call
like gtk_tree_model_iter_n_children (model, NULL) will suffice.
-kris.
On Thu, Sep 24, 2009 at 1:32 PM, Tadej BorovÅak <tadeboro gmail com> wrote:
Hello.
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
additions/removals
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 )
{
 Â*no_rows+;
 Âreturn( FALSE );
}
---- CODE ----
Tadej
--
Tadej BorovÅak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]