Kristian Rietveld wrote:
> 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 <tadeb...@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
>> tadeb...@gmail.com
>> tadej.borov...@gmail.com
>> _______________________________________________
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

That's what I thought, but I was hoping a function existed for
performance sake.  I'll just have to count the rows.  Thanks all.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to