hashing table rows





Hi,

I'm making a gtk 2.0 table, and want to be able to associate table rows with function pointers. A table row may have children, may be removed, and will have zero or more functions associated with it. The idea is to have a a dynamic right click menu, so that when a row is right clicked, one could see which functions are associated with that row, and select one of these functions. I want to have the function:

add_right_click_menu_item(GtkTreeIter row, char * func_display_name, *callback, void *params_struct);

The first param is the row in question, the second is the name that will appear on the right click menu, the third is a pointer to the function to be called, and the fourth is a struct of arguments.

Can anybody suggest a good way to do this? I was thinking about using a GHashTable, with a GtkTreeIter as the key, and a linked list of pointers to the associated functions. When I recieve a right click event, I will look at the associated callbacks and build a menu. Can anybody tell me if this is a good way to do it? If so, can I use GtkTreeIters like that? Will they stay valid if I remove various items from the tree? How can I compare them? If I can't use GtkTreeIters, what can I use as the key and how do I compare them?

regards,
Stephane





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