Re: Basic question - GtkTreeviewForeachFunc



On 24/05/06, John Coppens <john jcoppens com> wrote:
Hi guys.

I'm trying to get this working:

--------------- The function
gboolean
save_one_sat(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
                gpointer data)
{
  // do something
}

--------------- Is passed to another function like this:
  satlist_foreach_sat(save_one_sat);

--------------- This function is declared as:
void            satlist_foreach_sat(GtkTreeModelForeachFunc func);

--------------- Where the actual GtkTreeModelForeach will be called:
  gtk_tree_model_foreach(GTK_TREE_MODEL(sat_store), func, NULL);


Shouldn't this be:

gtk_tree_model_foreach(GTK_TREE_MODEL(sat_store), save_one_sat, NULL);

This will call save_one_sat for each row in sat_store. Otherwise I
don't know what 'func' is.


This segfaults, and gdb says the parameter passed to satlist_foreach_sat
is actually 0x1, not the address of the save_one_sat function. I've tried
declaring save_one_sat as static, I've typecasted the save_one_sat on
passing it as parameter. I've found several tutorials on the net that did
just this...

I guess the 0x1 is because the function is gboolean, and that value is
'TRUE', but why doesn't the function address get used?

Sorry if this is too basic... please point me to some good tutorial...

I have been using the GtkTreeView Tutorial at
http://scentric.net/tutorial/
to learn how to use the tree view stuff.

John

Cheers
Alex



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