I need to know which gtktreeview was passed to a function from the handler (An identical function used for several button/treeview combinations so this is much more efficient than making a ton of different functions)
The problem is that once the function gets the treeview and has to work with it there doesn’t seem to be a way to identify it (Even based on something as simple as the amount of columns)
void
add_button_clicked(GtkTreeView * treeview,GtkButton * widget){
GtkTreeIter iter;
GtkListStore * store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
gtk_list_store_append (store, &iter);
if(items)
gtk_list_store_set (store, &iter,
ITEM_COL_ENABLED, 1,
-1);
else if(locations)
gtk_list_store_set (store, &iter,
LOCATION_COL_NAME, "Broken Shores",
LOCATION_COL_ENABLED, 1,
-1);
}
How can I distinguish between the two?
You can attach arbitrary data to any GObject; this is often overlooked, but it’s perfect for identifying the tree views in your case. When creating the treeview, do:
Then in your callback: